Skip to main content

Module polygon

Module polygon 

Source
Expand description

Generic 2-D polygon area, containment and triangulation — no topology or rendering dependency, so it lives here rather than in geop-core-rasterize: geop-core-topology’s own edit code (splice_edge_into_face’s loop-orientation check) needs it too, and topology sits below rasterize in the dependency order.

Structs§

Convex
A convex polygon, as the half-planes it is the intersection of: each an outward normal n and an offset c, the polygon lying where n · p ≤ c. What a box drawn on screen covers of a plane it looks at.

Functions§

ear_clip
Ear-clip a (possibly non-convex) simple polygon into triangles, as index triples into poly: n - 2 of them for n >= 3 corners, none for fewer. Plain numbers, for rendering: a corner that rounding leaves no ear at is cut off all the same.
polygon_signed_area
Signed area of poly (positive for CCW, negative for CW).
polygons_contain
Whether p lies inside the closed polylines loops, outer boundaries and holes alike: an odd number of crossings of a ray from p along +x. Only crossings that definitely happen count, so a p whose ray could graze a corner is decided as if it did not.