Skip to content

Search

Documentation

geometry2d

Polygons on the plane as lists of Vec2 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 Vec2 points in outline order: triangulation, booleans, hulls and containment. Every answer is identical on every platform.

11 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([Vec2]) -> float — The polygon's area, always positive whatever its winding.
contains([Vec2], Vec2) -> bool — Whether a point lies inside the polygon. A point exactly on an edge may answer either way.
convex_decomposition([Vec2], geometry2d::DecompositionOptions?) -> [[Vec2]] — 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([Vec2]) -> [Vec2] — The smallest convex polygon around the points, counter-clockwise.
difference([Vec2], [Vec2], geometry2d::BooleanOptions?) -> [[[Vec2]]] — Everything inside the first polygon and outside the second, shaped and tuned as union is.
intersection([Vec2], [Vec2], geometry2d::BooleanOptions?) -> [[[Vec2]]] — Everything inside both polygons, shaped and tuned as union is.
is_clockwise([Vec2]) -> bool — Whether the points run clockwise, with y up.
segments_intersect(Vec2, Vec2, Vec2, Vec2) -> Vec2? — Where two segments cross, or nil when they do not; touching at an endpoint counts.
symmetric_difference([Vec2], [Vec2], geometry2d::BooleanOptions?) -> [[[Vec2]]] — Everything inside exactly one of the two polygons, shaped and tuned as union is.
triangulate([Vec2]) -> [[int]] — The polygon cut into triangles, as [i, j, k] triples indexing its points, counter-clockwise; either winding is accepted.
union([Vec2], [Vec2], geometry2d::BooleanOptions?) -> [[[Vec2]]] — 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.

Are you sure?