@technobuddha > library > Geometry
Polygon
| Name | Type | Description |
|---|---|---|
| area | Function | Calculates the area of a polygon given its vertices. |
| bounds | Function | Calculates the axis-aligned bounding rectangle for a given polygon. |
| centroid | Function | Calculates the centroid (geometric center) of a polygon. |
| convexHull | Function | Computes the convex hull of a set of 2D points using the Monotone Chain algorithm. |
| edgeAngles | Function | Generate normalized edge angles from polygon edges. |
| isClosed | Function | Determines whether a given polygon is closed. |
| isIntersecting | Function | Determines whether a given shape (either a LineSegment or a Polygon) intersects with a polygon. |
| isOnPolygon | Function | Determines whether a given point lies exactly on the boundary of a polygon. |
| isPolygon | Function | Determines if the provided object is a Polygon. |
| perimeter | Function | Calculates the perimeter of a polygon. |
| Polygon | Type | A polygon (a set of cartesian coordinates) |
| regularPolygon | Function | Generates a regular polygon. |
| rotate | Function | Rotates a point or a polygon around a given origin by a specified angle. |
| scale | Function | Scales a point or a polygon of points around a given origin by a specified amount. |
| star | Function | Generates a star-shaped polygon. |
| toClosed | Function | Ensures that a given polygon is closed by checking if the first and last points are the same. If the polygon is not closed, it appends the first point to the end of the array. |
| toPolygon | Function | Converts two Cartesian points or a Rect into a Polygon. |
| translate | Function | Translate a point or polygon by a specified amount. |