Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace mat4

Index

Functions

add

  • add(out: mat4, a: ReadonlyMat4, b: ReadonlyMat4): mat4
  • Adds two mat4's

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the first operand

    • b: ReadonlyMat4

      the second operand

    Returns mat4

    out

adjoint

  • adjoint(out: mat4, a: ReadonlyMat4): mat4
  • Calculates the adjugate of a mat4

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the source matrix

    Returns mat4

    out

clone

  • clone(a: ReadonlyMat4): mat4
  • Creates a new mat4 initialized with values from an existing matrix

    Parameters

    • a: ReadonlyMat4

      matrix to clone

    Returns mat4

    a new 4x4 matrix

copy

  • copy(out: mat4, a: ReadonlyMat4): mat4
  • Copy the values from one mat4 to another

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the source matrix

    Returns mat4

    out

create

  • Creates a new identity mat4

    Returns mat4

    a new 4x4 matrix

determinant

  • determinant(a: ReadonlyMat4): number
  • Calculates the determinant of a mat4

    Parameters

    • a: ReadonlyMat4

      the source matrix

    Returns number

    determinant of a

equals

  • equals(a: ReadonlyMat4, b: ReadonlyMat4): boolean
  • Returns whether or not the matrices have approximately the same elements in the same position.

    Parameters

    • a: ReadonlyMat4

      The first matrix.

    • b: ReadonlyMat4

      The second matrix.

    Returns boolean

    True if the matrices are equal, false otherwise.

exactEquals

  • exactEquals(a: ReadonlyMat4, b: ReadonlyMat4): boolean
  • Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)

    Parameters

    • a: ReadonlyMat4

      The first matrix.

    • b: ReadonlyMat4

      The second matrix.

    Returns boolean

    True if the matrices are equal, false otherwise.

frob

  • frob(a: ReadonlyMat4): number
  • Returns Frobenius norm of a mat4

    Parameters

    • a: ReadonlyMat4

      the matrix to calculate Frobenius norm of

    Returns number

    Frobenius norm

fromQuat

  • fromQuat(out: mat4, q: ReadonlyQuat): mat4
  • Calculates a 4x4 matrix from the given quaternion

    Parameters

    • out: mat4

      mat4 receiving operation result

    • q: ReadonlyQuat

      Quaternion to create matrix from

    Returns mat4

    out

fromQuat2

  • fromQuat2(out: mat4, a: ReadonlyQuat2): mat4
  • Creates a new mat4 from a dual quat.

    Parameters

    • out: mat4

      Matrix

    • a: ReadonlyQuat2

      Dual Quaternion

    Returns mat4

    mat4 receiving operation result

fromRotation

  • fromRotation(out: mat4, rad: number, axis: ReadonlyVec3): 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

    • out: mat4

      mat4 receiving operation result

    • rad: number

      the angle to rotate the matrix by

    • axis: ReadonlyVec3

      the axis to rotate around

    Returns mat4

    out

fromRotationTranslation

  • fromRotationTranslation(out: mat4, q: any, v: ReadonlyVec3): 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

    • out: mat4

      mat4 receiving operation result

    • q: any

      Rotation quaternion

    • v: ReadonlyVec3

      Translation vector

    Returns mat4

    out

fromRotationTranslationScale

  • fromRotationTranslationScale(out: mat4, q: any, v: ReadonlyVec3, s: ReadonlyVec3): 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

    • out: mat4

      mat4 receiving operation result

    • q: any

      Rotation quaternion

    • v: ReadonlyVec3

      Translation vector

    • s: ReadonlyVec3

      Scaling vector

    Returns mat4

    out

fromRotationTranslationScaleOrigin

  • fromRotationTranslationScaleOrigin(out: mat4, q: any, v: ReadonlyVec3, s: ReadonlyVec3, o: ReadonlyVec3): 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

    • out: mat4

      mat4 receiving operation result

    • q: any

      Rotation quaternion

    • v: ReadonlyVec3

      Translation vector

    • s: ReadonlyVec3

      Scaling vector

    • o: ReadonlyVec3

      The origin vector around which to scale and rotate

    Returns mat4

    out

