Class IdentityMatrix44

Represents a 4x4 identity matrix that provides optimized operations for identity transformations. This class implements the identity matrix pattern where all diagonal elements are 1 and all other elements are 0. It extends AbstractMatrix and implements both IMatrix and IMatrix44 interfaces.

The identity matrix is immutable and provides efficient implementations since the result of many operations can be computed without actual matrix multiplication.

const identity = new IdentityMatrix44();
const vector = new Vector4(1, 2, 3, 1);
const result = identity.multiplyVector(vector); // Returns the same vector

Hierarchy (view full)

Implements

Constructors

Properties

_v: Float32Array = ...

Internal Float32Array storage for matrix elements

__v: Float32Array = ...

Static array representing the identity matrix values in column-major order. This is shared across all instances for memory efficiency.

Accessors

  • get compositionType(): CompositionTypeClass<"MAT4">
  • Gets the composition type for this matrix class.

    Returns CompositionTypeClass<"MAT4">

    CompositionType.Mat4 indicating this is a 4x4 matrix

Methods

  • Gets the matrix element at the specified row and column indices. For identity matrix, returns 1 for diagonal elements and 0 for off-diagonal elements.

    Parameters

    • row_i: number

      The row index (0-based)

    • column_i: number

      The column index (0-based)

    Returns number

    1 if row equals column (diagonal), 0 otherwise

  • Checks if the given matrix is approximately equal to this identity matrix within a tolerance. Compares each element of the input matrix against the corresponding identity matrix element.

    Parameters

    • mat: IMatrix44

      The matrix to compare against this identity matrix

    • delta: number = Number.EPSILON

      The tolerance for floating-point comparison (default: Number.EPSILON)

    Returns boolean

    True if the matrix is approximately an identity matrix, false otherwise

  • Performs a strict equality check against another matrix. Uses exact floating-point comparison without tolerance.

    Parameters

    • mat: IMatrix

      The matrix to compare for strict equality

    Returns boolean

    True if the matrix is exactly an identity matrix, false otherwise

  • Checks if the matrix's internal storage shares the same ArrayBuffer as the provided one.

    This method is useful for determining if two matrices share the same underlying memory, which can be important for performance optimizations and avoiding unnecessary data copying.

    Parameters

    • arrayBuffer: ArrayBuffer

      The ArrayBuffer to compare against

    Returns boolean

    True if the internal storage uses the same ArrayBuffer, false otherwise

  • Multiplies this identity matrix with a vector and stores the result in an output vector. Since this is an identity matrix, copies the input vector to the output vector.

    Parameters

    Returns IMutableVector

    The output vector containing the copied values

  • Gets the matrix element at the specified linear index in column-major order. For identity matrix, returns 1 for diagonal positions and 0 elsewhere.

    Parameters

    • i: number

      The linear index (0-15) in column-major order

    Returns number

    1 for diagonal elements (indices 0, 5, 10, 15), 0 otherwise