Quaternion

Implementation of a quaternion. Quaternions are used to represent rotations.

Core Class

Implementation of a quaternion. Quaternions are used to represent rotations.

Constructors

  • Parameters

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

    Returns Quaternion

Properties

isQuaternion: boolean

Check the type whether it belongs to Matrix3. This value should not be changed by user.

Accessors

  • get x(): number

    Returns number

  • set x(value: number): void

    Parameters

    • value: number

    Returns void

  • get y(): number

    Returns number

  • set y(value: number): void

    Parameters

    • value: number

    Returns void

  • get z(): number

    Returns number

  • set z(value: number): void

    Parameters

    • value: number

    Returns void

  • get w(): number

    Returns number

  • set w(value: number): void

    Parameters

    • value: number

    Returns void

Methods

  • The function will be called when _x| x, _y| y _z| z and _w| w is changed.

    Returns void

  • Handles the spherical linear interpolation between quaternions. t represents the amount of rotation between this quaternion (where t is 0) and qb (where t is 1). This quaternion is set to the result. Also see the static version of the slerp below.

    // rotate a mesh towards a target quaternion
    mesh.quaternion.slerp( endQuaternion, 0.01 );
    

    Parameters

    Returns Quaternion

  • Like the static slerp method above, but operates directly on flat arrays of numbers.

    Parameters

    • dst: number[]

      The output array.

    • dstOffset: number

      An offset into the output array.

    • src0: number[]

      The source array of the starting quaternion.

    • srcOffset0: number

      An offset into the array src0.

    • src1: number[]

      The source array of the target quaternions.

    • srcOffset1: number

      An offset into the array src1.

    • t: number

      Normalized interpolation factor (between 0 and 1).

    Returns void

  • Sets x, y, z, w properties of this quaternion.

    Parameters

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

    Returns Quaternion

  • Sets this quaternion from the rotation specified by Euler angle.

    Parameters

    • euler: Euler
    • update: boolean

    Returns Quaternion

  • Sets this quaternion from rotation specified by axis and Float| angle. Adapted from the method here.

    Parameters

    • axis: Vector3
    • angle: number

      is in radians.

    Returns Quaternion

  • Returns the rotational conjugate of this quaternion. The conjugate of a quaternion represents the same rotation in the opposite direction about the rotational axis.

    Returns Quaternion

  • Computes the squared Euclidean length (straight-line length) of this quaternion, considered as a 4 dimensional vector. This can be useful if you are comparing the lengths of two quaternions, as this is a slightly more efficient calculation than length| length().

    Returns number

  • Computes the Euclidean length (straight-line length) of this quaternion, considered as a 4 dimensional vector.

    Returns number

  • Normalizes this quaternion - that is, calculated the quaternion that performs the same rotation as this one, but has length| length equal to 1.

    Returns Quaternion

  • Handles the spherical linear interpolation between quaternions. t represents the amount of rotation between this quaternion (where t is 0) and qb (where t is 1). This quaternion is set to the result. Also see the static version of the method slerp.

    // rotate a mesh towards a target quaternion
    mesh.quaternion.slerp( endQuaternion, 0.01 );
    

    Parameters

    • qb: Quaternion

      The other quaternion rotation.

    • t: number

      interpolation factor in the closed interval [0, 1].

    Returns Quaternion

  • Compares the x, y,z and w properties of v to the equivalent properties of this quaternion to determine if they represent the same rotation.

    Parameters

    Returns boolean

  • Sets this quaternion's x, y, z and w properties from an array.

    Parameters

    • array: ArrayLike<number>

      array of format (x, y, z, w) used to construct the quaternion.

    • offset: number

      (optional) an offset into the array.

    Returns Quaternion

  • Returns the numerical elements of this quaternion in an array of format [x, y, z, w].

    Parameters

    • array: number[]

      An optional array to store the quaternion. If not specified, a new array will be created.

    • offset: number

      (optional) if specified, the result will be copied into this array.

    Returns number[]