fromScaling

  • fromScaling(out: mat4, v: ReadonlyVec3): 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

    • out: mat4

      mat4 receiving operation result

    • v: ReadonlyVec3

      Scaling vector

    Returns mat4

    out

fromTranslation

  • fromTranslation(out: mat4, v: ReadonlyVec3): 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

    • out: mat4

      mat4 receiving operation result

    • v: ReadonlyVec3

      Translation vector

    Returns mat4

    out

fromValues

  • fromValues(m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number): mat4
  • Create a new mat4 with the given values

    Parameters

    • 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)

    Returns mat4

    A new mat4

fromXRotation

  • fromXRotation(out: mat4, rad: number): 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

    • out: mat4

      mat4 receiving operation result

    • rad: number

      the angle to rotate the matrix by

    Returns mat4

    out

fromYRotation

  • fromYRotation(out: mat4, rad: number): 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

    • out: mat4

      mat4 receiving operation result

    • rad: number

      the angle to rotate the matrix by

    Returns mat4

    out

fromZRotation

  • fromZRotation(out: mat4, rad: number): 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

    • out: mat4

      mat4 receiving operation result

    • rad: number

      the angle to rotate the matrix by

    Returns mat4

    out

frustum

  • frustum(out: mat4, left: number, right: number, bottom: number, top: number, near: number, far: number): mat4
  • Generates a frustum matrix with the given bounds

    Parameters

    • 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

    Returns mat4

    out

getRotation

  • getRotation(out: quat, mat: ReadonlyMat4): 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

    • out: quat

      Quaternion to receive the rotation component

    • mat: ReadonlyMat4

      Matrix to be decomposed (input)

    Returns quat

    out

getScaling

  • getScaling(out: vec3, mat: ReadonlyMat4): 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

    • out: vec3

      Vector to receive scaling factor component

    • mat: ReadonlyMat4

      Matrix to be decomposed (input)

    Returns vec3

    out

getTranslation

  • getTranslation(out: vec3, mat: ReadonlyMat4): 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

    • out: vec3

      Vector to receive translation component

    • mat: ReadonlyMat4

      Matrix to be decomposed (input)

    Returns vec3

    out

identity

  • Set a mat4 to the identity matrix

    Parameters

    • out: mat4

      the receiving matrix

    Returns mat4

    out

invert

  • invert(out: mat4, a: ReadonlyMat4): mat4
  • Inverts a mat4

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the source matrix

    Returns mat4

    out

lookAt

  • lookAt(out: mat4, eye: ReadonlyVec3, center: ReadonlyVec3, up: ReadonlyVec3): 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

    • out: mat4

      mat4 frustum matrix will be written into

    • eye: ReadonlyVec3

      Position of the viewer

    • center: ReadonlyVec3

      Point the viewer is looking at

    • up: ReadonlyVec3

      vec3 pointing up

    Returns mat4

    out

mul

  • mul(out: mat4, a: ReadonlyMat4, b: ReadonlyMat4): mat4
  • Multiplies two mat4s

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the first operand

    • b: ReadonlyMat4

      the second operand

    Returns mat4

    out

multiply

  • multiply(out: mat4, a: ReadonlyMat4, b: ReadonlyMat4): mat4
  • Multiplies two mat4s

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the first operand

    • b: ReadonlyMat4

      the second operand

    Returns mat4

    out

multiplyScalar

  • multiplyScalar(out: mat4, a: ReadonlyMat4, b: number): mat4
  • Multiply each element of the matrix by a scalar.

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the matrix to scale

    • b: number

      amount to scale the matrix's elements by

    Returns mat4

    out

multiplyScalarAndAdd

  • multiplyScalarAndAdd(out: mat4, a: ReadonlyMat4, b: ReadonlyMat4, scale: number): mat4
  • Adds two mat4's after multiplying each element of the second operand by a scalar value.

    Parameters

    • out: mat4

      the receiving vector

    • a: ReadonlyMat4

      the first operand

    • b: ReadonlyMat4

      the second operand

    • scale: number

      the amount to scale b's elements by before adding

    Returns mat4

    out

