Create a new instance. Default is a unit quaternion
x coordinate
y coordinate
z coordinate
w coordinate
Read-only flag to check if a given object is of type Quaternion.
Find the angle between this quaternion and quaternion q in radians.
The angle.
Creates a new Quaternion with identical x, y, z and w properties to this one.
A new instance.
Compute the rotational conjugate of this quaternion. The conjugate of a quaternion represents the same rotation in the opposite direction about the rotational axis.
The conjugate quaternion.
Copies the x, y, z and w properties of q into this quaternion.
This instance.
Calculates the dot product of quaternions v and this one.
The dot product.
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.
True when equivalance is found; false otherwise.
quaternion that this quaternion will be compared to.
Sets this quaternion's x, y, z and w properties from an array.
This instance.
array of format (x, y, z, w) used to construct the quaternion.
Optional
offset: number = 0an offset into the array.
Sets this quaternion to the identity quaternion; that is, to the quaternion that represents "no rotation".
This instance
Inverts this quaternion - calculates the conjugate. The quaternion is assumed to have unit length.
This instance.
Computes the Euclidean length (straight-line length) of this quaternion, considered as a 4 dimensional vector.
The Euclidean length.
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().
The squared Euclidean length.
Multiplies this quaternion by q.
This instance.
Sets this quaternion to a x b.
This instance.
Normalizes this quaternion - that is, calculated the quaternion that performs the same rotation as this one, but has length equal to 1.
This instance.
Pre-multiplies this quaternion by q.
This instance.
Sets this quaternion to a uniformly random, normalized quaternion.
This instance.
Rotates this quaternion by a given angular step to the defined quaternion q. The method ensures that the final quaternion will not overshoot q.
This instance.
THe target quaternion
The angular step in radians
Sets x, y, z, w properties of this quaternion.
This instance.
Sets this quaternion from rotation specified by axis and angle. Axis is assumed to be normalized, angle is in radians.
http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
This instance.
Sets this quaternion from the rotation specified by Euler angle.
This instance.
Optional
update: booleanSets this quaternion from rotation component of m.
This instance.
a Matrix4 of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).
Sets this quaternion to the rotation required to rotate direction vector vFrom to direction vector vTo.
This instance.
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. Also see the static version of the slerp below.
This instance.
The other quaternion rotation
interpolation factor in the closed interval [0, 1].
Performs a spherical linear interpolation between the given quaternions and stores the result in this quaternion.
This instance.
Calculates the numerical elements of this quaternion in an array of format [x, y, z, w].
The array equivalent of this quaternion.
An optional array to store the quaternion. If not specified, a new array will be created.
if specified, the result will be copied into this Array.
Static
multiplyMultiply 2 quaterions. This multiplication implementation assumes the quaternion data are managed in flat arrays.
The output array.
An offset into the output array.
The source array of the starting quaternion.
An offset into the array src0.
The source array of the target quaternion.
An offset into the array src1.
Static
slerpThis SLERP implementation assumes the quaternion data are managed in flat arrays.
An offset into the output array.
The source array of the starting quaternion.
An offset into the array src0.
The source array of the target quatnerion.
An offset into the array src1.
Normalized interpolation factor (between 0 and 1).
Implementation of a quaternion. Quaternions are used to represent rotations.
Example