d4_polygon library
This package provides a few basic geometric operations for two-dimensional polygons.
Each polygon is represented as an list of two-element list [[x0, y0], [x1, y1], …], and may either be closed (wherein the first and last point are the same) or open (wherein they are not). Typically polygons are in counterclockwise order, assuming a coordinate system where the origin is in the top-left corner.
Functions
-
polygonArea(
List< List< polygon) → numnum> > -
Returns the signed area of the specified
polygon
. -
polygonCentroid(
List< List< polygon) → List<num> >num> -
Returns the centroid of the
specified
polygon
. -
polygonContains(
List< List< polygon, List<num> >num> point) → bool -
Returns true if and only if the specified
point
is inside the specifiedpolygon
. -
polygonHull(
List< List< points) → List<num> >List< ?num> > -
Returns the convex hull of the
specified
points
using Andrew’s monotone chain algorithm. -
polygonLength(
List< List< polygon) → numnum> > -
Returns the length of the perimeter of the specified
polygon
.