Expand description
Weiler-Atherton polygon clipping engine
Production-grade polygon clipping supporting Intersection, Union, Difference, and Symmetric Difference (XOR) operations. Handles holes, degeneracies, self-intersecting polygons, and floating-point edge cases.
§Algorithm
The Weiler-Atherton algorithm proceeds in five phases:
- Intersection detection – segment-segment tests between polygon boundaries
- Entry/exit labeling – cross-product orientation classifies each intersection as entering or exiting the other polygon
- Polygon tracing – walk along subject/clip polygons, switching at intersections to build result rings
- Hole handling – process holes independently, classify output rings as exterior/interior by winding, assign holes via point-in-polygon
- Degeneracy handling – epsilon snap, zero-length edge removal
§Operations
ClipOperation::Intersection– area in both A and BClipOperation::Union– area in A or B (or both)ClipOperation::Difference– area in A but not BClipOperation::SymmetricDifference– area in A or B but not both
Enums§
- Clip
Operation - Polygon clipping operation kind.
Functions§
- clip_
multi - Clip subject against a set of clip polygons in sequence.
- clip_
polygons - Clip two polygons with the given boolean operation.