Mat4
- class cee.Mat4()
An immutable 4x4 matrix
Matrices are stored internally as a one dimensional array for performance reasons.
The mapping of matrix elements to indices of this internal array is as follows:
| m00 m01 m02 m03 | | 0 4 8 12 | | m10 m11 m12 m13 | | 1 5 9 13 | | m20 m21 m22 m23 | | 2 6 10 14 | | m30 m31 m32 m33 | | 3 7 11 15 |
This is consistent with the way matrices are represented in WebGL. To exemplify, translation values are stored in elements 12,13,14; see figure below
| 1 0 0 Tx | | 0 1 0 Ty | | 0 0 1 Tz | | 0 0 0 1 |
From the OpenGL red book (page 68) v’ = M*v
| X'| | 1 0 0 Tx | | X | | Y'| | 0 1 0 Ty | | Y | | Z'| = | 0 0 1 Tz | * | Z | | 1 | | 0 0 0 1 | | 1 |
Note that this class is immutable.
Constructors
Methods
Constructors
- Mat4.constructor()
Creates the matrix. Default is an identity matrix.
- Return type:
Mat4
Methods
equals
getAsArray
- Mat4.getAsArray()
Returns a reference to the internal array storing the matrix values.
The array will be ordered as follows:
| m00 m01 m02 m03 | | 0 4 8 12 | | m10 m11 m12 m13 | | 1 5 9 13 | | m20 m21 m22 m23 | | 2 6 10 14 | | m30 m31 m32 m33 | | 3 7 11 15 |
- Return type:
ArrayLike <number>
getInverse
- Mat4.getInverse()
Returns this inverse of this matrix.
If this matrix is not invertible, returns a zero matrix.
- Return type:
Mat4
getRowCol
- Mat4.getRowCol(row, col)
- Arguments:
row (
number
) – Nonecol (
number
) – None
Returns the value at the given row and column
- Return type:
number
isIdentity
- Mat4.isIdentity()
Returns true if the matrix is an identity matrix
- Return type:
boolean
static fromArray
- Mat4.fromArray(array)
- Arguments:
array (
ArrayLike
) – None
Returns a matrix initialized with the values in the passed array
The array must be ordered as follows:
| m00 m01 m02 m03 | | 0 4 8 12 | | m10 m11 m12 m13 | | 1 5 9 13 | | m20 m21 m22 m23 | | 2 6 10 14 | | m30 m31 m32 m33 | | 3 7 11 15 |
- Return type:
Mat4
static fromCoordSystemAxes
- Mat4.fromCoordSystemAxes(xAxis, yAxis, zAxis)
- Arguments:
Returns a rotation matrix that will align the global X, Y and Z axes with the specified axes.
Note that at least one axis must be specified and all specified axes must be normalized. If two or three axes are specified, they must be orthogonal to each other.
- Return type:
Mat4
static fromElements
- Mat4.fromElements(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)
- Arguments:
m00 (
number
) – Nonem01 (
number
) – Nonem02 (
number
) – Nonem03 (
number
) – Nonem10 (
number
) – Nonem11 (
number
) – Nonem12 (
number
) – Nonem13 (
number
) – Nonem20 (
number
) – Nonem21 (
number
) – Nonem22 (
number
) – Nonem23 (
number
) – Nonem30 (
number
) – Nonem31 (
number
) – Nonem32 (
number
) – Nonem33 (
number
) – None
Returns a transformation matrix containing the given element values
| m00 m01 m02 m03 | | m10 m11 m12 m13 | | m20 m21 m22 m23 | | m30 m31 m32 m33 |
- Return type:
Mat4
static fromRotation
static fromScaling
static fromTranslation
static multiply
- Mat4.multiply(matrices)
- Arguments:
matrices (
[Mat4]
) – None
Multiplies given matrices.
- Return type:
Mat4