modeling/geometries/poly3

Represents a convex 3D polygon consisting of a list of vertices.

Source:
See:
  • poly3 for data structure information.

Methods

(static) clone(outopt, polygon) → {poly3}

Source:

Create a deep clone of the given polygon

Parameters:
Name Type Attributes Description
out poly3 <optional>

receiving polygon

polygon poly3

polygon to clone

Returns:

a new polygon

Type
poly3

(static) create(verticesopt) → {poly3}

Source:

Creates a new 3D polygon with initial values.

Parameters:
Name Type Attributes Description
vertices Array <optional>

a list of vertices (3D)

Returns:

a new polygon

Type
poly3

(static) fromPoints(points) → {poly3}

Source:

Create a polygon from the given points.

Example
const points = [
  [0,  0, 0],
  [0, 10, 0],
  [0, 10, 10]
]
const polygon = fromPoints(points)
Parameters:
Name Type Description
points Array

list of points (3D)

Returns:

a new polygon

Type
poly3

(static) fromPointsAndPlane(vertices, plane) → {poly3}

Source:

Create a polygon from the given vertices and plane. NOTE: No checks are performed on the parameters.

Parameters:
Name Type Description
vertices Array

list of vertices (3D)

plane plane

plane of the polygon

Returns:

a new polygon

Type
poly3

(static) invert(polygon) → {poly3}

Source:

Invert the give polygon to face the opposite direction.

Parameters:
Name Type Description
polygon poly3

the polygon to invert

Returns:

a new poly3

Type
poly3

(static) isA(object) → {Boolean}

Source:

Determin if the given object is a polygon.

Parameters:
Name Type Description
object Object

the object to interogate

Returns:

true if the object matches a poly3

Type
Boolean

(static) isConvex(polygon) → {Boolean}

Source:

Check whether the given polygon is convex.

Parameters:
Name Type Description
polygon poly3

the polygon to interogate

Returns:

true if convex

Type
Boolean

(static) measureArea(polygon) → {Number}

Source:
See:
  • 2000 softSurfer http://geomalgorithms.com

Measure the area of the given polygon.

Parameters:
Name Type Description
polygon poly3

the polygon to measure

Returns:

area of the polygon

Type
Number

(static) measureBoundingBox(polygon) → {Array}

Source:
Parameters:
Name Type Description
polygon poly3

the polygon to measure

Returns:

an array of two vectors (3D); minimum and maximum coordinates

Type
Array

(static) measureBoundingSphere(polygon) → {Array}

Source:

Measure the bounding sphere of the given polygon.

Parameters:
Name Type Description
polygon poly3

the polygon to measure

Returns:

the computed bounding sphere; center point (3D) and radius

Type
Array

(static) measureSignedVolume(polygon) → {Number}

Source:
See:

Measure the signed volume of the given polygon, which must be convex. The volume is that formed by the tetrahedon connected to the axis [0,0,0], and will be positive or negative based on the rotation of the vertices.

Parameters:
Name Type Description
polygon poly3

the polygon to measure

Returns:

volume of the polygon

Type
Number

(static) toPoints(polygon) → {Array}

Source:

Return the given geometry as a list of points. NOTE: The returned array should not be modified as the points are shared with the geometry.

Parameters:
Name Type Description
polygon poly3

the polygon

Returns:

list of points (3D)

Type
Array

(static) toString(polygon) → {String}

Source:
Parameters:
Name Type Description
polygon poly3

the polygon to measure

Returns:

the string representation

Type
String

(static) transform(matrix, polygon) → {poly3}

Source:

Transform the given polygon using the given matrix.

Parameters:
Name Type Description
matrix mat4

the matrix to transform with

polygon poly3

the polygon to transform

Returns:

a new polygon

Type
poly3