rhodonite
    Preparing search index...

    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: TypedArray;
        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): Vector3;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Internal typed array storage for quaternion components (Float32Array or Float64Array)

    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)

    • 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

    • Creates a copy of this quaternion.

      Returns IQuaternion

      A new quaternion with the same values

    • Calculates the dot product between this quaternion and another.

      Parameters

      Returns number

      The dot product result

    • 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 magnitude (length) of the quaternion.

      Returns number

      The magnitude of the quaternion

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

      Returns number

      The squared magnitude of the quaternion

    • Converts the quaternion to Euler angles.

      Returns IVector3

      A new vector containing Euler angles (x=pitch, y=yaw, z=roll)

    • Converts the quaternion to Euler angles and stores the result in the provided vector.

      Parameters

      Returns IMutableVector3

      The output vector containing Euler angles (x=pitch, y=yaw, z=roll)

    • 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

    • Transforms a 3D vector by this quaternion rotation.

      Parameters

      Returns IVector3

      A new transformed vector

    • Transforms a 3D vector by the inverse of this quaternion rotation.

      Parameters

      Returns IVector3

      A new transformed vector

    • Transforms a 3D vector by this quaternion rotation and stores the result in the output vector.

      Parameters

      Returns Vector3

      The output vector containing the transformed result