# mat4 library Null safety

## Constants

mul → const List<double> Function( out, a, b)
`multiply`
ortho → const List<double> Function( out, double left, double right, double bottom, double top, double near, double far)
`orthoNO`
perspective → const List<double> Function( out, double fovy, double aspect, double near, far)
`perspectiveNO`
sub → const List<double> Function( out, a, dynamic b)
`subtract`

## Functions

Calculates the adjugate of a mat4
clone( a) List<double>
Creates a new mat4 initialized with values from an existing matrix
copy( out, a) List<double>
Copy the values from one mat4 to another
create() → dynamic
Creates a new identity mat4
decompose( outR, outT, outS, mat) List<double>
Decomposes a transformation matrix into its rotation, translation and scale components. Returns only the rotation component @param {quat} out_r Quaternion to receive the rotation component @param {vec3} out_t Vector to receive the translation vector @param {vec3} out_s Vector to receive the scaling factor @param {ReadonlyMat4} mat Matrix to be decomposed (input) @returns {quat} out_r
determinant( a)
Calculates the determinant of a mat4
equals( a, b) bool
Returns whether or not the matrices have approximately the same elements in the same position.
exactEquals( a, b) bool
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
frob( a)
Returns Frobenius norm of a mat4
fromQuat( out, q) List<double>
Calculates a 4x4 matrix from the given quaternion
fromQuat2( out, a) List<double>
Creates a new mat4 from a dual quat.
fromRotation( out, double rad, axis) List<double>?
Creates a matrix from a given angle around a given axis This is equivalent to (but much faster than):
fromRotationTranslation( out, q, v) List<double>
Creates a matrix from a quaternion rotation and vector translation This is equivalent to (but much faster than):
fromRotationTranslationScale( out, q, v, s) List<double>
Creates a matrix from a quaternion rotation, vector translation and vector scale This is equivalent to (but much faster than):
fromRotationTranslationScaleOrigin( out, q, v, s, o) List<double>
Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin This is equivalent to (but much faster than):
fromScaling( out, v) List<double>
Creates a matrix from a vector scaling This is equivalent to (but much faster than):
fromTranslation( out, v) List<double>
Creates a matrix from a vector translation This is equivalent to (but much faster than):
fromValues(double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33) List<double>
Create a new mat4 with the given values
Creates a matrix from the given angle around the X axis This is equivalent to (but much faster than):
Creates a matrix from the given angle around the Y axis This is equivalent to (but much faster than):
Creates a matrix from the given angle around the Z axis This is equivalent to (but much faster than):
frustum( out, double left, double right, double bottom, double top, double near, double far) List<double>
Generates a frustum matrix with the given bounds
getRotation( out, mat) List<double>
Returns a quaternion representing the rotational component of a transformation matrix. If a matrix is built with fromRotationTranslation, the returned quaternion will be the same as the quaternion originally supplied. @param {quat} out Quaternion to receive the rotation component @param {ReadonlyMat4} mat Matrix to be decomposed (input) @return {quat} out
getScaling( out, mat) List<double>
Returns the scaling factor component of a transformation matrix. If a matrix is built with fromRotationTranslationScale with a normalized Quaternion paramter, the returned vector will be the same as the scaling vector originally supplied. @param {vec3} out Vector to receive scaling factor component @param {ReadonlyMat4} mat Matrix to be decomposed (input) @return {vec3} out
getTranslation( out, mat) List<double>
Returns the translation vector component of a transformation matrix. If a matrix is built with fromRotationTranslation, the returned vector will be the same as the translation vector originally supplied. @param {vec3} out Vector to receive translation component @param {ReadonlyMat4} mat Matrix to be decomposed (input) @return {vec3} out
identity( out) List<double>
Set a mat4 to the identity matrix
invert( out, a) List<double>?
Inverts a mat4
lookAt( out, eye, center, up) List<double>
Generates a look-at matrix with the given eye position, focal point, and up axis. If you want a matrix that actually makes an object look at another object, you should use targetTo instead.
multiply( out, a, b) List<double>
Multiplies two mat4s
multiplyScalar( out, a, dynamic b) List<double>
Multiply each element of the matrix by a scalar.
multiplyScalarAndAdd( out, a, dynamic b, dynamic scale) List<double>
Adds two mat4's after multiplying each element of the second operand by a scalar value.
orthoNO( out, double left, double right, double bottom, double top, double near, double far) List<double>
Generates a orthogonal projection matrix with the given bounds. The near/far clip planes correspond to a normalized device coordinate Z range of `-1, 1`, which matches WebGL/OpenGL's clip volume.
orthoZO( out, double left, double right, double bottom, double top, double near, double far) List<double>
Generates a orthogonal projection matrix with the given bounds. The near/far clip planes correspond to a normalized device coordinate Z range of `0, 1`, which matches WebGPU/Vulkan/DirectX/Metal's clip volume.
perspectiveFromFieldOfView( out, dynamic fov, dynamic near, dynamic far) List<double>
Generates a perspective projection matrix with the given field of view. This is primarily useful for generating projection matrices to be used with the still experiemental WebVR API.
perspectiveNO( out, double fovy, double aspect, double near, far) List<double>
Generates a perspective projection matrix with the given bounds. The near/far clip planes correspond to a normalized device coordinate Z range of `-1, 1`, which matches WebGL/OpenGL's clip volume. Passing null/undefined/no value for far will generate infinite projection matrix.
perspectiveZO( out, double fovy, double aspect, double near, far) List<double>
Generates a perspective projection matrix suitable for WebGPU with the given bounds. The near/far clip planes correspond to a normalized device coordinate Z range of `0, 1`, which matches WebGPU/Vulkan/DirectX/Metal's clip volume. Passing null/undefined/no value for far will generate infinite projection matrix.
rotate( out, a, double rad, dynamic axis) List<double>?
Rotates a mat4 by the given angle around the given axis
rotateX( out, a, double rad) List<double>
Rotates a matrix by the given angle around the X axis
rotateY( out, a, double rad) List<double>
Rotates a matrix by the given angle around the Y axis
rotateZ( out, a, double rad) List<double>
Rotates a matrix by the given angle around the Z axis
scale( out, a, dynamic v) List<double>
Scales the mat4 by the dimensions in the given vec3 not using vectorization
set( out, double m00, double m01, double m02, double m03, double m10, double m11, double m12, double m13, double m20, double m21, double m22, double m23, double m30, double m31, double m32, double m33) List<double>
Set the components of a mat4 to the given values
str( a)
Returns a string representation of a mat4
subtract( out, a, dynamic b) List<double>
Subtracts matrix b from matrix a
targetTo( out, eye, target, up) List<double>
Generates a matrix that makes something look at something else.
translate( out, a, dynamic v) List<double>
Translate a mat4 by the given vector
transpose( out, a) List<double>
Transpose the values of a mat4