t3d. Quaternion

The Quaternion class

Constructor

new Quaternion(xopt, yopt, zopt, wopt)

Parameters:
NameTypeAttributesDefaultDescription
xNumber<optional>
0x coordinate
yNumber<optional>
0y coordinate
zNumber<optional>
0z coordinate
wNumber<optional>
1w coordinate

Members

w :Number

Type:
  • Number

w :Number

Type:
  • Number

x :Number

Type:
  • Number

x :Number

Type:
  • Number

y :Number

Type:
  • Number

y :Number

Type:
  • Number

z :Number

Type:
  • Number

z :Number

Type:
  • Number

Methods

clone() → {t3d.Quaternion}

Creates a new Quaternion with identical x, y, z and w properties to this one.
Returns:
Type: 
t3d.Quaternion

conjugate() → {t3d.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:
Type: 
t3d.Quaternion

copy(quaternion) → {t3d.Quaternion}

Copies the x, y, z and w properties of q into this quaternion.
Parameters:
NameTypeDescription
quaterniont3d.Quaternion
Returns:
Type: 
t3d.Quaternion

dot(v) → {t3d.Quaternion}

Calculates the dot product of quaternions v and this one.
Parameters:
NameTypeDescription
vt3d.Quaternion
Returns:
Type: 
t3d.Quaternion

fromArray(array, offsetopt, denormalizeopt) → {t3d.Quaternion}

Sets this quaternion's x, y, z and w properties from an array.
Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<Number>array of format (x, y, z, w) used to construct the quaternion.
offsetNumber<optional>
0an offset into the array.
denormalizeBoolean<optional>
falseif true, denormalize the values, and array should be a typed array.
Returns:
Type: 
t3d.Quaternion

length() → {Number}

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

lerpQuaternions(q1, q2, ratio) → {t3d.Quaternion}

Linearly interpolates between two quaternions.
Parameters:
NameTypeDescription
q1t3d.Quaternion
q2t3d.Quaternion
ratioNumber
Returns:
Type: 
t3d.Quaternion

multiply(q) → {t3d.Quaternion}

Multiplies this quaternion by q.
Parameters:
NameTypeDescription
qt3d.Quaternion
Returns:
Type: 
t3d.Quaternion

multiplyQuaternions(a, b) → {t3d.Quaternion}

Sets this quaternion to a x b.
Parameters:
NameTypeDescription
at3d.Quaternion
bt3d.Quaternion
Returns:
Type: 
t3d.Quaternion

normalize() → {t3d.Quaternion}

Normalizes this quaternion - that is, calculated the quaternion that performs the same rotation as this one, but has length equal to 1.
Returns:
Type: 
t3d.Quaternion

onChange(callback) → {t3d.Quaternion}

Parameters:
NameTypeDescription
callbackfunctionWhen the Quaternion angle value changes, the callback method is triggered
Returns:
Type: 
t3d.Quaternion

premultiply(q) → {t3d.Quaternion}

Pre-multiplies this quaternion by q.
Parameters:
NameTypeDescription
qt3d.Quaternion
Returns:
Type: 
t3d.Quaternion

set(x, y, z, w) → {t3d.Quaternion}

Sets x, y, z, w properties of this quaternion.
Parameters:
NameTypeDefaultDescription
xNumber0
yNumber0
zNumber0
wNumber1
Returns:
Type: 
t3d.Quaternion

setFromAxisAngle(axis, angle) → {t3d.Quaternion}

Set quaternion from axis angle
Parameters:
NameTypeDescription
axist3d.Vector3
angleNumber
Returns:
Type: 
t3d.Quaternion

setFromEuler(euler, updateopt) → {t3d.Quaternion}

Sets this quaternion from the rotation specified by Euler angle.
Parameters:
NameTypeAttributesDefaultDescription
eulert3d.Euler
updateBoolean<optional>
trueWhether to notify quaternion angle has changed
Returns:
Type: 
t3d.Quaternion

setFromRotationMatrix(m) → {t3d.Quaternion}

Sets this quaternion from rotation component of m.
Parameters:
NameTypeDescription
mt3d.Matrix4
Returns:
Type: 
t3d.Quaternion

setFromUnitVectors(vFrom, vTo) → {t3d.Quaternion}

vFrom and vTo are assumed to be normalized.
Parameters:
NameTypeDescription
vFromt3d.Vector3
vTot3d.Vector3
Returns:
Type: 
t3d.Quaternion

slerpQuaternions(q1, q2, ratio) → {t3d.Quaternion}

Spherically interpolates between two quaternions providing an interpolation between rotations with constant angle change rate.
Parameters:
NameTypeDescription
q1t3d.Quaternion
q2t3d.Quaternion
ratioNumber
Returns:
Type: 
t3d.Quaternion

toArray(arrayopt, offsetopt, normalizeopt) → {t3d.Quaternion}

Returns the numerical elements of this quaternion in an array of format [x, y, z, w].
Parameters:
NameTypeAttributesDefaultDescription
arrayArray.<Number><optional>
An array to store the quaternion. If not specified, a new array will be created.
offsetNumber<optional>
0An offset into the array.
normalizeBoolean<optional>
falseif true, normalize the values, and array should be a typed array.
Returns:
Type: 
t3d.Quaternion

toMatrix4(target) → {t3d.Matrix4}

Convert the current quaternion to a matrix4
Parameters:
NameTypeDescription
targett3d.Matrix4
Returns:
Type: 
t3d.Matrix4

(static) multiplyQuaternionsFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1) → {Array.<Number>}

Multipley quaternions, but operates directly on flat arrays of numbers.
Parameters:
NameTypeDescription
dstArray.<Number>The output array.
dstOffsetNumberAn offset into the output array.
src0Array.<Number>The source array of the starting quaternion.
srcOffset0NumberAn offset into the array src0.
src1Array.<Number>The source array of the target quatnerion.
srcOffset1NumberAn offset into the array src1.
Returns:
Type: 
Array.<Number>

(static) slerpFlat(dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t)

Slerp method, operates directly on flat arrays of numbers.
Parameters:
NameTypeDescription
dstArray.<Number>The output array.
dstOffsetNumberAn offset into the output array.
src0Array.<Number>The source array of the starting quaternion.
srcOffset0NumberAn offset into the array src0.
src1Array.<Number>The source array of the target quatnerion.
srcOffset1NumberAn offset into the array src1.
tNumberNormalized interpolation factor (between 0 and 1).