Class Quaternion

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

Example

const quaternion = new Quaternion();
quaternion.setFromAxisAngle( new Vector3( 0, 1, 0 ), Math.PI / 2 );

const vector = new Vector3( 1, 0, 0 );
vector.applyQuaternion( quaternion );

Hierarchy

  • Base
    • Quaternion

Constructors

  • Create a new instance. Default is a unit quaternion

    Parameters

    • Optional x: number

      x coordinate

    • Optional y: number

      y coordinate

    • Optional z: number

      z coordinate

    • Optional w: number

      w coordinate

    Returns Quaternion

Properties

_w: number
_x: number
_y: number
_z: number

Accessors

  • get isBox2(): boolean
  • Returns boolean

  • get isBox3(): boolean
  • Returns boolean

  • get isColor(): boolean
  • Returns boolean

  • get isCylindrical(): boolean
  • Returns boolean

  • get isEuler(): boolean
  • Returns boolean

  • get isLine3(): boolean
  • Returns boolean

  • get isMatrix3(): boolean
  • Returns boolean

  • get isMatrix4(): boolean
  • Returns boolean

  • get isPlane(): boolean
  • Returns boolean

  • get isQuaternion(): boolean
  • Read-only flag to check if a given object is of type Quaternion.

    Returns boolean

  • get isRay(): boolean
  • Returns boolean

  • get isSphere(): boolean
  • Returns boolean

  • get isSpherical(): boolean
  • Returns boolean

  • get isTriangle(): boolean
  • Returns boolean

  • get isVector2(): boolean
  • Returns boolean

  • get isVector3(): boolean
  • Returns boolean

  • get isVector4(): boolean
  • Returns boolean

Methods

  • Returns IterableIterator<number>

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

    Returns

    The conjugate quaternion.

    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.

    Returns

    True when equivalance is found; false otherwise.

    Parameters

    • quaternion: Quaternion

      quaternion that this quaternion will be compared to.

    Returns boolean

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

    Returns

    This instance.

    Parameters

    • array: number[]

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

    • Optional offset: number

      an offset into the array.

    Returns Quaternion

  • Sets this quaternion to the identity quaternion; that is, to the quaternion that represents "no rotation".

    Returns

    This instance

    Returns Quaternion

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

    Returns

    The Euclidean length.

    Returns number

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

    Returns

    The squared Euclidean length.

    Returns number

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

    Returns

    This instance.

    Returns Quaternion

  • Rotates this quaternion by a given angular step to the defined quaternion q. The method ensures that the final quaternion will not overshoot q.

    Returns

    This instance.

    Parameters

    • q: Quaternion

      THe target quaternion

    • step: number

      The angular step in radians

    Returns Quaternion

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

    Returns

    This instance.

    Parameters

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

    Returns Quaternion

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

    Returns

    This instance.

    Parameters

    • euler: Euler
    • Optional update: boolean

    Returns Quaternion

  • Sets this quaternion from rotation component of m.

    Returns

    This instance.

    Parameters

    • m: Matrix4

      a Matrix4 of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).

    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 slerp below.

    Returns

    This instance.

    Parameters

    • qb: Quaternion

      The other quaternion rotation

    • t: number

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

    Returns Quaternion

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

    Returns

    The array equivalent of this quaternion.

    Parameters

    • Optional array: number[]

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

    • Optional offset: number

      if specified, the result will be copied into this Array.

    Returns number[]

  • Multiply 2 quaterions. This multiplication implementation assumes the quaternion data are managed in flat arrays.

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

    • srcOffset1: number

      An offset into the array src1.

    Returns number[]

  • This SLERP implementation assumes the quaternion data are managed in flat arrays.

    Parameters

    • dst: number[]
    • 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 quatnerion.

    • srcOffset1: number

      An offset into the array src1.

    • t: number

      Normalized interpolation factor (between 0 and 1).

    Returns void