rhodonite
    Preparing search index...

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

    Implements

    Index

    Constructors

    Properties

    _v: Float32Array = ...

    Internal Float32Array storage for matrix elements

    __v: Float32Array<ArrayBuffer> = ...

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

    Accessors

    • get glslStrAsFloat(): string

      Gets the GLSL string representation of the matrix as float values.

      Returns string

      GLSL-formatted string for float values

      Error - Must be implemented by subclasses

    • get glslStrAsInt(): string

      Gets the GLSL string representation of the matrix as integer values.

      Returns string

      GLSL-formatted string for integer values

      Error - Must be implemented by subclasses

    • get glslStrAsUint(): string

      Gets the GLSL string representation of the matrix as unsigned integer values.

      Returns string

      GLSL-formatted string for unsigned integer values with 'u' suffix

      Error - Must be implemented by subclasses

    • get wgslStrAsFloat(): string

      Gets the WGSL string representation of the matrix as float values.

      Returns string

      WGSL-formatted string for float values

      Error - Must be implemented by subclasses

    • get wgslStrAsInt(): string

      Gets the WGSL string representation of the matrix as integer values.

      Returns string

      WGSL-formatted string for integer values

      Error - Must be implemented by subclasses

    • get wgslStrAsUint(): string

      Gets the WGSL string representation of the matrix as unsigned integer values.

      Returns string

      WGSL-formatted string for unsigned integer values with 'u' suffix

      Error - Must be implemented by subclasses

    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

    • 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