# Module: mat4

4x4 Matrix
Format: column-major, when typed out it looks like row-major
The matrices are being post multiplied.
Source:

### Methods

#### (static) add(out, a, b) → {mat4}

##### Parameters:
Name Type Description
out mat4 the receiving matrix
Source:
out
Type
mat4

#### (static) adjoint(out, a) → {mat4}

Calculates the adjugate of a mat4
##### Parameters:
Name Type Description
out mat4 the receiving matrix
Source:
out
Type
mat4

#### (static) clone(a) → {mat4}

Creates a new mat4 initialized with values from an existing matrix
##### Parameters:
Name Type Description
Source:
a new 4x4 matrix
Type
mat4

#### (static) copy(out, a) → {mat4}

Copy the values from one mat4 to another
##### Parameters:
Name Type Description
out mat4 the receiving matrix
Source:
out
Type
mat4

#### (static) create() → {mat4}

Creates a new identity mat4
Source:
a new 4x4 matrix
Type
mat4

#### (static) determinant(a) → {Number}

Calculates the determinant of a mat4
##### Parameters:
Name Type Description
Source:
determinant of a
Type
Number

#### (static) equals(a, b) → {Boolean}

Returns whether or not the matrices have approximately the same elements in the same position.
##### Parameters:
Name Type Description
Source:
##### Returns:
True if the matrices are equal, false otherwise.
Type
Boolean

#### (static) exactEquals(a, b) → {Boolean}

Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
##### Parameters:
Name Type Description
Source:
##### Returns:
True if the matrices are equal, false otherwise.
Type
Boolean

#### (static) frob(a) → {Number}

Returns Frobenius norm of a mat4
##### Parameters:
Name Type Description
a ReadonlyMat4 the matrix to calculate Frobenius norm of
Source:
Frobenius norm
Type
Number

#### (static) fromQuat(out, q) → {mat4}

Calculates a 4x4 matrix from the given quaternion
##### Parameters:
Name Type Description
out mat4 mat4 receiving operation result
q ReadonlyQuat Quaternion to create matrix from
Source:
out
Type
mat4

#### (static) fromQuat2(out, a) → {mat4}

Creates a new mat4 from a dual quat.
##### Parameters:
Name Type Description
out mat4 Matrix
Source:
##### Returns:
mat4 receiving operation result
Type
mat4

#### (static) fromRotation(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);
##### Parameters:
Name Type Description
out mat4 mat4 receiving operation result
rad Number the angle to rotate the matrix by
axis ReadonlyVec3 the axis to rotate around
Source:
out
Type
mat4

#### (static) fromRotationTranslation(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);
##### Parameters:
Name Type Description
out mat4 mat4 receiving operation result
q quat4 Rotation quaternion
Source:
out
Type
mat4

#### (static) fromRotationTranslationScale(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)
##### Parameters:
Name Type Description
out mat4 mat4 receiving operation result
q quat4 Rotation quaternion
Source:
out
Type
mat4

#### (static) fromRotationTranslationScaleOrigin(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);
##### Parameters:
Name Type Description
out mat4 mat4 receiving operation result
q quat4 Rotation quaternion
o ReadonlyVec3 The origin vector around which to scale and rotate
Source:
out
Type
mat4

#### (static) fromScaling(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);
##### Parameters:
Name Type Description
out mat4 mat4 receiving operation result
Source:
out
Type
mat4

#### (static) fromTranslation(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);
##### Parameters:
Name Type Description
out mat4 mat4 receiving operation result
Source:
out
Type
mat4

#### (static) fromValues(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
##### 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)
m02 Number Component in column 0, row 2 position (index 2)
m03 Number Component in column 0, row 3 position (index 3)
m10 Number Component in column 1, row 0 position (index 4)
m11 Number Component in column 1, row 1 position (index 5)
m12 Number Component in column 1, row 2 position (index 6)
m13 Number Component in column 1, row 3 position (index 7)
m20 Number Component in column 2, row 0 position (index 8)
m21 Number Component in column 2, row 1 position (index 9)
m22 Number Component in column 2, row 2 position (index 10)
m23 Number Component in column 2, row 3 position (index 11)
m30 Number Component in column 3, row 0 position (index 12)
m31 Number Component in column 3, row 1 position (index 13)
m32 Number Component in column 3, row 2 position (index 14)
m33 Number Component in column 3, row 3 position (index 15)
Source:
A new mat4
Type
mat4

