Storing and manipulating rotations in the form of quaternions. Constructed out of the 4 components: (x, y, z, w). Mathematical notation: w + xi + yj + zk. A Quaternion can be described with an axis and angle: (x, y, z) = sin(angle/2)*axis; w = cos(angle/2). roll: x, pitch: y, yaw: z. Note that operations are adapted to work with vectors where y is up and z is forward.

Authors

Matthias Roming, HFU, 2023 | Marko Fehrenbach, HFU, 2020 | Jonas Plotzky, HFU, 2023

Hierarchy (view full)

Implements

Constructors

Properties

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

Accessors

  • get eulerAngles(): Vector3
    • get: return the euler angle representation of the rotation in degrees. Caution! Use immediately and readonly, since the vector is going to be reused internally. Create a clone to keep longer and manipulate.
    • set: set the euler angle representation of the rotation in degrees.

    Returns Vector3

  • set eulerAngles(_eulerAngles): void
  • Parameters

    Returns void

  • get type(): string
  • Retrieves the type of this mutable subclass as the name of the runtime class

    Returns string

    The type of the mutable

Methods

  • Returns true if this quaternion is equal to the given quaternion within the given tolerance.

    Parameters

    • _compare: Quaternion
    • _tolerance: number = Number.EPSILON

    Returns boolean

  • Set the values of this object from the given array starting at the given offset.

    Parameters

    • _array: ArrayLike<number>

      The array to read the values from.

    • _offset: number = 0

      (optional) The offset to start reading from.

    Returns this

    A reference to this instance.

  • Collect applicable attributes of the instance and copies of their values in a Mutator-object. By default, a mutator cannot be extended, since extensions are not available in the object the mutator belongs to. A mutator may be reduced by the descendants of Mutable to contain only the properties needed.

    Parameters

    • _extendable: boolean = false

    Returns Mutator

  • Updates the attribute values of the instance according to the state of the mutator. The mutation may be restricted to a subset of the mutator and the event dispatching suppressed. Uses mutateBase, but can be overwritten in subclasses

    Parameters

    Returns void

  • Copy the values of this object into the given array starting at the given offset. Creates a new array if none is provided.

    Type Parameters

    • T extends {
          [n: number]: number;
      } = number[]

    Parameters

    • _out: T = ...

      (optional) The receiving array.

    • _offset: number = 0

      (optional) The offset to start writing to.

    Returns T

    _out or a new array if none is provided.

  • Normalize a quaternion array.

    Type Parameters

    • T extends {
          [n: number]: number;
      }

    Parameters

    • _a: Readonly<T>

      quaternion array to normalize.

    • _aOffset: number

      the offset into the quaternion array.

    • _out: T

      the receiving quaternion array.

    • _outOffset: number

      the offset into the receiving quaternion array.

    Returns T

    out

  • Returns a quaternion that rotates coordinates when multiplied by, using the axis and angle given. Axis must be normalized. Angle is in degrees.

    Parameters

    • _axis: Vector3
    • _angle: number
    • _out: Quaternion = ...

      Optional quaternion to store the result in.

    Returns Quaternion

  • Returns a quaternion that rotates coordinates when multiplied by, using the angles given. Rotation occurs around the axis in the order Z-Y-X.

    Parameters

    • _eulerAngles: Vector3
    • _out: Quaternion = ...

      Optional quaternion to store the result in.

    Returns Quaternion

  • Performs a spherical linear interpolation between two quaternion arrays.

    Type Parameters

    • T extends {
          [n: number]: number;
      }

    Parameters

    • _a: Readonly<T>

      the first operand.

    • _aOffset: number

      the offset into the first operand.

    • _b: Readonly<T>

      the second operand.

    • _bOffset: number

      the offset into the second operand.

    • _t: number

      interpolation amount, in the range [0-1], between the two inputs.

    • _out: T

      the receiving quaternion array.

    • _outOffset: number

      the offset into the receiving quaternion array.

    Returns T

    out