Skip to main content

Module polygon_boolean

Module polygon_boolean 

Source
Expand description

Boolean operations on simple polygons by the Greiner-Hormann algorithm.

Both polygons are walked as cyclic vertex lists with their mutual edge intersections inserted; each intersection is classified as an entry into or exit from the other polygon, and the result is traced by following one polygon until the next intersection, then switching to the other. Degenerate configurations (a vertex on the other polygon’s boundary, overlapping collinear edges) are resolved by perturbing the clip polygon by a relative 1e-9, so results are exact up to that tolerance. Results are counter-clockwise outer boundaries and clockwise holes. Holes arise in a difference when the clip polygon lies strictly inside the subject, and in a union when the two polygons enclose a region between them; areas add up correctly when the holes’ negative signed areas are included.

See the book entry Convex hulls and polygon booleans.

Enums§

BooleanOperation
The boolean operation.

Functions§

point_in_polygon
Whether p is inside the polygon (even-odd rule).
polygon_boolean
Applies operation to the simple polygons subject and clip (either orientation).