#### (static) fromXRotation(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);
##### Parameters:
Name Type Description
out mat4 mat4 receiving operation result
rad Number the angle to rotate the matrix by
Source:
out
Type
mat4

#### (static) fromYRotation(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);
##### Parameters:
Name Type Description
out mat4 mat4 receiving operation result
rad Number the angle to rotate the matrix by
Source:
out
Type
mat4

#### (static) fromZRotation(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);
##### Parameters:
Name Type Description
out mat4 mat4 receiving operation result
rad Number the angle to rotate the matrix by
Source:
out
Type
mat4

#### (static) frustum(out, left, right, bottom, top, near, far) → {mat4}

Generates a frustum matrix with the given bounds
##### Parameters:
Name Type Description
out mat4 mat4 frustum matrix will be written into
left Number Left bound of the frustum
right Number Right bound of the frustum
bottom Number Bottom bound of the frustum
top Number Top bound of the frustum
near Number Near bound of the frustum
far Number Far bound of the frustum
Source:
out
Type
mat4

#### (static) getRotation(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.
##### Parameters:
Name Type Description
out quat Quaternion to receive the rotation component
mat ReadonlyMat4 Matrix to be decomposed (input)
Source:
out
Type
quat

#### (static) getScaling(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.
##### Parameters:
Name Type Description
out vec3 Vector to receive scaling factor component
mat ReadonlyMat4 Matrix to be decomposed (input)
Source:
out
Type
vec3

#### (static) getTranslation(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.
##### Parameters:
Name Type Description
out vec3 Vector to receive translation component
mat ReadonlyMat4 Matrix to be decomposed (input)
Source:
out
Type
vec3

#### (static) identity(out) → {mat4}

Set a mat4 to the identity matrix
##### Parameters:
Name Type Description
out mat4 the receiving matrix
Source:
out
Type
mat4

#### (static) invert(out, a) → {mat4}

Inverts a mat4
##### Parameters:
Name Type Description
out mat4 the receiving matrix
Source:
out
Type
mat4

#### (static) lookAt(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.
##### Parameters:
Name Type Description
out mat4 mat4 frustum matrix will be written into
eye ReadonlyVec3 Position of the viewer
center ReadonlyVec3 Point the viewer is looking at
Source:
out
Type
mat4

#### (static) mul()

Alias for mat4.multiply
Source:

#### (static) multiply(out, a, b) → {mat4}

Multiplies two mat4s
##### Parameters:
Name Type Description
out mat4 the receiving matrix
Source:
out
Type
mat4

#### (static) multiplyScalar(out, a, b) → {mat4}

Multiply each element of the matrix by a scalar.
##### Parameters:
Name Type Description
out mat4 the receiving matrix
a ReadonlyMat4 the matrix to scale
b Number amount to scale the matrix's elements by
Source:
out
Type
mat4

#### (static) multiplyScalarAndAdd(out, a, b, scale) → {mat4}

Adds two mat4's after multiplying each element of the second operand by a scalar value.
##### Parameters:
Name Type Description
out mat4 the receiving vector
scale Number the amount to scale b's elements by before adding
Source:
out
Type
mat4

#### (static) ortho(out, left, right, bottom, top, near, far) → {mat4}

Generates a orthogonal projection matrix with the given bounds
##### Parameters:
Name Type Description
out mat4 mat4 frustum matrix will be written into
left number Left bound of the frustum
right number Right bound of the frustum
bottom number Bottom bound of the frustum
top number Top bound of the frustum
near number Near bound of the frustum
far number Far bound of the frustum
Source:
out
Type
mat4

#### (static) perspective(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.
##### Parameters:
Name Type Description
out mat4 mat4 frustum matrix will be written into
fovy number Vertical field of view in radians
aspect number Aspect ratio. typically viewport width/height
near number Near bound of the frustum
far number Far bound of the frustum, can be null or Infinity
Source:
out
Type
mat4

