# Namespace: mat2
# Table of contents
# Type aliases
# Functions
- LDU
- add
- adjoint
- clone
- copy
- create
- determinant
- equals
- exactEquals
- frob
- fromRotation
- fromScaling
- fromValues
- identity
- invert
- multiply
- multiplyScalar
- multiplyScalarAndAdd
- rotate
- scale
- set
- str
- subtract
- transpose
# Type aliases
# valueType
Ƭ valueType: mat2type
# Functions
# LDU
▸ LDU(L
: mat2type, D
: mat2type, U
: mat2type, a
: mat2type): mat2type[]
Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix
# Parameters
Name | Type | Description |
---|---|---|
L | mat2type | the lower triangular matrix |
D | mat2type | the diagonal matrix |
U | mat2type | the upper triangular matrix |
a | mat2type | the input matrix to factorize |
Returns: mat2type[]
# add
▸ add(out
: mat2type, a
: mat2type, b
: mat2type): mat2type
Adds two mat2's
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving matrix |
a | mat2type | the first operand |
b | mat2type | the second operand |
Returns: mat2type
out
# adjoint
▸ adjoint(out
: mat2type, a
: mat2type): mat2type
Calculates the adjugate of a mat2
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving matrix |
a | mat2type | the source matrix |
Returns: mat2type
out
# clone
▸ clone(a
: mat2type): Float32Array
Creates a new mat2 initialized with values from an existing matrix
# Parameters
Name | Type | Description |
---|---|---|
a | mat2type | matrix to clone |
Returns: Float32Array
a new 2x2 matrix
# copy
▸ copy(out
: mat2type, a
: mat2type): mat2type
Copy the values from one mat2 to another
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving matrix |
a | mat2type | the source matrix |
Returns: mat2type
out
# create
▸ create(): Float32Array
Creates a new identity mat2
Returns: Float32Array
a new 2x2 matrix
# determinant
▸ determinant(a
: mat2type): number
Calculates the determinant of a mat2
# Parameters
Name | Type | Description |
---|---|---|
a | mat2type | the source matrix |
Returns: number
determinant of a
# equals
▸ equals(a
: mat2type, b
: mat2type): boolean
Returns whether or not the matrices have approximately the same elements in the same position.
# Parameters
Name | Type | Description |
---|---|---|
a | mat2type | The first matrix. |
b | mat2type | The second matrix. |
Returns: boolean
True if the matrices are equal, false otherwise.
# exactEquals
▸ exactEquals(a
: mat2type, b
: mat2type): boolean
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
# Parameters
Name | Type | Description |
---|---|---|
a | mat2type | The first matrix. |
b | mat2type | The second matrix. |
Returns: boolean
True if the matrices are equal, false otherwise.
# frob
▸ frob(a
: mat2type): number
Returns Frobenius norm of a mat2
# Parameters
Name | Type | Description |
---|---|---|
a | mat2type | the matrix to calculate Frobenius norm of |
Returns: number
Frobenius norm
# fromRotation
▸ fromRotation(out
: mat2type, rad
: number): mat2type
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 | mat2type | mat2 receiving operation result |
rad | number | the angle to rotate the matrix by |
Returns: mat2type
out
# fromScaling
▸ fromScaling(out
: mat2type, v
: mat2type): mat2type
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 | mat2type | mat2 receiving operation result |
v | mat2type | Scaling vector |
Returns: mat2type
out
# fromValues
▸ fromValues(m00
: number, m01
: number, m10
: number, m11
: number): mat2type
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) |
Returns: mat2type
out A new 2x2 matrix
# identity
▸ identity(out
: mat2type): mat2type
Set a mat2 to the identity matrix
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving matrix |
Returns: mat2type
out
# invert
▸ invert(out
: mat2type, a
: mat2type): mat2type | null
Inverts a mat2
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving matrix |
a | mat2type | the source matrix |
Returns: mat2type | null
out
# multiply
▸ multiply(out
: mat2type, a
: mat2type, b
: mat2type): mat2type
Multiplies two mat2's
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving matrix |
a | mat2type | the first operand |
b | mat2type | the second operand |
Returns: mat2type
out
# multiplyScalar
▸ multiplyScalar(out
: mat2type, a
: mat2type, b
: number): mat2type
Multiply each element of the matrix by a scalar.
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving matrix |
a | mat2type | the matrix to scale |
b | number | amount to scale the matrix's elements by |
Returns: mat2type
out
# multiplyScalarAndAdd
▸ multiplyScalarAndAdd(out
: mat2type, a
: mat2type, b
: mat2type, scale
: number): mat2type
Adds two mat2's after multiplying each element of the second operand by a scalar value.
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving vector |
a | mat2type | the first operand |
b | mat2type | the second operand |
scale | number | the amount to scale b's elements by before adding |
Returns: mat2type
out
# rotate
▸ rotate(out
: mat2type, a
: mat2type, rad
: number): mat2type
Rotates a mat2 by the given angle
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving matrix |
a | mat2type | the matrix to rotate |
rad | number | the angle to rotate the matrix by |
Returns: mat2type
out
# scale
▸ scale(out
: mat2type, a
: mat2type, v
: mat2type): mat2type
Scales the mat2 by the dimensions in the given vec2
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving matrix |
a | mat2type | the matrix to rotate |
v | mat2type | the vec2 to scale the matrix by |
Returns: mat2type
out
# set
▸ set(out
: mat2type, m00
: number, m01
: number, m10
: number, m11
: number): mat2type
Set the components of a mat2 to the given values
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | 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) |
Returns: mat2type
out
# str
▸ str(a
: mat2type): string
Returns a string representation of a mat2
# Parameters
Name | Type | Description |
---|---|---|
a | mat2type | matrix to represent as a string |
Returns: string
string representation of the matrix
# subtract
▸ subtract(out
: mat2type, a
: mat2type, b
: mat2type): mat2type
Subtracts matrix b from matrix a
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving matrix |
a | mat2type | the first operand |
b | mat2type | the second operand |
Returns: mat2type
out
# transpose
▸ transpose(out
: mat2type, a
: mat2type): mat2type
Transpose the values of a mat2
# Parameters
Name | Type | Description |
---|---|---|
out | mat2type | the receiving matrix |
a | mat2type | the source matrix |
Returns: mat2type
out