2D polygon geometry primitives — signed area, point-in-polygon
ray casting, Douglas-Peucker polyline / loop simplification, and
marching-squares contour extraction from a binary raster mask.
Lives next to the rest of the math primitives (vector,
matrix, boundaries, …) — every operation here
is pure 2D arithmetic with no scene-graph or rendering
dependencies.
Two point representations are supported for the signed-area and
point-in-polygon helpers:
Tuple-array form (Point2D = [number, number]): natural
for marching-squares output and Douglas-Peucker walks, and
for any code that thinks in terms of point objects.
Flat-array form (interleaved [x0, y0, x1, y1, …]):
natural for code paths that already pack coordinates into a
single buffer (section-cap loops, GPU-bound vertex streams).
The two forms are layout-compatible — pick whichever matches
how the caller already stores its points; no copying needed.
2D polygon geometry primitives — signed area, point-in-polygon ray casting, Douglas-Peucker polyline / loop simplification, and marching-squares contour extraction from a binary raster mask.
Lives next to the rest of the math primitives (vector, matrix, boundaries, …) — every operation here is pure 2D arithmetic with no scene-graph or rendering dependencies.
Two point representations are supported for the signed-area and point-in-polygon helpers:
Point2D = [number, number]): natural for marching-squares output and Douglas-Peucker walks, and for any code that thinks in terms of point objects.[x0, y0, x1, y1, …]): natural for code paths that already pack coordinates into a single buffer (section-cap loops, GPU-bound vertex streams).The two forms are layout-compatible — pick whichever matches how the caller already stores its points; no copying needed.