[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
.[page:Float x]
.[page:Float y]
.[page:Float z]
.[page:Float w]
Methods
.set( [page:Float x], [page:Float y], [page:Float z], [page:Float w] ) [page:Quaternion]
Sets values of this quaternion.
.copy( [page:Quaternion q] ) [page:Quaternion]
Copies values of *q* to this quaternion.
.setFromEuler( [page:Vector3 vector] ) [page:Quaternion]
Sets this quaternion from rotation specified by Euler angles.
.setFromAxisAngle( [page:Vector3 axis], [page:Float angle] ) [page:Quaternion]
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* have to be normalized, *angle* is in radians.
.setFromRotationMatrix( [page:Matrix4 m] ) [page:Quaternion]
Sets this quaternion from rotation component of *m*.
Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm].
.inverse() [page:Quaternion]
Inverts this quaternion.
.length() [page:Float]
Computes length of this quaternion.
.normalize() [page:Quaternion]
Normalizes this quaternion.
.multiply( [page:Quaternion b] ) [page:Quaternion]
Multiplies this quaternion by *b*.
.multiplyQuaternions( [page:Quaternion a], [page:Quaternion b] ) [page:Quaternion]
Sets this quaternion to *a x b*
Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm].
.multiplyVector3( [page:Vector3 vector], [page:Vector3 dest] ) [page:Quaternion]
Rotates *vector* by this quaternion into *dest*.
If *dest* is not specified, result goes to *vec*.
.clone() [page:Quaternion]
Clones this quaternion.
Static methods
.slerp( [page:Quaternion qa], [page:Quaternion qb], [page:Quaternion qm], [page:Float t] ) [page:Quaternion]
Adapted from [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/].
.slerp([page:Quaternion qb], [page:float t]) [page:Quaternion]
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.
.toArray() [page: Array]
Returns the numerical elements of this quaternion in an array of format (x, y, z, w).
.equals([page:Quaternion v]) [page:Boolean]
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.
.lengthSq() [page:Float]
Calculates the squared length of the quaternion.
.fromArray([page:Array array]) [page:Quaternion]
array -- Array of format (x, y, z, w) used to construct the quaternion.
Sets this quaternion's component values from an array.
.conjugate() [page: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.
Source
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]