rhodonite
    Preparing search index...

    Class AbstractQuaternionAbstract

    Abstract base class for quaternion implementations.

    Quaternions are a mathematical system that extends complex numbers and are commonly used in 3D graphics for representing rotations. A quaternion consists of four components (x, y, z, w) where (x, y, z) represents the vector part and w represents the scalar part.

    This abstract class provides common functionality and interface for all quaternion implementations while leaving specific operations to be implemented by concrete subclasses.

    Hierarchy (View Summary)

    Implements

    Index
    _v: TypedArray = ...

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

    • get className(): string

      Gets the class name of the quaternion implementation.

      Returns string

      The name of the constructor function

    • 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

    • 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 IQuaternion

      A new quaternion instance with the same values

      Error - Method must be implemented by subclass

    • 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

    • Flattens the quaternion components into a plain number array.

      Returns number[]

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

      Error - Method must be implemented by subclass

    • Checks if this quaternion is a dummy/placeholder instance.

      Returns boolean

      True if this is a dummy quaternion, false otherwise

      Error - Method must be implemented by subclass

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

      Parameters

      Returns boolean

      True if quaternions are approximately equal, false otherwise

      Error - Method must be implemented by subclass

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

      Parameters

      Returns boolean

      True if quaternions are exactly equal, false otherwise

      Error - Method must be implemented by subclass

    • 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.

      Returns IVector3

      A new vector containing the Euler angles

      Error - Method must be implemented by subclass

    • Converts the quaternion to a string representation.

      Returns string

      String representation of the quaternion

      Error - Method must be implemented by subclass

    • Converts the quaternion to an approximate string representation. Useful for debugging when exact precision is not required.

      Returns string

      Approximate string representation of the quaternion

      Error - Method must be implemented by subclass

    • Transforms a 3D vector by this quaternion rotation.

      Parameters

      Returns IVector3

      A new transformed vector

      Error - Method must be implemented by subclass

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

      Parameters

      Returns IVector3

      A new vector transformed by the inverse rotation

      Error - Method must be implemented by subclass