Module: mat2

2x2 Matrix
Source:

Methods

(static) add(out, a, b) → {mat2}

Adds two mat2's
Parameters:
Name Type Description
out mat2 the receiving matrix
a ReadonlyMat2 the first operand
b ReadonlyMat2 the second operand
Source:
Returns:
out
Type
mat2

(static) adjoint(out, a) → {mat2}

Calculates the adjugate of a mat2
Parameters:
Name Type Description
out mat2 the receiving matrix
a ReadonlyMat2 the source matrix
Source:
Returns:
out
Type
mat2

(static) clone(a) → {mat2}

Creates a new mat2 initialized with values from an existing matrix
Parameters:
Name Type Description
a ReadonlyMat2 matrix to clone
Source:
Returns:
a new 2x2 matrix
Type
mat2

(static) copy(out, a) → {mat2}

Copy the values from one mat2 to another
Parameters:
Name Type Description
out mat2 the receiving matrix
a ReadonlyMat2 the source matrix
Source:
Returns:
out
Type
mat2

(static) create() → {mat2}

Creates a new identity mat2
Source:
Returns:
a new 2x2 matrix
Type
mat2

(static) determinant(a) → {Number}

Calculates the determinant of a mat2
Parameters:
Name Type Description
a ReadonlyMat2 the source matrix
Source:
Returns:
determinant of a
Type
Number

(static) equals(a, b) → {Boolean}

Returns whether or not the matrices have approximately the same elements in the same position.
Parameters:
Name Type Description
a ReadonlyMat2 The first matrix.
b ReadonlyMat2 The second matrix.
Source:
Returns:
True if the matrices are equal, false otherwise.
Type
Boolean

(static) exactEquals(a, b) → {Boolean}

Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Parameters:
Name Type Description
a ReadonlyMat2 The first matrix.
b ReadonlyMat2 The second matrix.
Source:
Returns:
True if the matrices are equal, false otherwise.
Type
Boolean

(static) frob(a) → {Number}

Returns Frobenius norm of a mat2
Parameters:
Name Type Description
a ReadonlyMat2 the matrix to calculate Frobenius norm of
Source:
Returns:
Frobenius norm
Type
Number

(static) fromRotation(out, rad) → {mat2}

Creates a matrix from a given angle This is equivalent to (but much faster than): mat2.identity(dest); mat2.rotate(dest, dest, rad);
Parameters:
Name Type Description
out mat2 mat2 receiving operation result
rad Number the angle to rotate the matrix by
Source:
Returns:
out
Type
mat2

(static) fromScaling(out, v) → {mat2}

Creates a matrix from a vector scaling This is equivalent to (but much faster than): mat2.identity(dest); mat2.scale(dest, dest, vec);
Parameters:
Name Type Description
out mat2 mat2 receiving operation result
v ReadonlyVec2 Scaling vector
Source:
Returns:
out
Type
mat2

(static) fromValues(m00, m01, m10, m11) → {mat2}

Create a new mat2 with the given values
Parameters:
Name Type Description
m00 Number Component in column 0, row 0 position (index 0)
m01 Number Component in column 0, row 1 position (index 1)
m10 Number Component in column 1, row 0 position (index 2)
m11 Number Component in column 1, row 1 position (index 3)
Source:
Returns:
out A new 2x2 matrix
Type
mat2

(static) identity(out) → {mat2}

Set a mat2 to the identity matrix
Parameters:
Name Type Description
out mat2 the receiving matrix
Source:
Returns:
out
Type
mat2

(static) invert(out, a) → {mat2}

Inverts a mat2
Parameters:
Name Type Description
out mat2 the receiving matrix
a ReadonlyMat2 the source matrix
Source:
Returns:
out
Type
mat2

(static) LDU(L, D, U, a)

Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix
Parameters:
Name Type Description
L ReadonlyMat2 the lower triangular matrix
D ReadonlyMat2 the diagonal matrix
U ReadonlyMat2 the upper triangular matrix
a ReadonlyMat2 the input matrix to factorize
Source:

(static) mul()

Alias for mat2.multiply
Source:

(static) multiply(out, a, b) → {mat2}

Multiplies two mat2's
Parameters:
Name Type Description
out mat2 the receiving matrix
a ReadonlyMat2 the first operand
b ReadonlyMat2 the second operand
Source:
Returns:
out
Type
mat2

(static) multiplyScalar(out, a, b) → {mat2}

Multiply each element of the matrix by a scalar.
Parameters:
Name Type Description
out mat2 the receiving matrix
a ReadonlyMat2 the matrix to scale
b Number amount to scale the matrix's elements by
Source:
Returns:
out
Type
mat2

(static) multiplyScalarAndAdd(out, a, b, scale) → {mat2}

Adds two mat2's after multiplying each element of the second operand by a scalar value.
Parameters:
Name Type Description
out mat2 the receiving vector
a ReadonlyMat2 the first operand
b ReadonlyMat2 the second operand
scale Number the amount to scale b's elements by before adding
Source:
Returns:
out
Type
mat2

(static) rotate(out, a, rad) → {mat2}

Rotates a mat2 by the given angle
Parameters:
Name Type Description
out mat2 the receiving matrix
a ReadonlyMat2 the matrix to rotate
rad Number the angle to rotate the matrix by
Source:
Returns:
out
Type
mat2

(static) scale(out, a, v) → {mat2}

Scales the mat2 by the dimensions in the given vec2
Parameters:
Name Type Description
out mat2 the receiving matrix
a ReadonlyMat2 the matrix to rotate
v ReadonlyVec2 the vec2 to scale the matrix by
Source:
Returns:
out
Type
mat2

(static) set(out, m00, m01, m10, m11) → {mat2}

Set the components of a mat2 to the given values
Parameters:
Name Type Description
out mat2 the receiving matrix
m00 Number Component in column 0, row 0 position (index 0)
m01 Number Component in column 0, row 1 position (index 1)
m10 Number Component in column 1, row 0 position (index 2)
m11 Number Component in column 1, row 1 position (index 3)
Source:
Returns:
out
Type
mat2

(static) str(a) → {String}

Returns a string representation of a mat2
Parameters:
Name Type Description
a ReadonlyMat2 matrix to represent as a string
Source:
Returns:
string representation of the matrix
Type
String

(static) sub()

Alias for mat2.subtract
Source:

(static) subtract(out, a, b) → {mat2}

Subtracts matrix b from matrix a
Parameters:
Name Type Description
out mat2 the receiving matrix
a ReadonlyMat2 the first operand
b ReadonlyMat2 the second operand
Source:
Returns:
out
Type
mat2

(static) transpose(out, a) → {mat2}

Transpose the values of a mat2
Parameters:
Name Type Description
out mat2 the receiving matrix
a ReadonlyMat2 the source matrix
Source:
Returns:
out
Type
mat2