RSX Code Reference
    Preparing search index...

    Class Matrix4

    The Matrix4 implements a 4x4 matrix that can be used for homogenous transformations of three dimensional vectors and points.

    The class follows the 'copy-on-write' pattern, which means that every operation such as Matrix4.multiply returns a copy of the matrix with updated values. It also implies that the values of the matrix cannot be directly modified.

    The concept of immutability improves sharing of objects as all types in TypeScript are assigned by identity, instead of by-value (e.g. a copy) as in other programming languages like C.

    The matrix storage is "row-major" meaning that elements [0...3] represents the first row. The first column is represented by the elements[0, 4, 8, 12]

    Index
    • Creates a new matrix with the specified elements. If no arguments are specified, an identity matrix is constructed.

      Parameters

      • Optionalm00: number
      • Optionalm01: number
      • Optionalm02: number
      • Optionalm03: number
      • Optionalm10: number
      • Optionalm11: number
      • Optionalm12: number
      • Optionalm13: number
      • Optionalm20: number
      • Optionalm21: number
      • Optionalm22: number
      • Optionalm23: number
      • Optionalm30: number
      • Optionalm31: number
      • Optionalm32: number
      • Optionalm33: number

      Returns Matrix4

    identity: Immutable<Matrix4>

    Identity matrix.

    A matrix with all zero values.

    • get m00(): number

      Returns number

    • set m00(m00: number): void

      Parameters

      • m00: number

      Returns void

    • get m01(): number

      Returns number

    • set m01(m01: number): void

      Parameters

      • m01: number

      Returns void

    • get m02(): number

      Returns number

    • set m02(m02: number): void

      Parameters

      • m02: number

      Returns void

    • get m03(): number

      Returns number

    • set m03(m03: number): void

      Parameters

      • m03: number

      Returns void

    • get m10(): number

      Returns number

    • set m10(m10: number): void

      Parameters

      • m10: number

      Returns void

    • get m11(): number

      Returns number

    • set m11(m11: number): void

      Parameters

      • m11: number

      Returns void

    • get m12(): number

      Returns number

    • set m12(m12: number): void

      Parameters

      • m12: number

      Returns void

    • get m13(): number

      Returns number

    • set m13(m13: number): void

      Parameters

      • m13: number

      Returns void

    • get m20(): number

      Returns number

    • set m20(m20: number): void

      Parameters

      • m20: number

      Returns void

    • get m21(): number

      Returns number

    • set m21(m21: number): void

      Parameters

      • m21: number

      Returns void

    • get m22(): number

      Returns number

    • set m22(m22: number): void

      Parameters

      • m22: number

      Returns void

    • get m23(): number

      Returns number

    • set m23(m23: number): void

      Parameters

      • m23: number

      Returns void

    • get m30(): number

      Returns number

    • set m30(m30: number): void

      Parameters

      • m30: number

      Returns void

    • get m31(): number

      Returns number

    • set m31(m31: number): void

      Parameters

      • m31: number

      Returns void

    • get m32(): number

      Returns number

    • set m32(m32: number): void

      Parameters

      • m32: number

      Returns void

    • get m33(): number

      Returns number

    • set m33(m33: number): void

      Parameters

      • m33: number

      Returns void

    • Calculates the determinant of the matrix.

      Returns number

      Determinant of the matrix.

    • Clones this instance and returns a new Matrix4 with identical values.

      Returns Matrix4

    • Calculates the inverse of the matrix. If matrix is affine use invertAffine as it is faster.

      Returns void

    • Calculates the inverse of the matrix. Matrix must be affine.

      Returns void

    • Sets values of a specific column in the matrix.

      Parameters

      • columnIndex: number

        Index of the column in range [0, 3].

      • column: Immutable<Vector4>

        Values to set in the column.

      Returns Matrix4

    • Transposes the matrix (switched columns and rows).

      Returns void

    • Gets a specific column in the matrix.

      Parameters

      • columnIndex: number

        Index of the column in range [0, 3].

      Returns Vector4

      The column as Vector4.

    • Gets a specific column in the matrix as a Vector3, discarding the fourth component.

      Parameters

      • columnIndex: number

        Index of the column in range [0, 3].

      Returns Vector3

      The upper three rows of the column as Vector3.

    • Gets the value of the specified element in the matrix.

      Parameters

      • row: number

        Row index of the element to retrieve.

      • column: number

        Column index of the element to retrieve.

      Returns number

      Value of the element.

    • Returns value of the specified element in the matrix using a linear index. Linear index can be calculated using the following formula: idx = row * 4 + column.

      Parameters

      • index: number

        Linear index to get the value of.

      Returns number

      Value of the element.

    • Gets the translation part from the matrix.

      Returns Vector3

      The translation as Vector3.

    • Decompose a matrix to translation, rotation and scale components. Matrix must consist only of translation, rotation and uniform scale transformations, otherwise accurate results are not guaranteed. Applying non-uniform scale guarantees results will not be accurate.

      Returns { rotation: Quaternion; scale: Vector3; translation: Vector3 }

      An object containing:

      • translation the translation
      • rotation the rotation
      • scale the scale.
    • Calculates the inverse of the matrix.

      Returns Matrix4

    • Calculates the inverse of the matrix. Matrix must be affine.

      Returns Matrix4

    • Determines if this matrix is are element-wise equal to the provided one.

      Parameters

      Returns boolean

    • Transform a 3D point by this matrix. Matrix must be affine. Affine multiplication offers better performance than the general case.

      Parameters

      Returns Vector3

      Point transformed by this matrix.

    • Transform a 4D vector by this matrix. Matrix must be affine. Affine multiplication offers better performance than the general case.

      Parameters

      Returns Vector4

      Vector transformed by this matrix.

    • Transform a 3D direction vector by this matrix. w component is assumed to be 0.

      Parameters

      Returns Vector3

      Direction vector transformed by this matrix.

    • Transform a 3D point by this matrix. w component of the vector is assumed to be 1. After transformation all components are projected back so that w remains 1. If your matrix doesn't contain projection components use multiplyAffineVector4 as it is faster.

      Parameters

      Returns Vector3

      Point transformed by this matrix.

    • Transform a 4D vector by this matrix. If your matrix doesn't contain projection components use multiplyAffineVector4 as it is faster.

      Parameters

      Returns Vector4

      Vector transformed by this matrix.

    • Sets values of a specific column in the matrix.

      Parameters

      • columnIndex: number

        Index of the column in range [0, 3].

      • column: Immutable<Vector4>

        Values to set in the column.

      Returns Matrix4

    • Sets the value of the specified element in the matrix.

      Parameters

      • row: number

        Row index of the element to retrieve.

      • column: number

        Column index of the element to retrieve.

      • value: number

      Returns void

      Value of the element.

    • Sets value of the specified element in the matrix using a linear index. Linear index can be calculated using the following formula: idx = row * 4 + column.

      Parameters

      • index: number

        Linear index to gsetet the value of.

      • value: number

        New value of the element.

      Returns void

    • Sets the translation part from the matrix.

      Parameters

      Returns void

    • Returns string

    • Returns a transpose of the matrix (switched columns and rows).

      Returns Matrix4

    • Returns a 4x4 matrix with the upper-left 3x3 portion set from the provided matrix. The translation column is set to identity values.

      Parameters

      Returns Matrix4

      4x4 matrix with the rotation/scaling parts set from the provided 3x3 matrix.

    • Returns the rotation/scaling parts of the 4x4 matrix.

      Parameters

      Returns Matrix3

      3x3 matrix representing an upper left portion of the provided matrix.

    • Creates a new identity matrix.

      Returns Matrix4

    • Returns a 4x4 matrix with the upper-left 3x3 portion set from matrix and the translation column set from position.

      Parameters

      Returns Matrix4

      4x4 matrix combining the rotation/scaling from the 3x3 matrix and the provided translation.