Skip to content

Search

Documentation

geometry2d module

Polygons on the plane as lists of [x, y] points in outline order: triangulation, booleans, hulls and containment. Every answer is identical on every…

On this page

Polygons on the plane as lists of [x, y] points in outline order: triangulation, booleans, hulls and containment. Every answer is identical on every platform.

12 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_decomposition(any, any?) -> any — The polygon cut into convex pieces that overlap across their seams, so nothing wedges into one; overlap from 0 to 1 says how far each piece grows, 0.9 by default.
convex_hull(any) -> any — The smallest convex polygon around the points, counter-clockwise.
difference(any, any, any?) -> any — Everything inside the first polygon and outside the second, shaped and tuned as union is.
intersection(any, any, any?) -> any — Everything inside both polygons, shaped and tuned as union is.
is_clockwise(any) -> bool — Whether the points run clockwise, with y up.
reverse_difference(any, any, any?) -> any — Everything inside the second polygon and outside the first, shaped and tuned as union is.
segments_intersect(any, any, any, any) -> any — Where two segments cross, or nil when they do not; touching at an endpoint counts.
symmetric_difference(any, any, any?) -> any — Everything inside exactly one of the two polygons, shaped and tuned as union is.
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?) -> any — Everything inside either polygon: a list of shapes, each a list of paths whose first is the outline and the rest holes. opts takes fill_rule (even_odd, non_zero, positive, negative; even_odd unless given), min_area, keep_collinear and clean_result, as boolean2d does.