# modeling/geometries/poly3

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

Source:
See:
• poly3 for data structure information.
##### Examples
``poly3.create([[0,0,0], [4,0,0], [4,3,12]])``
``{"vertices": [[0,0,0], [4,0,0], [4,3,12]]}``

### 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

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)

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)

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

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

a new poly3

Type
poly3

#### (static) isA(object) → {Boolean}

Source:

Determine if the given object is a polygon.

##### Parameters:
Name Type Description
`object` Object

the object to interrogate

##### 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 interrogate

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) → {vec4}

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
vec4

#### (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 tetrahedron 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 polygon 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

a new polygon

Type
poly3

#### (static) validate(object)

Source:

Determine if the given object is a valid polygon. Checks for valid data structure, convex polygons, and duplicate points.

If the geometry is not valid, an exception will be thrown with details of the geometry error.

##### Parameters:
Name Type Description
`object` Object

the object to interrogate

##### Throws:

error if the geometry is not valid

Type
Error