Polygon measures (spec/07 §21), copied from visualize's Visualize.Polygon over lists of
{x, y} tuples; a polygon is implicitly closed. Geographic polygons, contours and
Voronoi cells (spec/09) measure through this module.
iex> square = [{0, 0}, {100, 0}, {100, 100}, {0, 100}]
iex> {Macaw.Draw.Polygon.area(square), Macaw.Draw.Polygon.centroid(square)}
{10000.0, {50.0, 50.0}}hull/1 is Andrew's monotone chain, O(n log n); every other measure is one pass over
the points (visualize read them by position, a square of their count). A list holding a
term that is no pair of numbers is {[i], {:type, :point}} at its index.
Summary
Functions
The signed shoelace area: positive when the vertices wind counter-clockwise in a y-up
frame (clockwise on screen, where y points down); 0.0 for fewer than three points.
{min_x, min_y, max_x, max_y}, or nil for [].
The area-weighted centroid: {0.0, 0.0} for [], the point itself for one, the midpoint
for two, the vertex mean when |area| < 1.0e-10.
Whether point is inside, by even-odd ray casting; false for fewer than three points.
A point exactly on an edge may answer either.
The convex hull by Andrew's monotone chain: counter-clockwise (y-up), collinear points and duplicates removed; two or fewer points are returned unchanged.
The length of the open polyline: no closing edge.
The sum of edge lengths, the closing edge included; 0.0 for fewer than two points.
Types
@type error() :: {:error, [Macaw.Base.Fault.t()]}
A refusal: faults with their paths.
@type polygon() :: [point()]
Functions
The signed shoelace area: positive when the vertices wind counter-clockwise in a y-up
frame (clockwise on screen, where y points down); 0.0 for fewer than three points.
{min_x, min_y, max_x, max_y}, or nil for [].
The area-weighted centroid: {0.0, 0.0} for [], the point itself for one, the midpoint
for two, the vertex mean when |area| < 1.0e-10.
Whether point is inside, by even-odd ray casting; false for fewer than three points.
A point exactly on an edge may answer either.
The convex hull by Andrew's monotone chain: counter-clockwise (y-up), collinear points and duplicates removed; two or fewer points are returned unchanged.
The length of the open polyline: no closing edge.
The sum of edge lengths, the closing edge included; 0.0 for fewer than two points.