rhodonite
    Preparing search index...

    Class QuaternionD

    Immutable quaternion with 64-bit float components.

    Hierarchy (View Summary)

    Index
    _v: TypedArray = ...

    Internal typed array storage for quaternion components [x, y, z, w].

    _type: FloatTypedArrayConstructor = Float64Array

    The typed array constructor used for newly created quaternions.

    • get className(): string

      Gets the class name for debugging and reflection purposes.

      Returns string

      The string "Quaternion"

    • get w(): number

      Gets the w component (scalar part) of the quaternion.

      Returns number

      The w component value

    • get x(): number

      Gets the x component (i coefficient) of the quaternion.

      Returns number

      The x component value

    • get y(): number

      Gets the y component (j coefficient) of the quaternion.

      Returns number

      The y component value

    • get z(): number

      Gets the z component (k coefficient) of the quaternion.

      Returns number

      The z component value

    • get compositionType(): CompositionTypeClass<"VEC4">

      Gets the composition type for this quaternion class.

      Returns CompositionTypeClass<"VEC4">

      CompositionType.Vec4 indicating this is a 4-component vector

    • Gets the component at the specified index.

      Parameters

      • i: number

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

      Returns number

      The component value at the given index

    • Creates a deep copy of this quaternion.

      Returns this

      A new quaternion with the same component values

    • Calculates the dot product between this quaternion and another quaternion. The dot product of two quaternions gives a scalar value that represents the cosine of half the angle between them when both quaternions are unit quaternions.

      Parameters

      • quat: IQuaternion

        The quaternion to compute the dot product with

      Returns number

      The dot product result

    • Converts the quaternion to a flat array representation.

      Returns number[]

      An array containing [x, y, z, w] components

    • Creates a quaternion representing the rotation from one vector to another. This is an instance method version of the static fromToRotation.

      Parameters

      • from: IVector3

        The starting direction vector

      • to: IVector3

        The target direction vector

      Returns any

      The normalized quaternion representing the rotation

    • Checks if this quaternion is a dummy (uninitialized) quaternion.

      Returns boolean

      True if the internal array has zero length, false otherwise

    • Checks if this quaternion is approximately equal to another quaternion within a tolerance.

      Parameters

      • quat: IQuaternion

        The quaternion to compare with

      • delta: number = Number.EPSILON

        The tolerance value (default: Number.EPSILON)

      Returns boolean

      True if all components are within the tolerance, false otherwise

    • Checks if this quaternion is exactly equal to another quaternion.

      Parameters

      Returns boolean

      True if all components are exactly equal, false otherwise

    • Calculates the magnitude (length) of the quaternion.

      Returns number

      The Euclidean norm of the quaternion

    • Calculates the squared magnitude of the quaternion. This is more efficient than length() when you only need to compare magnitudes.

      Returns number

      The squared Euclidean norm of the quaternion

    • Converts the quaternion to Euler angles. The rotation order is XYZ (roll, pitch, yaw).

      Returns Vector3

      A new Vector3 containing the Euler angles in radians

    • Converts the quaternion to Euler angles and stores the result in the output vector. The rotation order is XYZ (roll, pitch, yaw).

      Parameters

      • out: IMutableVector3

        The output vector to store the Euler angles [x, y, z]

      Returns IMutableVector3

      The output vector containing the Euler angles in radians

    • Converts the quaternion to a string representation.

      Returns string

      A string in the format "(x, y, z, w)"

    • Converts the quaternion to an approximately formatted string using financial precision.

      Returns string

      A formatted string with components separated by spaces and ending with newline

    • Transforms a 3D vector by this quaternion rotation. Applies the rotation represented by this quaternion to the input vector.

      Parameters

      Returns Vector3

      A new transformed vector

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

      Parameters

      Returns any

      A new transformed vector

    • fromCopy4

      Parameters

      • x: number
      • y: number
      • z: number
      • w: number

      Returns QuaternionD

    • Creates a quaternion that directly uses the given Float64Array (no copy).

      Parameters

      • array: Float64Array

      Returns QuaternionD