Options
Menu

Class Quaternion

A Quaternion object which can be used to represent rotations.

Hierarchy

  • Quaternion

Index

Constructors

constructor

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

    Parameters

    • Default value x: number = 0

      The x value of the quaternion.

    • Default value y: number = 0

      The y value of the quaternion.

    • Default value z: number = 0

      The z value of the quaternion.

    • Default value w: number = 1

      The w value of the quaternion.

    Returns Quaternion

Properties

w

w: number

The w value of the quaternion.

x

x: number

The x value of the quaternion.

y

y: number

The y value of the quaternion.

z

z: number

The z value of the quaternion.

Accessors

magnitude

  • get (): number
  • Returns the magnitude of the quaternion object.

    Returns number

Methods

clone

  • Clones the quaternion.

    Returns Quaternion

    An exact duplicate of the current Quaternion.

copyFrom

  • Copies the data from a quaternion into this instance.

    Parameters

    Returns void

fromAxisAngle

  • fromAxisAngle(axis: Vector3D, angle: number): void
  • Fills the quaternion object with values representing the given rotation around a vector.

    Parameters

    • axis: Vector3D

      The axis around which to rotate

    • angle: number

      The angle in radians of the rotation.

    Returns void

fromEulerAngles

  • fromEulerAngles(ax: number, ay: number, az: number): void
  • Fills the quaternion object with values representing the given euler rotation.

    Parameters

    • ax: number

      The angle in radians of the rotation around the ax axis.

    • ay: number

      The angle in radians of the rotation around the ay axis.

    • az: number

      The angle in radians of the rotation around the az axis.

    Returns void

fromMatrix

  • Extracts a quaternion rotation matrix out of a given Matrix3D object.

    Parameters

    • matrix: Matrix3D

      The Matrix3D out of which the rotation will be extracted.

    Returns void

lerp

  • Linearly interpolates between two quaternions.

    Parameters

    • qa: Quaternion

      The first quaternion to interpolate.

    • qb: Quaternion

      The second quaternion to interpolate.

    • t: number

      The interpolation weight, a value between 0 and 1.

    Returns void

multiply

  • Fills the quaternion object with the result from a multiplication of two quaternion objects.

    Parameters

    • qa: Quaternion

      The first quaternion in the multiplication.

    • qb: Quaternion

      The second quaternion in the multiplication.

    Returns void

multiplyVector

normalize

  • normalize(val?: number): void
  • Normalises the quaternion object.

    Parameters

    • Default value val: number = 1

    Returns void

rotatePoint

  • Rotates a point.

    Parameters

    • vector: Vector3D

      The Vector3D object to be rotated.

    • Default value target: Vector3D = null

      An optional Vector3D object that will contain the rotated coordinates. If not provided, a new object will be created.

    Returns Vector3D

    A Vector3D object containing the rotated point.

slerp

  • Spherically interpolates between two quaternions, providing an interpolation between rotations with constant angle change rate.

    Parameters

    • qa: Quaternion

      The first quaternion to interpolate.

    • qb: Quaternion

      The second quaternion to interpolate.

    • t: number

      The interpolation weight, a value between 0 and 1.

    Returns void

toEulerAngles

  • Fills a target Vector3D object with the Euler angles that form the rotation represented by this quaternion.

    Parameters

    • Default value target: Vector3D = null

      An optional Vector3D object to contain the Euler angles. If not provided, a new object is created.

    Returns Vector3D

    The Vector3D containing the Euler angles.

toMatrix3D

  • Converts the quaternion to a Matrix3D object representing an equivalent rotation.

    Parameters

    • Default value target: Matrix3D = null

      An optional Matrix3D container to store the transformation in. If not provided, a new object is created.

    Returns Matrix3D

    A Matrix3D object representing an equivalent rotation.

toRawData

  • toRawData(target: number[], exclude4thRow?: boolean): void
  • Converts the quaternion to a Vector.<Number> matrix representation of a rotation equivalent to this quaternion.

    Parameters

    • target: number[]

      The Vector.<Number> to contain the raw matrix data.

    • Default value exclude4thRow: boolean = false

      If true, the last row will be omitted, and a 4x3 matrix will be generated instead of a 4x4.

    Returns void

toString

  • toString(): string
  • Used to trace the values of a quaternion.

    Returns string

    A string representation of the quaternion object.

Generated using TypeDoc