Matrix3()

Class representing a 3x3 matrix. The elements of the matrix are stored in column-major order.

new Matrix3()

Constructs a new 3x3 identity matrix.

Author:

Members

elements :Array.<Number>

The elements of the matrix in column-major order.

Methods

clone() → {Matrix3}

Creates a new matrix and copies all values from this matrix.

Returns:
Matrix3 -

A new matrix.

copy(m) → {Matrix3}

Copies all values from the given matrix to this matrix.

Parameters:
Name Type Description
m Matrix3

The matrix to copy.

Returns:
Matrix3 -

A reference to this matrix.

eigenDecomposition(result) → {Object}

Computes the eigenvectors and eigenvalues.

Reference: https://github.com/AnalyticalGraphicsInc/cesium/blob/411a1afbd36b72df64d7362de6aa934730447234/Source/Core/Matrix3.js#L1141 (Apache License 2.0)

The values along the diagonal of the diagonal matrix are the eigenvalues. The columns of the unitary matrix are the corresponding eigenvectors.

Parameters:
Name Type Description
result Object

An object with unitary and diagonal properties which are matrices onto which to store the result.

Returns:
Object -

An object with unitary and diagonal properties which are matrices onto which to store the result.

equals(m) → {Boolean}

Returns true if the given matrix is deep equal with this matrix.

Parameters:
Name Type Description
m Matrix3

The matrix to test.

Returns:
Boolean -

The result of the equality test.

extractBasis(xAxis, yAxis, zAxis) → {Matrix3}

Extracts the basis vectors and stores them to the given vectors.

Parameters:
Name Type Description
xAxis Vector3

The first result vector for the x-axis.

yAxis Vector3

The second result vector for the y-axis.

zAxis Vector3

The third result vector for the z-axis.

Returns:
Matrix3 -

A reference to this matrix.

frobeniusNorm() → {Number}

Computes the frobenius norm. It's the squareroot of the sum of all squared matrix elements.

Returns:
Number -

The frobenius norm.

fromArray(array, offset) → {Matrix3}

Sets the elements of this matrix from an array.

Parameters:
Name Type Default Description
array Array.<Number>

An array.

offset Number 0

An optional offset.

Returns:
Matrix3 -

A reference to this matrix.

fromMatrix4(m) → {Matrix3}

Sets the elements of this matrix by extracting the upper-left 3x3 portion from a 4x4 matrix.

Parameters:
Name Type Description
m Matrix4

A 4x4 matrix.

Returns:
Matrix3 -

A reference to this matrix.

fromQuaternion(q) → {Matrix3}

Creates a rotation matrix from the given quaternion.

Parameters:
Name Type Description
q Quaternion

A quaternion representing a rotation.

Returns:
Matrix3 -

A reference to this matrix.

getElementIndex(column, row) → {Number}

Computes the element index according to the given column and row.

Parameters:
Name Type Description
column Number

Index of the column.

row Number

Index of the row.

Returns:
Number -

The index of the element at the provided row and column.

identity() → {Matrix3}

Transforms this matrix to an identity matrix.

Returns:
Matrix3 -

A reference to this matrix.

lookAt(localForward, targetDirection, localUp) → {Matrix3}

Creates a rotation matrix that orients an object to face towards a specified target direction.

Parameters:
Name Type Description
localForward Vector3

Specifies the forward direction in the local space of the object.

targetDirection Vector3

Specifies the desired world space direction the object should look at.

localUp Vector3

Specifies the up direction in the local space of the object.

Returns:
Matrix3 -

A reference to this matrix.

makeBasis(xAxis, yAxis, zAxis) → {Matrix3}

Makes a basis from the given vectors.

Parameters:
Name Type Description
xAxis Vector3

The first basis vector for the x-axis.

yAxis Vector3

The second basis vector for the y-axis.

zAxis Vector3

The third basis vector for the z-axis.

Returns:
Matrix3 -

A reference to this matrix.

multiply(m) → {Matrix3}

Multiplies this matrix with the given matrix.

Parameters:
Name Type Description
m Matrix3

The matrix to multiply.

Returns:
Matrix3 -

A reference to this matrix.

multiplyMatrices(a, b) → {Matrix3}

Multiplies two given matrices and stores the result in this matrix.

Parameters:
Name Type Description
a Matrix3

The first matrix of the operation.

b Matrix3

The second matrix of the operation.

Returns:
Matrix3 -

A reference to this matrix.

multiplyScalar(s) → {Matrix3}

Multiplies the given scalar with this matrix.

Parameters:
Name Type Description
s Number

The scalar to multiply.

Returns:
Matrix3 -

A reference to this matrix.

offDiagonalFrobeniusNorm() → {Number}

Computes the "off-diagonal" frobenius norm. Assumes the matrix is symmetric.

Returns:
Number -

The "off-diagonal" frobenius norm.

premultiply(m) → {Matrix3}

Multiplies this matrix with the given matrix. So the order of the multiplication is switched compared to Matrix3#multiply.

Parameters:
Name Type Description
m Matrix3

The matrix to multiply.

Returns:
Matrix3 -

A reference to this matrix.

set(n11, n12, n13, n21, n22, n23, n31, n32, n33) → {Matrix3}

Sets the given values to this matrix. The arguments are in row-major order.

Parameters:
Name Type Description
n11 Number

An element of the matrix.

n12 Number

An element of the matrix.

n13 Number

An element of the matrix.

n21 Number

An element of the matrix.

n22 Number

An element of the matrix.

n23 Number

An element of the matrix.

n31 Number

An element of the matrix.

n32 Number

An element of the matrix.

n33 Number

An element of the matrix.

Returns:
Matrix3 -

A reference to this matrix.

shurDecomposition(result) → {Matrix3}

Finds the largest off-diagonal term and then creates a matrix which can be used to help reduce it.

Parameters:
Name Type Description
result Matrix3

The result matrix.

Returns:
Matrix3 -

The result matrix.

toArray(array, offset) → {Array.<Number>}

Copies all elements of this matrix to the given array.

Parameters:
Name Type Default Description
array Array.<Number>

An array.

offset Number 0

An optional offset.

Returns:
Array.<Number> -

The array with the elements of the matrix.

transpose() → {Matrix3}

Transposes this matrix.

Returns:
Matrix3 -

A reference to this matrix.