modeling/geometries/poly2

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

Source:

Measure the area under the given polygon.

Methods

(static) arePointsInside(points, polygon) → {Integer}

Source:

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}

Source:

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}

Source:

Flip the give polygon, rotating the opposite direction.

Parameters:
Name Type Description
polygon poly2

the polygon to flip

Returns:

a new polygon

Type
poly2