Triangle

A geometric triangle as defined by three Vector3s representing its three corners.

Constructor

new Triangle(aopt, bopt, copt)

Parameters:
NameTypeAttributesDescription
aVector3<optional>

the first corner of the triangle. Default is a Vector3 at (0, 0, 0).

bVector3<optional>

the second corner of the triangle. Default is a Vector3 at (0, 0, 0).

cVector3<optional>

the final corner of the triangle. Default is a Vector3 at (0, 0, 0).

Methods

set(a, b, c) → {Triangle}

Sets the triangle's a, b and c properties to the passed vector3s.

Parameters:
NameTypeDescription
aVector3
bVector3
cVector3
Returns:
Type: 
Triangle

(static) barycoordFromPoint(point, a, b, c, targetopt) → {Vector3}

static/instance method to calculate barycentric coordinates. based on: http://www.blackpawn.com/texts/pointinpoly/default.html

Parameters:
NameTypeAttributesDescription
pointVector3

Vector3

aVector3
bVector3
cVector3
targetVector3<optional>

the result will be copied into this Vector3.

Returns:
Type: 
Vector3

(static) containsPoint(point, a, b, c) → {Vector3}

Returns true if the passed point, when projected onto the plane of the triangle, lies within the triangle.

Parameters:
NameTypeDescription
pointVector3
aVector3
bVector3
cVector3
Returns:
Type: 
Vector3

(static) normal(a, b, c, optionalTargetopt) → {Vector3}

Calculate the normal vector of the triangle.

Parameters:
NameTypeAttributesDescription
aVector3
bVector3
cVector3
optionalTargetVector3<optional>
Returns:
Type: 
Vector3