[name]
Implementation of a
quaternion. This is used for rotating things without encountering the dreaded
gimbal lock issue, amongst other advantages.
Example
var quaternion = new THREE.Quaternion();
quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
var vector = new THREE.Vector3( 1, 0, 0 );
vector.applyQuaternion( quaternion );
Constructor
[name]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] )
x - x coordinate
y - y coordinate
z - z coordinate
w - w coordinate
Properties
[property:Float x]
[property:Float y]
[property:Float z]
[property:Float w]
Methods
[method:Quaternion set]( [page:Float x], [page:Float y], [page:Float z], [page:Float w] )
Sets values of this quaternion.
[method:Quaternion copy]( [page:Quaternion q] )
Copies values of *q* to this quaternion.
[method:Quaternion setFromEuler]( [page:Euler euler] )
Sets this quaternion from rotation specified by Euler angle.
[method:Quaternion setFromAxisAngle]( [page:Vector3 axis], [page:Float angle] )
Sets this quaternion from rotation specified by axis and angle.
Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm].
*Axis* is asumed to be normalized, *angle* is in radians.
[method:Quaternion setFromRotationMatrix]( [page:Matrix4 m] )
Sets this quaternion from rotation component of *m*.
Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm].
[method:Quaternion setFromUnitVectors]( [page:Vector3 vFrom], [page:Vector3 vTo] )
Sets this quaternion to the rotation required to rotate direction vector *vFrom* to direction vector *vTo*.
Adapted from [link:http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors].
*vFrom* and *vTo* are assumed to be normalized.
[method:Quaternion inverse]()
Inverts this quaternion.
[method:Float length]()
Computes length of this quaternion.
[method:Quaternion normalize]()
Normalizes this quaternion.
[method:Quaternion multiply]( [page:Quaternion b] )
Multiplies this quaternion by *b*.
[method:Quaternion multiplyQuaternions]( [page:Quaternion a], [page:Quaternion b] )
Sets this quaternion to *a x b*
Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm].
[method:Quaternion multiplyVector3]( [page:Vector3 vector], [page:Vector3 dest] )
Rotates *vector* by this quaternion into *dest*.
If *dest* is not specified, result goes to *vec*.
[method:Quaternion clone]()
Clones this quaternion.
Static methods
[method:Quaternion slerp]( [page:Quaternion qa], [page:Quaternion qb], [page:Quaternion qm], [page:Float t] )
Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/].
[method:Quaternion slerp]([page:Quaternion qb], [page:float t])
qb -- Target quaternion rotation.
t -- Normalized [0..1] interpolation factor.
Handles the spherical linear interpolation between this quaternion's configuration
and that of *qb*. *t* represents how close to the current (0) or target (1) rotation the
result should be.
[method:Array toArray]( [page:Array array] )
array -- Array to store the quaternion.
Returns the numerical elements of this quaternion in an array of format (x, y, z, w).
[method:Boolean equals]([page:Quaternion v])
v -- Quaternion that this quaternion will be compared to.
Compares each component of *v* to each component of this quaternion to determine if they
represent the same rotation.
[method:Float lengthSq]()
Calculates the squared length of the quaternion.
[method:Quaternion fromArray]([page:Array array])
array -- Array of format (x, y, z, w) used to construct the quaternion.
Sets this quaternion's component values from an array.
[method:Quaternion conjugate]()
Returns the rotational conjugate of this quaternion. The conjugate of a quaternion
represents the same rotation in the opposite direction about the rotational axis.
Source
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]