Class Quaternion

A Quaternion describes a rotation in 3D space. The Quaternion is mathematically defined as Q = xi + yj + z*k + w, where (i,j,k) are imaginary basis vectors. (x,y,z) can be seen as a vector related to the axis of rotation, while the real multiplier, w, is related to the amount of rotation.

Param: x

Multiplier of the imaginary basis vector i.

Param: y

Multiplier of the imaginary basis vector j.

Param: z

Multiplier of the imaginary basis vector k.

Param: w

Multiplier of the real part.

See

http://en.wikipedia.org/wiki/Quaternion

Constructors

  • Parameters

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

    Returns Quaternion

Properties

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

Methods

  • Rotate an absolute orientation quaternion given an angular velocity and a time step.

    Parameters

    Returns Quaternion

  • Normalize the quaternion. Note that this changes the values of the quaternion.

    Returns Quaternion

  • Set the value of the quaternion.

    Parameters

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

    Returns Quaternion

  • Set the quaternion components given an axis and an angle in radians.

    Parameters

    • vector: Vec3
    • angle: number

    Returns Quaternion

  • Set the quaternion components given Euler angle representation.

    Parameters

    • x: number
    • y: number
    • z: number
    • Optional order: string

      The order to apply angles: 'XYZ' or 'YXZ' or any other combination.

      See MathWorks reference

    Returns Quaternion

  • Set the quaternion value given two vectors. The resulting rotation will be the needed rotation to rotate u to v.

    Parameters

    Returns Quaternion

  • Performs a spherical linear interpolation between two quat

    Parameters

    • toQuat: Quaternion

      second operand

    • t: number

      interpolation amount between the self quaternion and toQuat

    • Optional target: Quaternion

      A quaternion to store the result in. If not provided, a new one will be created.

    Returns Quaternion

    The "target" object

  • Convert to an Array

    Returns [number, number, number, number]

    [x, y, z, w]

  • Converts the quaternion to [ axis, angle ] representation.

    Parameters

    • Optional targetAxis: Vec3

      A vector object to reuse for storing the axis.

    Returns [Vec3, number]

    An array, first element is the axis and the second is the angle in radians.

  • Convert to a readable format

    Returns string

    "x,y,z,w"

  • Multiply the quaternion by a vector

    Parameters

    Returns Vec3