Home | Overview |

# FAQ

Why does Clipper use integer coordinates, not floats?

This has been done to preserve numerical robustness. Early versions of the library did use floating point coordinates, but it became apparent that floating point imprecision was always going to cause occasional errors.

How do I use floating point coordinates with Clipper?

It's a simple task to multiply your floating point coordinates by a scaling factor (that's typically a power of 10 depending on the desired precision). Then with the solution polygons, divide the returned coordinates by this same scaling factor. Clipper accepts integer coordinates as large as ±4.6e18, so it can accommodate very large scaling factors.

Does Clipper handle polygons with holes?

'Holes' are implied simply by having their orientations opposite that of their container polygons.

Some solution polygons share a common edge. Is this a bug?

No. However Clipper tries very hard to minimize this by merging polygons that share a common edge.

I have lots of polygons that I want to 'union'. Can I do this in one operation?

Yes. Just add all the polygons as subject polygons to the Clipper object. (You don't have to assign both subject and clip polygons.)

The OffsetPolygons function is returning tiny artefacts? Could this be a bug?

The precision of the input coordinates may be a problem. The Clipper Library only operates on integer coordinates so if you need better precision than integers, scale the coordinates (eg by a factor of 10) before passing them to the OffsetPolygons function. Then it's a simple matter to reverse the scaling on the output polygons.

The OffsetPolygons function is returning unexpected results? Could this be a bug?

Most likely the orientation of the input polygons is wrong.

Is there an easy way to reverse polygon orientations?

Yes, see ReversePolygons.

Is it possible to get the offset of a line or a polyline?

Yes. If it's two vertices forming a single line, just treat this line as if it were a polygon. Polylines however must first be converted into 'flat' polygons. Do this by appending to the polyline a reverse copy of the polyline while avoiding duplicating the end coordinates: c1,c2,...,cn,c(n-1),c(n-2),...,c2.

    var
      pts: TPolygon;
      ppts: TPolygons;
    begin
      //define the polyline ...
      setlength(pts, 5);
      pts[0] := IntPoint(10,10);
      pts[1] := IntPoint(100,100);
      pts[2] := IntPoint(150,100);
      pts[3] := IntPoint(100,10);
      pts[4] := IntPoint(10,100);

      //convert the line to a 'flat' polygon ...
      len := length(pts);
      setLength(pts, len*2 -2);
      for i := 1 to len -2 do pts[len-1 +i] := pts[len-1 -i];

      //do the offsetting ...
      setlength(ppts, 1);
      ppts[0] := pts;
      ppts := OffsetPolygons(ppts, 6, jtSquare, 0);

My drawings contain lots of ellipses and arcs. How can I perform clipping operations or offsetting on these?

You'll have to convert then to polygons. Many graphics libraries have 'flatten path' routines.

## See Also

OffsetPolygons, Orientation, ReversePolygons

Copyright ©2010-2013 Angus Johnson - Clipper version 5.1.5 - Help file built on 6-May-2013