Interface IQuaternion

Immutable quaternion interface representing a rotation in 3D space. Quaternions are a mathematical notation for representing rotations and orientations. They consist of four components: x, y, z (imaginary parts) and w (real part).

interface IQuaternion {
    _v: Float32Array;
    className: string;
    w: number;
    x: number;
    y: number;
    z: number;
    at(i: number): number;
    clone(): IQuaternion;
    dot(vec: IQuaternion): number;
    flattenAsArray(): number[];
    isDummy(): boolean;
    isEqual(vec: IQuaternion, delta?: number): boolean;
    isStrictEqual(vec: IQuaternion): boolean;
    length(): number;
    lengthSquared(): number;
    toEulerAngles(): IVector3;
    toEulerAnglesTo(out: IMutableVector3): IMutableVector3;
    toString(): string;
    toStringApproximately(): string;
    transformVector3(vec: IVector3): IVector3;
    transformVector3Inverse(vec: IVector3): IVector3;
    transformVector3To(vec: IVector3, out: IMutableVector3): IVector3;
}

Hierarchy (view full)

Implemented by

Properties

_v: Float32Array

Internal Float32Array storage for quaternion components

className: string

The class name identifier

w: number

The w component (real quaternion basis)

x: number

The x component (i quaternion basis)

y: number

The y component (j quaternion basis)

z: number

The z component (k quaternion basis)

Methods

  • Gets the component value at the specified index.

    Parameters

    • i: number

      Index (0=x, 1=y, 2=z, 3=w)

    Returns number

    The component value at the given index

  • Converts the quaternion to a flat array of numbers.

    Returns number[]

    Array containing [x, y, z, w] components

  • Checks if this quaternion is a dummy/invalid quaternion.

    Returns boolean

    True if the quaternion is dummy, false otherwise

  • Compares this quaternion with another quaternion for equality within a tolerance.

    Parameters

    • vec: IQuaternion

      The quaternion to compare with

    • Optionaldelta: number

      Optional tolerance value for comparison (default uses system epsilon)

    Returns boolean

    True if quaternions are equal within tolerance, false otherwise

  • Compares this quaternion with another quaternion for strict equality.

    Parameters

    Returns boolean

    True if quaternions are exactly equal, false otherwise

  • Calculates the squared magnitude of the quaternion. More efficient than length() when only comparison is needed.

    Returns number

    The squared magnitude of the quaternion

  • Returns a string representation of the quaternion.

    Returns string

    String representation of the quaternion

  • Returns an approximate string representation of the quaternion with limited precision.

    Returns string

    Approximate string representation