#### (static) perspectiveFromFieldOfView(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.
##### Parameters:
Name Type Description
out mat4 mat4 frustum matrix will be written into
fov Object Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees
near number Near bound of the frustum
far number Far bound of the frustum
Source:
out
Type
mat4

#### (static) rotate(out, a, rad, axis) → {mat4}

Rotates a mat4 by the given angle around the given axis
##### Parameters:
Name Type Description
out mat4 the receiving matrix
a ReadonlyMat4 the matrix to rotate
rad Number the angle to rotate the matrix by
axis ReadonlyVec3 the axis to rotate around
Source:
out
Type
mat4

#### (static) rotateX(out, a, rad) → {mat4}

Rotates a matrix by the given angle around the X axis
##### Parameters:
Name Type Description
out mat4 the receiving matrix
a ReadonlyMat4 the matrix to rotate
rad Number the angle to rotate the matrix by
Source:
out
Type
mat4

#### (static) rotateY(out, a, rad) → {mat4}

Rotates a matrix by the given angle around the Y axis
##### Parameters:
Name Type Description
out mat4 the receiving matrix
a ReadonlyMat4 the matrix to rotate
rad Number the angle to rotate the matrix by
Source:
out
Type
mat4

#### (static) rotateZ(out, a, rad) → {mat4}

Rotates a matrix by the given angle around the Z axis
##### Parameters:
Name Type Description
out mat4 the receiving matrix
a ReadonlyMat4 the matrix to rotate
rad Number the angle to rotate the matrix by
Source:
out
Type
mat4

#### (static) scale(out, a, v) → {mat4}

Scales the mat4 by the dimensions in the given vec3 not using vectorization
##### Parameters:
Name Type Description
out mat4 the receiving matrix
a ReadonlyMat4 the matrix to scale
v ReadonlyVec3 the vec3 to scale the matrix by
Source:
out
Type
mat4

#### (static) set(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
##### Parameters:
Name Type Description
out mat4 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)
m02 Number Component in column 0, row 2 position (index 2)
m03 Number Component in column 0, row 3 position (index 3)
m10 Number Component in column 1, row 0 position (index 4)
m11 Number Component in column 1, row 1 position (index 5)
m12 Number Component in column 1, row 2 position (index 6)
m13 Number Component in column 1, row 3 position (index 7)
m20 Number Component in column 2, row 0 position (index 8)
m21 Number Component in column 2, row 1 position (index 9)
m22 Number Component in column 2, row 2 position (index 10)
m23 Number Component in column 2, row 3 position (index 11)
m30 Number Component in column 3, row 0 position (index 12)
m31 Number Component in column 3, row 1 position (index 13)
m32 Number Component in column 3, row 2 position (index 14)
m33 Number Component in column 3, row 3 position (index 15)
Source:
out
Type
mat4

#### (static) str(a) → {String}

Returns a string representation of a mat4
##### Parameters:
Name Type Description
a ReadonlyMat4 matrix to represent as a string
Source:
##### Returns:
string representation of the matrix
Type
String

#### (static) sub()

Alias for mat4.subtract
Source:

#### (static) subtract(out, a, b) → {mat4}

Subtracts matrix b from matrix a
##### Parameters:
Name Type Description
out mat4 the receiving matrix
Source:
out
Type
mat4

#### (static) targetTo(out, eye, center, up) → {mat4}

Generates a matrix that makes something look at something else.
##### Parameters:
Name Type Description
out mat4 mat4 frustum matrix will be written into
eye ReadonlyVec3 Position of the viewer
center ReadonlyVec3 Point the viewer is looking at
Source:
out
Type
mat4

#### (static) translate(out, a, v) → {mat4}

Translate a mat4 by the given vector
##### Parameters:
Name Type Description
out mat4 the receiving matrix
a ReadonlyMat4 the matrix to translate
v ReadonlyVec3 vector to translate by
Source:
out
Type
mat4

#### (static) transpose(out, a) → {mat4}

Transpose the values of a mat4
##### Parameters:
Name Type Description
out mat4 the receiving matrix