dot big bang

Developer API
Menu

Class Quaternion

All
  • Public
  • Public/Protected
  • All

Hierarchy

  • Quaternion

Index

Constructors

constructor

  • new Quaternion(x?: number, y?: number, z?: number, w?: number): Quaternion
  • Creates a new quaternion.

    Parameters

    • Optional x: number

      The x coordinate of the quaternion. Default is 0.

    • Optional y: number

      The y coordinate of the quaternion. Default is 0.

    • Optional z: number

      The z coordinate of the quaternion. Default is 0.

    • Optional w: number

      The w coordinate of the quaternion. Default is 1.

    Returns Quaternion

Accessors

w

  • get w(): number
  • set w(value: number): void
  • The w coordinate of the quaternion.

    Returns number

  • The w coordinate of the quaternion.

    Parameters

    • value: number

    Returns void

x

  • get x(): number
  • set x(value: number): void
  • The x coordinate of the quaternion.

    Returns number

  • The x coordinate of the quaternion.

    Parameters

    • value: number

    Returns void

y

  • get y(): number
  • set y(value: number): void
  • The y coordinate of the quaternion.

    Returns number

  • The y coordinate of the quaternion.

    Parameters

    • value: number

    Returns void

z

  • get z(): number
  • set z(value: number): void
  • The z coordinate of the quaternion.

    Returns number

  • The z coordinate of the quaternion.

    Parameters

    • value: number

    Returns void

Methods

clone

  • Creates a new quaternion with identical x, y, z and w properties to this one.

    Returns Quaternion

conjugate

  • 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

copy

  • Copies the x, y, z and w properties of v into this quaternion.

    Parameters

    • v: Quaternion

      The other quaternion to copy the coordinates from.

    Returns Quaternion

dot

equals

  • 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

    • v: Quaternion

      The quaternion that this one will be compared to.

    Returns boolean

fromArray

  • fromArray(array: number[], offset?: number): Quaternion
  • Sets this quaternion's x, y, z, and w properties from the provided array.

    Parameters

    • array: number[]

      The array of format [x, y, z, w] used to construct this quaternion.

    • Optional offset: number

      An offset into the array from where to start reading the elements. Defaults to 0.

    Returns Quaternion

inverse

  • Conjugates and normalizes this quaternion.

    Returns Quaternion

length

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

    Returns number

lengthSq

  • lengthSq(): 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 number

multiply

  • Multiplies this quaternion by the other quaternion q.

    Parameters

    • q: Quaternion

      The quaternion to multiply this one by.

    Returns Quaternion

multiplyQuaternions

  • Sets this quaternion to a x b. Adapted from the method outlined here.

    Parameters

    Returns Quaternion

normalize

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

    Returns Quaternion

premultiply

  • Pre-multiplies this quaternion by the other quaternion q.

    Parameters

    • q: Quaternion

      The quaternion to pre-multiply this one by.

    Returns Quaternion

set

  • set(x: number, y: number, z: number, w: number): Quaternion
  • Sets the x, y, z and w properties of this quaternion.

    Parameters

    • x: number

      The x coordinate of the quaternion.

    • y: number

      The y coordinate of the quaternion.

    • z: number

      The z coordinate of the quaternion.

    • w: number

      The w coordinate of the quaternion.

    Returns Quaternion

setFromAxisAngle

  • Sets this quaternion from the rotation specified by axis and angle. The axis is assumed to be normalized, and angle is in radians. Adapted from the method here.

    Parameters

    • axis: Vector3

      The normalized axis of rotation.

    • angle: number

      The rotation angle in radians.

    Returns Quaternion

setFromEuler

  • Sets this quaternion from the rotation specified by the euler transform.

    Parameters

    • euler: Euler

      The euler transform to set this quaternion from.

    Returns Quaternion

setFromRotationMatrix

  • Sets this quaternion from the rotation components of m. Adapted from the method here.

    Parameters

    Returns Quaternion

setFromUnitVectors

  • Sets this quaternion to the rotation required to rotate the direction vector vFrom to the direction vector vTo. vFrom and vTo are assumed to be normalized. Adapted from the method here

    Parameters

    • vFrom: Vector3

      "From" direction vector.

    • vTo: Vector3

      "To" direction vector.

    Returns Quaternion

slerp

  • 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. A slerp static method also exists.

    Parameters

    • qb: Quaternion

      The other quaternion rotation to interpolate towards.

    • t: number

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

    Returns Quaternion

toArray

  • toArray(array?: number[], offset?: number): number[]
  • Returns the numerical elements of this quaternion in an array of format [x, y, z, w].

    Parameters

    • Optional array: number[]

      The array to store the quaternion in. If not specified, a new array will be created.

    • Optional offset: number

      An offset into the array where to write the elements of this quaternion.

    Returns number[]

Static slerp

  • Handles the spherical linear interpolation between two quaternions and store the result in a third one. t represents the amount of rotation between qStart (where t is 0) and qEnd (where t is 1). The quaternion qTarget is set to the result. A slerp instance method also exists.

    Parameters

    • qStart: Quaternion

      The starting quaternion (where t is 0).

    • qEnd: Quaternion

      The ending quaternion (where t is 1).

    • qTarget: Quaternion

      The target quaternion that gets set with the result.

    • t: number

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

    Returns Quaternion

Static slerpFlat

  • slerpFlat(dst: number[], dstOffset: number, src0: number[], srcOffset0: number, src1: number[], srcOffset1: number, t: number): void
  • Handles the spherical linear interpolation between two quaternions and store the result in a third one, each one being is stored as an array of numbers. t represents the amount of rotation between qStartArray (where t is 0) and qEndArray (where t is 1). The quaternion qTargetArray is set to the result. A slerp instance method also exists.

    Parameters

    • dst: number[]
    • dstOffset: number
    • src0: number[]
    • srcOffset0: number
    • src1: number[]
    • srcOffset1: number
    • t: number

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

    Returns void