Array of 16 numbers representing the elements in the Matrix4
Static
Readonly
IDENTITYStatic field to provide quick access to the identity matrix. (Note: Be careful not to change the value of this field! It is marked readonly, but typescipt do not completely enforce this!)
// Good use of IDENTITY:
const M = gfx.Matrix4();
if (M.equals(gfx.Matrix4.IDENTITY)) {
console.log("We have an identity matrix.")
}
// Dangerous use of IDENTITY!!!!
const M = gfx.Matrix4.IDENTITY; // makes M a reference to gfx.Matrix4.IDENTITY
M.set(3.0, 3, 3); // changes the underlying matrix in gfx.Matrix4.IDENTITY!
// Do this instead:
const M = gfx.Matrix4.makeIdentity(); // create a new identity matrix M
M.set(3.0, 3, 3);
Sets the matrix to a composition of three basic transformations (this = T * R * S), where scale is applied first, then rotation, then translation.
The position of the Matrix4 object (default Vector3.ZERO)
The rotation of the Matrix4 object (default Quaternion.IDENTITY)
The scale of the Matrix4 object (default Vector3.ONE)
Decomposes the 4x4 transformation matrix into separate translation, rotation, and scale components such that the original matrix can be represented as a combination of transformations in the form T * R * S. The decomposition is straightforward (relatively efficient) if the matrix does not include a negative scale. If the matrix includes a negative scale factor, a slower polar decomposition must be used, and the caller must explicitly set the containsNegScale to true.
An array of three elements [translation: Vector3, rotation: Quaternion, scale: Vector3]
Set to true if the matrix includes a negative scale factor.
Checks if every element of this Matrix4 is exactly equal (within a small value of epsilon) to every element of the given Matrix4
A boolean value indicating if the two matrices are equal
The other Matrix3 to compare to
A small value of acceptable variance to account for numerical instability
Gets the rotation quaternion of this Matrix4 object
The Quaternion representing the rotation
Sets the Matrix to a view matrix of a camera. The matrix will position the camera at eyePoint and orient it to look directly toward the targetPoint so that the camera's look vector will be (targetPoint - eyePoint). The camera's rotation around the look vector is controlled by the upVector, which only needs to point roughly in the Up direction, i.e., it does not need to be completely perpendicular to the look vector.
A new Matrix4 object for the view matrix of a camera
this.mat = this.mat * M1 * M2 * ... * M(n-1): Multiplies this matrix with one or more additional
4x4 matrices.
(Remember, matrix multiplication is not commutitive; so, the order of the matrices is important! The order that transformations are applied to points and vectors is right-to-left. To transform point p into p', as in the equation below, think of M(n-1) as being the first transformation to be applied to p and the current value of this.mat as being the last transformation to be applied in order to produce p'.)
p' = this.mat * M1 * M2 * ... * M(n-1) * p
Set the values of the Matrix4 in column-major order
Column 1, Row 1 value
Column 1, Row 2 value
Column 1, Row 3 value
Column 1, Row 4 value
Column 2, Row 1 value
Column 2, Row 2 value
Column 2, Row 3 value
Column 2, Row 4 value
Column 3, Row 1 value
Column 3, Row 2 value
Column 3, Row 3 value
Column 3, Row 4 value
Column 4, Row 1 value
Column 4, Row 2 value
Column 4, Row 3 value
Column 4, Row 4 value
Sets the matrix to a rotation matrix defined by Euler angles.
The x-axis euler angle
The y-axis euler angle
The z-axis euler angle
The order in which the euler angles should be applied
Sets a frustum projection matrix on this Matrix4 object
The leftmost coordinate
The rightmost coordinate
The bottom coordinate
The top coordinate
The near coordinate
The far coordinate
Sets an orthographic projection matrix on this Matrix4 object
The leftmost coordinate
The rightmost coordinate
The bottom coordinate
The top coordinate
The near coordinate
The far coordinate
Sets a perspective projection matrix on this Matrix4 object
The field of view angle
The aspect ratio of the view
The near coordinate
The far coordinate
Sets this Matrix4 to a rotation matrix given a Quaternion.
The Quaternion to construct the rotation matrix with.
Set the values of the Matrix4 in row-major order
Column 1, Row 1 value
Column 1, Row 2 value
Column 1, Row 3 value
Column 1, Row 4 value
Column 2, Row 1 value
Column 2, Row 2 value
Column 2, Row 3 value
Column 2, Row 4 value
Column 3, Row 1 value
Column 3, Row 2 value
Column 3, Row 3 value
Column 3, Row 4 value
Column 4, Row 1 value
Column 4, Row 2 value
Column 4, Row 3 value
Column 4, Row 4 value
Multiplies point p by this 4x4 transformation matrix and returns the result as a new point. This has the effect of transforming p from the matrix's local coordinate system to its parent coordinate system. The multiplication is done using homogeneous coordinates (p is treated as having a w=1 coordinate).
A new point transformed by m
The original point
Multiplies vector v by this 4x4 transformation matrix and returns the result as a new vector. This has the effect of transforming v from the matrix's local coordinate system to its parent coordinate system. The multiplication is done using homogeneous coordinates (v is treated as having a w=0 coordinate).
A new vector transformed by m
The original vector
Static
composeCreates a new Matrix4 object representing the combined transform of position, rotation and scale
A new Matrix4 object representing the combined transform of position, rotation and scale
The Vector3 object representing the position
The Quaternion object representing the rotation
The Vector3 object representing the scale
Static
copyStatic
equalsStatic
fromCreates a new Matrix4 object from the given values in column-major order
A new Matrix4 object created from the given values
Element [0,0] in the matrix
Element [1,0] in the matrix
Element [2,0] in the matrix
Element [3,0] in the matrix
Element [0,1] in the matrix
Element [1,1] in the matrix
Element [2,1] in the matrix
Element [3,1] in the matrix
Element [0,2] in the matrix
Element [1,2] in the matrix
Element [2,2] in the matrix
Element [3,2] in the matrix
Element [0,3] in the matrix
Element [1,3] in the matrix
Element [2,3] in the matrix
Element [3,3] in the matrix
Static
fromCreates a new Matrix4 object from the given values in row-major order
A new Matrix4 object created from the given values
Element [0,0] in the matrix
Element [0,1] in the matrix
Element [0,2] in the matrix
Element [0,3] in the matrix
Element [1,0] in the matrix
Element [1,1] in the matrix
Element [1,2] in the matrix
Element [1,3] in the matrix
Element [2,0] in the matrix
Element [2,1] in the matrix
Element [2,2] in the matrix
Element [2,3] in the matrix
Element [3,0] in the matrix
Element [3,1] in the matrix
Element [3,2] in the matrix
Element [3,3] in the matrix
Static
fuzzyStatic
lookCreates a new Matrix4 object for the view matrix of a camera. The matrix will position the camera at eyePoint and orient it to look directly toward the targetPoint so that the camera's look vector will be (targetPoint - eyePoint). The camera's rotation around the look vector is controlled by the upVector, which only needs to point roughly in the Up direction, i.e., it does not need to be completely perpendicular to the look vector.
A new Matrix4 object for the view matrix of a camera
Static
makeCreates a rotation matrix that will align a reference direction to some new direction. This is similar to a lookAt function but more flexible in that the reference direction does not need to be -Z. The routine can optionally include a second reference direction and new direction. This is interpreted similarly to the Up parameter in a typical lookAt function. (The rotation matrix will always align referenceDir with newDir and it will try to get referenceDir2 to align as closely as possible with newDir2.)
Static
makeCreates a new Matrix4 object for rotation around an arbitrary axis
A new Matrix4 object for rotation around an arbitrary axis
The Vector3 object representing the axis of rotation
The angle of rotation around the axis
Static
makeCreates a matrix that represents a right-handed X,Y,Z coordinate frame (an orthonormal basis) where: 1. the vector provided by the reference direction is aligned with the X axis, and optionally 2. the vector provided by a second reference direction is aligned as closely as possible (subject to the requirements of a right-handed, orthonormal basis) with the Y axis. This means the first column of the matrix will contain the normalized x, y, z values of the reference direction and the second and third columns can be interpreted as the directions of the Y and Z axes of the basis.
A 4x4 transformation matrix.
Static
makeCreates a new Matrix4 object for rotation using Euler angles
A new Matrix4 object for rotation using Euler angles
The angle of rotation around the x axis
The angle of rotation around the y axis
The angle of rotation around the z axis
The order of the rotations (default is 'YZX')
Static
makeCreate a frustum projection Matrix4
A Matrix4 representing a frustum projection
Left coordinate of the viewing volume
Right coordinate of the viewing volume
Bottom coordinate of the viewing volume
Top coordinate of the viewing volume
Near clipping plane of the viewing volume
Far clipping plane of the viewing volume
Static
makeStatic
makeCreate an orthographic projection Matrix4
A Matrix4 representing an orthographic projection
Left coordinate of the viewing volume
Right coordinate of the viewing volume
Bottom coordinate of the viewing volume
Top coordinate of the viewing volume
Near clipping plane of the viewing volume
Far clipping plane of the viewing volume
Static
makeCreate a perspective projection Matrix4
A Matrix4 representing a perspective projection
Field of view of the projection in radians
Aspect ratio of the viewport (width / height)
Near clipping plane of the viewing volume
Far clipping plane of the viewing volume
Static
makeCreates a new Matrix4 object for rotation
A new Matrix4 object for rotation
The Quaternion object representing the rotation vector
Static
makeStatic
makeStatic
makeStatic
makeStatic
makeStatic
multiplyStatic
multiplyMn = M1 * M2 * M3 * ... * M(n-1): Composes (i.e., multiplies) two or more 4x4 matrices together and returns the result in a new matrix.
(Remember, matrix multiplication is not commutitive; so, the order of the matrices is important! The order that transformations are applied to points and vectors is right-to-left. To transform point p into p', as in the equation below, think of M(n-1) as being the first transformation to be applied to p and M1 as being the last transformation to be applied in order to produce p'.)
p' = M1 * M2 * M3 * ... * M(n-1) * p
A new Matrix4 object = m1 * m2 * ...
Static
transformMultiplies point p by a 4x4 transformation matrix and returns the result as a new point. This has the effect of transforming p from m's local coordinate system to m's parent coordinate system. The multiplication is done using homogeneous coordinates (p is treated as having a w=1 coordinate).
A new point transformed by m
Static
transformMultiplies vector v by a 4x4 transformation matrix and returns the result as a new vector. This has the effect of transforming v from m's local coordinate system to m's parent coordinate system. The multiplication is done using homogeneous coordinates (p is treated as having a w=0 coordinate).
A new vector transformed by m
Generated using TypeDoc
This class holds a 4x4 transformation matrix. It includes routines for using the matrix to transform points and vectors. It includes routines for constructing many common types of matrices (see make*), for inverting the matrix, and for accessing the underlying 16-elements by row, column.
Most of the functions in the class are defined both as member functions that can be called on a specific instance of Vector3 and as static functions. The static functions return a new result, leaving the original inputs unchanged, whereas, in general, member functions save the result in the matrix itself and return void: