![]() |
Overview | ![]() |
By using an integer type for polygon coordinates, the Clipper Library has been able to avoid problems of numerical robustness that can cause havoc with geometric computations. Problems associated with integer rounding and their possible solutions are discussed below.
It's important to stress at the outset that rounding causes vertices to move fractions of a unit away from their 'true' positions. Nevertheless, the resulting imprecision can be very effectively managed by appropriate scaling.
Very high degrees of precision can be achieved by scaling (or increasing scaling) of polygon coordinates.
The Clipper library accepts integer coordinate values in the range ±0x3FFFFFFFFFFFFFFF (± 4.6e+18) in order to accommodate very high degrees of precision.
Apart from the imprecision resulting from vertices being forced onto an integer grid, another complication that very occasionally arises is tiny self-intersection artefacts. In the unscaled image on the left (where one unit equals one pixel), the area of intersection of 2 polygons has been highlighted in bright green.
A 30X 'close up' of the lower points of intersection of these same 2 polygons shows the presence of a tiny self-intersecting artefact. The three 'black dots' highlight the actual points of intersection (with their fractional coordinates displayed). The 'red dots' show where these points of intersection are located once rounding is applied. With a little care you can see that rounding reverses the orientation of these vertices and causes a tiny self-intersecting artefact.
Although these tiny self-intersections are uncommon, if it's deemed necessary, they can be removed using CleanPolygons.
In this final example, the single polygon on the left also has a tiny self-intersection. However, the clipping algorithm sees this vertex (88,50) as simply 'touching' rather than intersecting the right edge of the polygon (though only by a fraction of a unit). Since this intersection won't be detected, the clipping solution (eg following a union operation) will still contain this tiny self-intersection.
Copyright ©2010-2013 Angus Johnson - Clipper Ver 5.1.6 - Help file built on 24-May-2013