该类实现了 [link:http://en.wikipedia.org/wiki/Quaternion quaternion] 。
四元数在three.js中用于表示 [link:https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation rotation] (旋转)。
const quaternion = new THREE.Quaternion();
quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
const vector = new THREE.Vector3( 1, 0, 0 );
vector.applyQuaternion( quaternion );
[page:Float x] - x 坐标
[page:Float y] - y 坐标
[page:Float z] - z 坐标
[page:Float w] - w 坐标
以弧度返回该四元数与四元数 [page:Quaternion q] 之间的夹角。
创建一个与该四元数具有相同[page:.x x]、[page:.y y]、[page:.z z]和[page:.w w] 属性的四元数。
返回该四元数的旋转共轭。 四元数的共轭表示的是,围绕旋转轴在相反方向上的相同旋转。
复制四元数 [page:Quaternion q] 的 [page:.x x]、[page:.y y]、[page:.z z] 和 [page:.w w] 属性到该四元数中。
[page:Quaternion v] - 用于进行比较的四元数。
将四元数 [page:Quaternion v] 的 [page:.x x]、 [page:.y y]、 [page:.z z] 和 [page:.w w] 的属性
与当前四元数的对应属性相比较,以确定它们是否表示相同的旋转。
计算四元数 [page:Quaternion v] 与当前四元数的[link:https://en.wikipedia.org/wiki/Dot_product dot product](点积)。
[page:Array array] - 用于构造四元数的形如(x, y, z, w)的数组。
[page:Integer offset] - (可选)数组的偏移量。(译者注:使用数组中从第offset元素算起的四个元素)
从一个数组来设置四元数的 [page:.x x]、 [page:.y y]、[page:.z z] 和 [page:.w w] 的属性。
设置该四元数为 identity 四元数,即表示“不旋转”的四元数。
翻转该四元数 —— 计算 [page:.conjugate conjugate] 。假定该四元数具有单位长度。
计算四元数的 [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean length] (欧几里得长度,直线长度),视为一个四维向量。
计算四元数 [link:https://en.wikipedia.org/wiki/Euclidean_distance Euclidean length] (欧几里得长度,直线长度)的平方,视为一个四维向量。 如果要比较两个四元数的长度,这可能会十分有用, 因为这比 [page:.length length]() 的效率稍高一些。
[link:https://en.wikipedia.org/wiki/Normalized_vector Normalizes](归一化)四元数 —— 即计算与该四元数具有相同旋转、但长度为*1*的四元数。
将该四元数与[page:Quaternion q]相乘。
将该四元数设为 [page:Quaternion a] x [page:Quaternion b] 。
改编自 [link:http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm here] 所概述的方法。
Pre-multiplies this quaternion by [page:Quaternion q].
[page:Quaternion q] - The target quaternion.
[page:Float step] - The angular step in radians.
Rotates this quaternion by a given angular step to the defined quaternion *q*.
The method ensures that the final quaternion will not overshoot *q*.
[page:Quaternion qb] - The other quaternion rotation
[page:Float t] - interpolation factor in the closed interval [0, 1].
Handles the spherical linear interpolation between quaternions. [page:Float t] represents the
amount of rotation between this quaternion (where [page:Float t] is 0) and [page:Quaternion qb] (where
[page:Float t] is 1). This quaternion is set to the result. Also see the static version of the
*slerp* below.
// rotate a mesh towards a target quaternion
mesh.quaternion.slerp( endQuaternion, 0.01 );
Performs a spherical linear interpolation between the given quaternions and stores the result in this quaternion.
设置该四元数的 [page:.x x]、[page:.y y]、[page:.z z]和[page:.w w]属性。
从由 [page:Vector3 axis](轴) 和 [page:Float angle](角度)所给定的旋转来设置该四元数。
改编自 [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm here] 所述的方法。
假定*Axis*已被归一化,*angle*以弧度来表示。
从由 [page:Euler] 角所给定的旋转来设置该四元数。
从[page:Matrix4 m]的旋转分量中来设置该四元数。
改编自 [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm here] 所概述的方法。
Sets this quaternion to the rotation required to rotate direction vector [page:Vector3 vFrom] to
direction vector [page:Vector3 vTo].
Adapted from the method [link:http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors here].
[page:Vector3 vFrom] and [page:Vector3 vTo] are assumed to be normalized.
[page:Array array] - (可选)存储该四元数的数组。若未指定该参数,则将创建一个新数组。
[page:Integer offset] - (可选)若指定了该值,结果将会被拷贝到该
[page:Array]。
在形如[x, y, z, w]的数组中,返回四元数中的数字元素。
[page:BufferAttribute attribute] - 源 attribute。
[page:Integer index] - attribute 中的索引。
从 [page:BufferAttribute attribute] 中设置该四元数的[page:.x x]、 [page:.y y]、 [page:.z z]、 [page:.w w]属性。
[page:Array dst] - The output array.
[page:Integer dstOffset] - An offset into the output array.
[page:Array src0] - The source array of the starting quaternion.
[page:Integer srcOffset0] - An offset into the array *src0*.
[page:Array src1] - The source array of the target quatnerion.
[page:Integer srcOffset1] - An offset into the array *src1*.
[page:Float t] - Normalized interpolation factor (between 0 and 1).
Like the static *slerp* method above, but operates directly on flat arrays of numbers.
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]