Vector3D

Immutable 3D vector.

Constructor

new Vector3D(x, y, z)

Parameters:
NameTypeDescription
xnumber

The X component of the vector.

ynumber

The Y component of the vector.

znumber

The Z component of the vector.

Classes

Vector3D

Methods

crossProduct(vector3D) → {Vector3D}

Get the cross product with another Vector3D, ie the vector that is perpendicular to both a and b. If both vectors are parallel, the cross product is a zero vector.

Parameters:
NameTypeDescription
vector3DVector3D

The input vector.

Returns:

The result vector.

Type: 
Vector3D

dotProduct(vector3D) → {number}

Get the dot product with another Vector3D.

Parameters:
NameTypeDescription
vector3DVector3D

The input vector.

Returns:

The dot product.

Type: 
number

equals(rhs) → {boolean}

Check for Vector3D equality.

Parameters:
NameTypeDescription
rhsVector3D

The other vector to compare to.

Returns:

True if both vectors are equal.

Type: 
boolean

getX() → {number}

Get the X component of the vector.

Returns:

The X component of the vector.

Type: 
number

getY() → {number}

Get the Y component of the vector.

Returns:

The Y component of the vector.

Type: 
number

getZ() → {number}

Get the Z component of the vector.

Returns:

The Z component of the vector.

Type: 
number

norm() → {number}

Get the norm of the vector.

Returns:

The norm.

Type: 
number

toString() → {string}

Get a string representation of the Vector3D.

Returns:

The vector as a string.

Type: 
string