Creates a new Quaternion, defaulting to identity (0, 0, 0, 1)
The x component
The y component
The z component
The w component
The w component; QuaternionData says what it means
The x component; QuaternionData says what it means
The y component; QuaternionData says what it means
The z component; QuaternionData says what it means
StaticsharedA static Quaternion reset to identity on every access, for a result used straight away
This quaternion is shared and temporary. Do not store references to it.
Returns the angle of the turn from this rotation to q
Both quaternions are assumed unit-length.
The other quaternion
The angle in radians, from 0 to π
Negates x, y and z, leaving w, which reverses a unit quaternion's turn
Target to write the result into instead of this quaternion
The result quaternion for chaining
Copies q into this quaternion
The quaternion to copy from
This quaternion for chaining
Copies this quaternion into target and returns it
The quaternion to copy into
The given target
Returns the dot product of this quaternion and q
For unit quaternions its absolute value is the cosine of half the angle between the two rotations: 1 for the same rotation.
The other quaternion
The dot product
Returns true when x, y, z and w match q exactly, with no tolerance
q and its negation are the same rotation but don't compare equal.
The quaternion to compare with
Whether all components match
Reads x, y, z, w from array starting at offset
The array to read from
The offset into array to read at
This quaternion for chaining
Inverts this rotation, so it turns the other way
Computes the conjugate, which is the inverse of a unit quaternion. For any other quaternion, call Quaternion#normalize first.
Target to write the result into instead of this quaternion
The result quaternion for chaining
Returns the squared length of this quaternion
Cheaper than Quaternion#magnitude and enough to check for drift.
The squared magnitude
Multiplies this quaternion by q (this = this * q)
The result turns by q first, then by this. On a node's rotation, that turns by q around the
node's own axes; Quaternion#premultiply turns around its parent's axes.
The quaternion to multiply by
Target to write the result into instead of this quaternion
The result quaternion for chaining
Scales this quaternion to unit length, undoing the drift of repeated multiplies
A zero quaternion becomes identity.
Target to write the result into instead of this quaternion
The result quaternion for chaining
Pre-multiplies this quaternion by q (this = q * this)
The result turns by this first, then by q. On a node's rotation, that turns by q around the
parent's axes; Quaternion#multiply turns around the node's own.
The quaternion to pre-multiply by
Target to write the result into instead of this quaternion
The result quaternion for chaining
Sets this quaternion to a turn of angle radians around the unit-length axis
The unit-length rotation axis
The rotation angle in radians
Target to write the result into instead of this quaternion
The result quaternion for chaining
Sets this quaternion from Euler angles in radians
Uses the XYZ order of Container3D#rotation, so it gives the rotation a node with those angles has.
The Euler angles as (x, y, z) radians
Target to write the result into instead of this quaternion
The result quaternion for chaining
Sets this quaternion to the rotation in m
The upper-left 3x3 of m must be a pure rotation, with no scale. Use
Quaternion#setFromScaledRotationMatrix for a matrix with scale, such as a node's world
transform.
The rotation matrix to extract from
Target to write the result into instead of this quaternion
The result quaternion for chaining
Sets this quaternion to the rotation in m, a transform that may also scale each axis
A matrix with a zero scale has no rotation to read and gives NaN. A mirrored one (negative
determinant) gives a quaternion that isn't a rotation; Matrix4#decompose handles it.
The transform to extract from
Target to write the result into instead of this quaternion
The result quaternion for chaining
Sets this quaternion to the shortest turn that takes unit-length vFrom to unit-length vTo
When vTo points exactly opposite vFrom, the result is a half turn around some axis at right
angles to vFrom.
The unit-length start direction
The unit-length end direction
Target to write the result into instead of this quaternion
The result quaternion for chaining
Blends from this rotation toward qb by t, turning at an even rate the shorter way round
The quaternion to interpolate towards
The interpolation factor in [0, 1]
Target to write the result into instead of this quaternion
The result quaternion for chaining
Writes this quaternion's values into array starting at offset
The array to write into; a new array when omitted
The offset into array to write at
The written array
StaticslerpAdvanced
Spherically interpolates between two quaternions stored in flat arrays, writing the result into
dst without creating a Quaternion
Like Quaternion#slerp, it takes the shorter way round. It costs one Math.sin where the
textbook form costs three, so it suits blending many rotations every frame.
The array to write the result into
The offset into dst to write at
The array holding the start quaternion
The offset into src0 to read from
The array holding the end quaternion
The offset into src1 to read from
The interpolation factor in [0, 1]
A rotation in 3D, stored as four numbers
(x, y, z, w)Unlike Euler angles, a quaternion doesn't lose a degree of freedom when two axes line up, and Quaternion#slerp blends between two of them smoothly. QuaternionData says what the four numbers mean. A rotation quaternion has length 1. Most methods assume so, and long chains of Quaternion#multiply drift from it, which Quaternion#normalize fixes.
Methods change the quaternion they're called on and return it, so calls chain. Pass an
outtarget last to write the result there instead and leave this one as it is.Example
See
Vector3#applyQuaternion For applying a quaternion rotation to a point