4x4 Matrix
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied.
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied.
Methods
-
inneradd$3(out, a, b) → mat4
-
Adds two mat4's
Name Type Description outmat4 the receiving matrix amat4 the first operand bmat4 the second operand Returns:
out -
inneradjoint$2(out, a) → mat4
-
Calculates the adjugate of a mat4
Name Type Description outmat4 the receiving matrix amat4 the source matrix Returns:
out -
innerclone$3(a) → mat4
-
Creates a new mat4 initialized with values from an existing matrix
Name Type Description amat4 matrix to clone Returns:
a new 4x4 matrix -
innercopy$3(out, a) → mat4
-
Copy the values from one mat4 to another
Name Type Description outmat4 the receiving matrix amat4 the source matrix Returns:
out -
innercreate$3() → mat4
-
Creates a new identity mat4
Returns:
a new 4x4 matrix -
Calculates the determinant of a mat4
Name Type Description amat4 the source matrix Returns:
determinant of a -
Returns whether or not the matrices have approximately the same elements in the same position.
Name Type Description amat4 The first matrix. bmat4 The second matrix. Returns:
True if the matrices are equal, false otherwise. -
Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
Name Type Description amat4 The first matrix. bmat4 The second matrix. Returns:
True if the matrices are equal, false otherwise. -
Returns Frobenius norm of a mat4
Name Type Description amat4 the matrix to calculate Frobenius norm of Returns:
Frobenius norm -
innerfromQuat2(out, a) → mat4
-
Creates a new mat4 from a dual quat.
Name Type Description outmat4 Matrix aquat2 Dual Quaternion Returns:
mat4 receiving operation result -
innerfromQuat$1(out, q) → mat4
-
Calculates a 4x4 matrix from the given quaternion
Name Type Description outmat4 mat4 receiving operation result qquat Quaternion to create matrix from Returns:
out -
innerfromRotation$3(out, rad, axis) → mat4
-
Creates a matrix from a given angle around a given axis This is equivalent to (but much faster than): mat4.identity(dest); mat4.rotate(dest, dest, rad, axis);
Name Type Description outmat4 mat4 receiving operation result radNumber the angle to rotate the matrix by axisvec3 the axis to rotate around Returns:
out -
innerfromRotationTranslation(out, q, v) → mat4
-
Creates a matrix from a quaternion rotation and vector translation This is equivalent to (but much faster than): mat4.identity(dest); mat4.translate(dest, vec); let quatMat = mat4.create(); quat4.toMat4(quat, quatMat); mat4.multiply(dest, quatMat);
Name Type Description outmat4 mat4 receiving operation result qquat4 Rotation quaternion vvec3 Translation vector Returns:
out -
innerfromRotationTranslationScale(out, q, v, s) → mat4
-
Creates a matrix from a quaternion rotation, vector translation and vector scale This is equivalent to (but much faster than): mat4.identity(dest); mat4.translate(dest, vec); let quatMat = mat4.create(); quat4.toMat4(quat, quatMat); mat4.multiply(dest, quatMat); mat4.scale(dest, scale)
Name Type Description outmat4 mat4 receiving operation result qquat4 Rotation quaternion vvec3 Translation vector svec3 Scaling vector Returns:
out -
innerfromRotationTranslationScaleOrigin(out, q, v, s, o) → mat4
-
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): mat4.identity(dest); mat4.translate(dest, vec); mat4.translate(dest, origin); let quatMat = mat4.create(); quat4.toMat4(quat, quatMat); mat4.multiply(dest, quatMat); mat4.scale(dest, scale) mat4.translate(dest, negativeOrigin);
Name Type Description outmat4 mat4 receiving operation result qquat4 Rotation quaternion vvec3 Translation vector svec3 Scaling vector ovec3 The origin vector around which to scale and rotate Returns:
out -
innerfromScaling$3(out, v) → mat4
-
Creates a matrix from a vector scaling This is equivalent to (but much faster than): mat4.identity(dest); mat4.scale(dest, dest, vec);
Name Type Description outmat4 mat4 receiving operation result vvec3 Scaling vector Returns:
out -
innerfromTranslation$2(out, v) → mat4
-
Creates a matrix from a vector translation This is equivalent to (but much faster than): mat4.identity(dest); mat4.translate(dest, dest, vec);
Name Type Description outmat4 mat4 receiving operation result vvec3 Translation vector Returns:
out -
innerfromValues$3(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) → mat4
-
Create a new mat4 with the given values
Name Type Description m00Number Component in column 0, row 0 position (index 0) m01Number Component in column 0, row 1 position (index 1) m02Number Component in column 0, row 2 position (index 2) m03Number Component in column 0, row 3 position (index 3) m10Number Component in column 1, row 0 position (index 4) m11Number Component in column 1, row 1 position (index 5) m12Number Component in column 1, row 2 position (index 6) m13Number Component in column 1, row 3 position (index 7) m20Number Component in column 2, row 0 position (index 8) m21Number Component in column 2, row 1 position (index 9) m22Number Component in column 2, row 2 position (index 10) m23Number Component in column 2, row 3 position (index 11) m30Number Component in column 3, row 0 position (index 12) m31Number Component in column 3, row 1 position (index 13) m32Number Component in column 3, row 2 position (index 14) m33Number Component in column 3, row 3 position (index 15) Returns:
A new mat4 -
innerfromXRotation(out, rad) → mat4
-
Creates a matrix from the given angle around the X axis This is equivalent to (but much faster than): mat4.identity(dest); mat4.rotateX(dest, dest, rad);
Name Type Description outmat4 mat4 receiving operation result radNumber the angle to rotate the matrix by Returns:
out -
innerfromYRotation(out, rad) → mat4
-
Creates a matrix from the given angle around the Y axis This is equivalent to (but much faster than): mat4.identity(dest); mat4.rotateY(dest, dest, rad);
Name Type Description outmat4 mat4 receiving operation result radNumber the angle to rotate the matrix by Returns:
out -
innerfromZRotation(out, rad) → mat4
-
Creates a matrix from the given angle around the Z axis This is equivalent to (but much faster than): mat4.identity(dest); mat4.rotateZ(dest, dest, rad);
Name Type Description outmat4 mat4 receiving operation result radNumber the angle to rotate the matrix by Returns:
out -
innerfrustum(out, left, right, bottom, top, near, far) → mat4
-
Generates a frustum matrix with the given bounds
Name Type Description outmat4 mat4 frustum matrix will be written into leftNumber Left bound of the frustum rightNumber Right bound of the frustum bottomNumber Bottom bound of the frustum topNumber Top bound of the frustum nearNumber Near bound of the frustum farNumber Far bound of the frustum Returns:
out -
innergetRotation(out, mat) → quat
-
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.
Name Type Description outquat Quaternion to receive the rotation component matmat4 Matrix to be decomposed (input) Returns:
out -
innergetScaling(out, mat) → vec3
-
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.
Name Type Description outvec3 Vector to receive scaling factor component matmat4 Matrix to be decomposed (input) Returns:
out -
innergetTranslation(out, mat) → vec3
-
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.
Name Type Description outvec3 Vector to receive translation component matmat4 Matrix to be decomposed (input) Returns:
out -
inneridentity$3(out) → mat4
-
Set a mat4 to the identity matrix
Name Type Description outmat4 the receiving matrix Returns:
out -
innerinvert$3(out, a) → mat4
-
Inverts a mat4
Name Type Description outmat4 the receiving matrix amat4 the source matrix Returns:
out -
innerlookAt(out, eye, center, up) → mat4
-
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.
Name Type Description outmat4 mat4 frustum matrix will be written into eyevec3 Position of the viewer centervec3 Point the viewer is looking at upvec3 vec3 pointing up Returns:
out -
Alias for
mat4.multiply -
innermultiply$3(out, a, b) → mat4
-
Multiplies two mat4s
Name Type Description outmat4 the receiving matrix amat4 the first operand bmat4 the second operand Returns:
out -
innermultiplyScalar$3(out, a, b) → mat4
-
Multiply each element of the matrix by a scalar.
Name Type Description outmat4 the receiving matrix amat4 the matrix to scale bNumber amount to scale the matrix's elements by Returns:
out -
innermultiplyScalarAndAdd$3(out, a, b, scale) → mat4
-
Adds two mat4's after multiplying each element of the second operand by a scalar value.
Name Type Description outmat4 the receiving vector amat4 the first operand bmat4 the second operand scaleNumber the amount to scale b's elements by before adding Returns:
out -
innerortho(out, left, right, bottom, top, near, far) → mat4
-
Generates a orthogonal projection matrix with the given bounds
Name Type Description outmat4 mat4 frustum matrix will be written into leftnumber Left bound of the frustum rightnumber Right bound of the frustum bottomnumber Bottom bound of the frustum topnumber Top bound of the frustum nearnumber Near bound of the frustum farnumber Far bound of the frustum Returns:
out -
innerperspective(out, fovy, aspect, near, far) → mat4
-
Generates a perspective projection matrix with the given bounds. Passing null/undefined/no value for far will generate infinite projection matrix.
Name Type Description outmat4 mat4 frustum matrix will be written into fovynumber Vertical field of view in radians aspectnumber Aspect ratio. typically viewport width/height nearnumber Near bound of the frustum farnumber Far bound of the frustum, can be null or Infinity Returns:
out -
innerperspectiveFromFieldOfView(out, fov, near, far) → mat4
-
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.
Name Type Description outmat4 mat4 frustum matrix will be written into fovObject Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees nearnumber Near bound of the frustum farnumber Far bound of the frustum Returns:
out -
innerrotate$3(out, a, rad, axis) → mat4
-
Rotates a mat4 by the given angle around the given axis
Name Type Description outmat4 the receiving matrix amat4 the matrix to rotate radNumber the angle to rotate the matrix by axisvec3 the axis to rotate around Returns:
out -
innerrotateX(out, a, rad) → mat4
-
Rotates a matrix by the given angle around the X axis
Name Type Description outmat4 the receiving matrix amat4 the matrix to rotate radNumber the angle to rotate the matrix by Returns:
out -
innerrotateY(out, a, rad) → mat4
-
Rotates a matrix by the given angle around the Y axis
Name Type Description outmat4 the receiving matrix amat4 the matrix to rotate radNumber the angle to rotate the matrix by Returns:
out -
innerrotateZ(out, a, rad) → mat4
-
Rotates a matrix by the given angle around the Z axis
Name Type Description outmat4 the receiving matrix amat4 the matrix to rotate radNumber the angle to rotate the matrix by Returns:
out -
innerscale$3(out, a, v) → mat4
-
Scales the mat4 by the dimensions in the given vec3 not using vectorization
Name Type Description outmat4 the receiving matrix amat4 the matrix to scale vvec3 the vec3 to scale the matrix by Returns:
out -
innerset$3(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) → mat4
-
Set the components of a mat4 to the given values
Name Type Description outmat4 the receiving matrix m00Number Component in column 0, row 0 position (index 0) m01Number Component in column 0, row 1 position (index 1) m02Number Component in column 0, row 2 position (index 2) m03Number Component in column 0, row 3 position (index 3) m10Number Component in column 1, row 0 position (index 4) m11Number Component in column 1, row 1 position (index 5) m12Number Component in column 1, row 2 position (index 6) m13Number Component in column 1, row 3 position (index 7) m20Number Component in column 2, row 0 position (index 8) m21Number Component in column 2, row 1 position (index 9) m22Number Component in column 2, row 2 position (index 10) m23Number Component in column 2, row 3 position (index 11) m30Number Component in column 3, row 0 position (index 12) m31Number Component in column 3, row 1 position (index 13) m32Number Component in column 3, row 2 position (index 14) m33Number Component in column 3, row 3 position (index 15) Returns:
out -
Returns a string representation of a mat4
Name Type Description amat4 matrix to represent as a string Returns:
string representation of the matrix -
Alias for
mat4.subtract -
innersubtract$3(out, a, b) → mat4
-
Subtracts matrix b from matrix a
Name Type Description outmat4 the receiving matrix amat4 the first operand bmat4 the second operand Returns:
out -
innertargetTo(out, eye, center, up) → mat4
-
Generates a matrix that makes something look at something else.
Name Type Description outmat4 mat4 frustum matrix will be written into eyevec3 Position of the viewer centervec3 Point the viewer is looking at upvec3 vec3 pointing up Returns:
out -
innertranslate$2(out, a, v) → mat4
-
Translate a mat4 by the given vector
Name Type Description outmat4 the receiving matrix amat4 the matrix to translate vvec3 vector to translate by Returns:
out -
innertranspose$2(out, a) → mat4
-
Transpose the values of a mat4
Name Type Description outmat4 the receiving matrix amat4 the source matrix Returns:
out
