Matrix4

Matrix4

Matrix with 4x4 components.

Constructor

new Matrix4(…args)

Parameters:
Name Type Attributes Description
args number | Matrix4 | Array.<number> <repeatable>

A Initial values for the components.

Members

mul2

Deprecated:
  • Deprecated as of 0.23.x Multiplies the matrix's values with another matrix's values; an alias for .mult

set

Sets the matrix's values from another matrix's values; an alias for .copy

Methods

add(rhs) → {Matrix4}

Performs a component-wise addition.

Parameters:
Name Type Description
rhs Matrix4

Matrix or scalar on the right-hand side.

clone() → {Matrix4}

Returns a new matrix with the same values as the existing one.

compose(position, rotation, scale, scaleRotationopt) → {Matrix4}

Use provided position, rotation, scale and scaleRotation to compose the matrix

Parameters:
Name Type Attributes Description
position Vector3

storage for position

rotation Matrix3

storage for rotation. NOTE: it has to be an orthogonal matrix

scale Vector3

storage for scale.

scaleRotation Matrix3 <optional>

Storage for scaleRotation. If not provided, it will be set to Identity matrix. NOTE: it has to be an orthogonal matrix

copy(rhs) → {Matrix4}

Copies component values and stores them locally.

Parameters:
Name Type Description
rhs Matrix4

Source matrix.

decompose(position, rotation, scale, scaleRotation, sortScaleopt) → {Matrix4}

Fills in the given position, rotation, scale and scaleRotation represented by the Matrix.

Parameters:
Name Type Attributes Default Description
position Vector3

storage for the jposition vector

rotation Matrix3

storage for the jrotation matrix

scale Vector3

storage for the jscale vector

scaleRotation Matrix3

storage for the scaleRotation matrix

sortScale boolean <optional>
false

Sort the scale vector or not

determinant() → {number}

Computes the determinant of the matrix.

equals(rhs, epsilonopt) → {boolean}

Compares two matrices for approximate equality

Parameters:
Name Type Attributes Description
rhs Matrix4

The matrix to compare against

epsilon number <optional>

Maximum tolerance

getRotation(store) → {Matrix4}

Gets the rotational part of the matrix (the upper left 3x3 matrix).

Parameters:
Name Type Description
store Matrix3

Rotation matrix to store in.

getScale(store) → {Matrix4}

Gets the scaling part of the matrix.

Parameters:
Name Type Description
store Vector3

Scaling vector to store result in.

getTranslation(store) → {Matrix4}

Gets the translational part of the matrix.

Parameters:
Name Type Description
store Vector3

Translation vector to store result in.

invert() → {Matrix4}

Computes the analytical inverse and stores the result locally.

isNormal() → {Boolean}

Tests if the matrix is normal.

isOrthogonal() → {Boolean}

Tests if the matrix is orthogonal.

isOrthonormal() → {Boolean}

Tests if the matrix is orthonormal.

mul(rhs) → {Matrix4}

Parameters:
Name Type Description
rhs Matrix4

Matrix on the right-hand side

Deprecated:
  • Use Matrix4.mult instead. Multiplies this matrix with another matrix

mult(lhs, rhs) → {Matrix4}

Multiplies two matrices and stores the result in this matrix

Parameters:
Name Type Description
lhs Matrix4

Matrix on the left-hand side

rhs Matrix4

Matrix on the right-hand side

multiplyScalar(scalar) → {Matrix4}

Multiplies this matrix with a scalar

Parameters:
Name Type Description
scalar number

scale(scale) → {Matrix4}

Scales the matrix.

Parameters:
Name Type Description
scale Vector3

Scale vector.

setArray(rhsData) → {Matrix4}

Sets matrix values from an array.

Parameters:
Name Type Description
rhsData Array.<number>

Array source

setIdentity() → {Matrix4}

Sets the matrix to identity.

setRotationFromQuaternion(quaternion) → {Matrix4}

Sets the rotational part of the matrix from a quaternion.

Parameters:
Name Type Description
quaternion Vector4

Rotational quaternion.

setRotationFromVector(angles) → {Matrix4}

Sets the rotational part of the matrix from a vector of angles. Order convention is x followed by y followed by z.

Parameters:
Name Type Description
angles Vector3

Rotational angles in radians.

setScale(scale) → {Matrix4}

Sets the scale of the matrix.

Parameters:
Name Type Description
scale Vector3

Scale vector.

setTranslation(translation) → {Matrix4}

Sets the translational part of the matrix.

Parameters:
Name Type Description
translation Vector3

Translation vector.

sub(rhs) → {Matrix4}

Performs a component-wise subtraction.

Parameters:
Name Type Description
rhs Matrix4

Matrix or scalar on the right-hand side.

transpose() → {Matrix4}

Transposes a matrix (exchanges rows and columns)

(static) invert(source, targetopt) → {Matrix4}

Computes the analytical inverse and stores the result in a separate matrix.

Parameters:
Name Type Attributes Description
source Matrix4

Source matrix.

target Matrix4 <optional>

Target matrix.