Represents a 2D polygon consisting of a list of ordered vertices.
- Source:
- See:
-
- poly2 for data structure information.
Examples
poly2.create([[0,0], [4,0], [4,3]])
{"vertices": [[0,0], [4,0], [4,3]]}
Members
(static, constant) measureArea
Measure the area under the given polygon.
Methods
(static) arePointsInside(points, polygon) → {Integer}
Determine if the given points are inside the given polygon.
Parameters:
Name | Type | Description |
---|---|---|
points |
Array | a list of points, where each point is an array with X and Y values |
polygon |
poly2 | a 2D polygon |
Returns:
1 if all points are inside, 0 if some or none are inside
- Type
- Integer
(static) create(verticesopt) → {poly2}
Creates a new polygon with initial values.
Example
let polygon = create()
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
vertices |
Array |
<optional> |
list of vertices (2D) |
Returns:
a new polygon
- Type
- poly2
(static) flip(polygon) → {poly2}
Flip the give polygon, rotating the opposite direction.
Parameters:
Name | Type | Description |
---|---|---|
polygon |
poly2 | the polygon to flip |
Returns:
a new polygon
- Type
- poly2