Polygon()

Class for representing a planar polygon with an arbitrary amount of edges.

new Polygon()

Constructs a new polygon.

Author:

Members

centroid :Vector3

The centroid of this polygon.

nullable edge :HalfEdge

A reference to the first half-edge of this polygon.

Default Value:
  • null

plane :Plane

A plane abstraction of this polygon.

Methods

computeCentroid() → {Polygon}

Computes the centroid for this polygon.

Returns:
Polygon -

A reference to this polygon.

contains(point, epsilon) → {Boolean}

Returns true if the polygon contains the given point.

Parameters:
Name Type Default Description
point Vector3

The point to test.

epsilon Number 0.001

A tolerance value.

Returns:
Boolean -

Whether this polygon contain the given point or not.

convex(ccw) → {Boolean}

Returns true if the polygon is convex.

Parameters:
Name Type Default Description
ccw Boolean true

Whether the winding order is CCW or not.

Returns:
Boolean -

Whether this polygon is convex or not.

coplanar(epsilon) → {Boolean}

Returns true if the polygon is coplanar.

Parameters:
Name Type Default Description
epsilon Number 0.001

A tolerance value.

Returns:
Boolean -

Whether this polygon is coplanar or not.

distanceToPoint(point) → {Number}

Computes the signed distance from the given 3D vector to this polygon. The method uses the polygon's plane abstraction in order to compute this value.

Parameters:
Name Type Description
point Vector3

A point in 3D space.

Returns:
Number -

The signed distance from the given point to this polygon.

fromContour(points) → {Polygon}

Creates the polygon based on the given array of points in 3D space. The method assumes the contour (the sequence of points) is defined in CCW order.

Parameters:
Name Type Description
points Array.<Vector3>

The array of points.

Returns:
Polygon -

A reference to this polygon.

getContour(result) → {Array.<Vector3>}

Determines the contour (sequence of points) of this polygon and stores the result in the given array.

Parameters:
Name Type Description
result Array.<Vector3>

The result array.

Returns:
Array.<Vector3> -

The result array.