Matrix2

Matrix2

Matrix with 2x2 components.

Constructor

new Matrix2()

var m1 = new Matrix2();
// m1 == (1, 0, 0, 1)
var m2 = new Matrix2(1, 2, 3, 4);
// m2 == (1, 2, 3, 4)
var m3 = new Matrix2([4, 3, 2, 1]);
// m3 == (4, 3, 2, 1)
var m4 = new Matrix2(m2);
// m4 == (1, 2, 3, 4)

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

Performs a component-wise addition.

Parameters:
Name Type Description
rhs Matrix2

Matrix or scalar on the right-hand side.

clone() → {Matrix2}

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

copy(rhs) → {Matrix2}

Copies component values from another matrix to this matrix

Parameters:
Name Type Description
rhs Matrix2

Source matrix

determinant() → {number}

Computes the determinant of the matrix.

equals(rhs) → {boolean}

Compares two matrices for approximate equality

Parameters:
Name Type Description
rhs Matrix2

The matrix to compare against

invert() → {Matrix2}

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(lhs) → {Matrix2}

Parameters:
Name Type Description
lhs Matrix2

Matrix on the lhs-hand side

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

mult(lhs, rhs) → {Matrix2}

Multiplies two matrices and stores the result in this matrix

Parameters:
Name Type Description
lhs Matrix2

Matrix on the left-hand side

rhs Matrix2

Matrix on the right-hand side

scale(scalar) → {Matrix2}

Multiplies this matrix with a scalar

Parameters:
Name Type Description
scalar number

setArray(rhsData) → {Matrix2}

Sets matrix values from an array.

Parameters:
Name Type Description
rhsData Array.<number>

Array source

setIdentity() → {Matrix2}

Sets the matrix to identity.

sub(rhs) → {Matrix2}

Performs a component-wise subtraction.

Parameters:
Name Type Description
rhs Matrix2

Matrix or scalar on the right-hand side.

transpose() → {Matrix2}

Transposes a matrix (exchanges rows and columns).

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

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

Parameters:
Name Type Attributes Description
source Matrix2

Source matrix.

target Matrix2 <optional>

Target matrix.