geometry2d
Polygons on the plane, as lists of [x, y] points in outline order: triangulation, booleans, hulls and containment. Every answer is the same on every platform: the booleans run in fixed point and the rest is plain arithmetic.
9 functions, 0 constants. Scripts reach it as geometry2d::.
Functions
Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.
| function | acts on | what it does |
|---|---|---|
area(any) -> float | — | The polygon's area, always positive whatever its winding. |
contains(any, any) -> bool | — | Whether a point lies inside the polygon; a point on an edge counts as inside. |
convex_hull(any) -> any | — | The smallest convex polygon around the points, counter-clockwise. |
difference(any, any) -> any | — | Everything inside the first polygon and outside the second, shaped as union shapes it. |
intersection(any, any) -> any | — | Everything inside both polygons, shaped as union shapes it. |
is_clockwise(any) -> bool | — | Whether the points run clockwise, with y up. |
segments_intersect(any, any, any, any) -> any | — | Where two segments cross, or nil when they do not; touching at an endpoint counts. |
triangulate(any) -> any | — | The polygon cut into triangles, as [i, j, k] triples indexing its points, counter-clockwise; either winding is accepted. |
union(any, any) -> any | — | Everything inside either polygon: a list of shapes, each a list of paths whose first is the outline and the rest holes. |