Import std.math.polygon
PolygonArea
function
Public Function PolygonArea(ring: Vec2[]): Double
The area of the ring, above 0 when it goes counterclockwise and below when it goes clockwise:
the shoelace formula, in Doubles.
Examples
Local square = [Vec2(0, 0), Vec2(4, 0), Vec2(4, 4), Vec2(0, 4)]
Expect(PolygonArea(square) == 16.0)
Expect(PointInPolygon(Vec2(1, 1), square) && !PointInPolygon(Vec2(5, 1), square))
Expect(Triangulate(square).Count == 2)function
Public Function PolygonArea(rings: Vec2[][]): Double
The area of the region, its outer rings' less its holes', as each ring's PolygonArea adds up.
Report an issue with this page or with FutureBlitz on GitHub.