Options
All
• Public
• Public/Protected
• All

# 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

• Quaternion

## Constructors

### constructor

• new Quaternion(x?: number, y?: number, z?: number, w?: number): Quaternion

## Methods

### conjugate

• Get the quaternion conjugate

### copy

• Copies value of source to this quaternion.

this

### integrate

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

### inverse

• Get the inverse quaternion rotation.

### mult

• Multiply the quaternion with an other quaternion.

### normalize

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

### set

• set(x: number, y: number, z: number, w: number): Quaternion
• Set the value of the quaternion.

### setFromAxisAngle

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

### setFromEuler

• setFromEuler(x: number, y: number, z: number, order?: string): Quaternion
• Set the quaternion components given Euler angle representation.

#### Parameters

• ##### order: string = 'XYZ'

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

See MathWorks reference

### setFromVectors

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

### slerp

• Performs a spherical linear interpolation between two quat

#### Parameters

• ##### toQuat: Quaternion

second operand

• ##### t: number

interpolation amount between the self quaternion and toQuat

• ##### target: Quaternion = ...

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

#### Returns Quaternion

The "target" object

### toArray

• toArray(): [number, number, number, number]
• Convert to an Array

### toAxisAngle

• toAxisAngle(targetAxis?: Vec3): [Vec3, number]
• Converts the quaternion to [ axis, angle ] representation.

#### Parameters

• ##### 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.

### toEuler

• toEuler(target: Vec3, order?: string): void

### toString

• toString(): string
• Convert to a readable format

"x,y,z,w"

### vmult

• Multiply the quaternion by a vector