ortho

  • ortho(out: mat4, left: number, right: number, bottom: number, top: number, near: number, far: number): mat4
  • Generates a orthogonal projection matrix with the given bounds

    Parameters

    • 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

    Returns mat4

    out

perspective

  • perspective(out: mat4, fovy: number, aspect: number, near: number, far: number): mat4
  • Generates a perspective projection matrix with the given bounds. Passing null/undefined/no value for far will generate infinite projection matrix.

    Parameters

    • 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

    Returns mat4

    out

perspectiveFromFieldOfView

  • perspectiveFromFieldOfView(out: mat4, fov: any, near: number, far: number): 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

    • out: mat4

      mat4 frustum matrix will be written into

    • fov: any

      Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees

    • near: number

      Near bound of the frustum

    • far: number

      Far bound of the frustum

    Returns mat4

    out

rotate

  • rotate(out: mat4, a: ReadonlyMat4, rad: number, axis: ReadonlyVec3): mat4
  • Rotates a mat4 by the given angle around the given axis

    Parameters

    • 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

    Returns mat4

    out

rotateX

  • rotateX(out: mat4, a: ReadonlyMat4, rad: number): mat4
  • Rotates a matrix by the given angle around the X axis

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the matrix to rotate

    • rad: number

      the angle to rotate the matrix by

    Returns mat4

    out

rotateY

  • rotateY(out: mat4, a: ReadonlyMat4, rad: number): mat4
  • Rotates a matrix by the given angle around the Y axis

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the matrix to rotate

    • rad: number

      the angle to rotate the matrix by

    Returns mat4

    out

rotateZ

  • rotateZ(out: mat4, a: ReadonlyMat4, rad: number): mat4
  • Rotates a matrix by the given angle around the Z axis

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the matrix to rotate

    • rad: number

      the angle to rotate the matrix by

    Returns mat4

    out

scale

  • scale(out: mat4, a: ReadonlyMat4, v: ReadonlyVec3): mat4
  • Scales the mat4 by the dimensions in the given vec3 not using vectorization

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the matrix to scale

    • v: ReadonlyVec3

      the vec3 to scale the matrix by

    Returns mat4

    out

set

  • set(out: mat4, m00: number, m01: number, m02: number, m03: number, m10: number, m11: number, m12: number, m13: number, m20: number, m21: number, m22: number, m23: number, m30: number, m31: number, m32: number, m33: number): mat4
  • Set the components of a mat4 to the given values

    Parameters

    • 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)

    Returns mat4

    out

str

  • str(a: ReadonlyMat4): string
  • Returns a string representation of a mat4

    Parameters

    • a: ReadonlyMat4

      matrix to represent as a string

    Returns string

    string representation of the matrix

sub

  • sub(out: mat4, a: ReadonlyMat4, b: ReadonlyMat4): mat4
  • Subtracts matrix b from matrix a

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the first operand

    • b: ReadonlyMat4

      the second operand

    Returns mat4

    out

subtract

  • subtract(out: mat4, a: ReadonlyMat4, b: ReadonlyMat4): mat4
  • Subtracts matrix b from matrix a

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the first operand

    • b: ReadonlyMat4

      the second operand

    Returns mat4

    out

targetTo

  • targetTo(out: mat4, eye: ReadonlyVec3, target: any, up: ReadonlyVec3): mat4
  • Generates a matrix that makes something look at something else.

    Parameters

    • out: mat4

      mat4 frustum matrix will be written into

    • eye: ReadonlyVec3

      Position of the viewer

    • target: any
    • up: ReadonlyVec3

      vec3 pointing up

    Returns mat4

    out

translate

  • translate(out: mat4, a: ReadonlyMat4, v: ReadonlyVec3): mat4
  • Translate a mat4 by the given vector

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the matrix to translate

    • v: ReadonlyVec3

      vector to translate by

    Returns mat4

    out

transpose

  • transpose(out: mat4, a: ReadonlyMat4): mat4
  • Transpose the values of a mat4

    Parameters

    • out: mat4

      the receiving matrix

    • a: ReadonlyMat4

      the source matrix

    Returns mat4

    out