KQuaternion interface
四元数(quaternion)是用来表示旋转变换的一种形式,它可以避免欧拉角的万向节死锁问题。
An interface representing quaternion. Quaternion is used for rotating models without encountering the dreaded gimbal lock issue, amongst other advantages.
Signature:
export interface KQuaternion
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
| number | 四元数的w实部。 The quaternion's w value. | |
| number | 四元数的x虚部。 The quaternion's x value. | |
| number | 四元数的y虚部。 The quaternion's y value. | |
| number | 四元数的z虚部。 The quaternion's z value. |
Methods
Method | Description |
---|---|
克隆自己,返回一个新的四元数对象。 Get the cloned object of this 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. | |
从另外一个四元数对象复制数据,覆盖自己的数据成员。 Copy values from another quaternion. | |
求取和另外一个四元数的点积。 Calculates the dot product of quaternions v and this one | |
从数组中读取数据,赋值给自己的数据成员。 Copy values (x, y, z and w) from an array with 4 elements. | |
获取以弧度为单位的旋转角度。 返回旋转角度。 Angle of rotation about the axis, in radius. | |
获取旋转轴。如果旋转角度是零的话,返回一个各分量为零的旋转轴。 返回旋转轴。 The axis of rotation (normalized); return a zero vector if angle of rotation is zero. | |
判断是不是和联外一个四元数相等。 Whether two quaternions are equal. | |
求取这个四元数当成一个四维向量,求取它的欧几里得长度。 Computes the Euclidean length (straight-line length) of this quaternion, considered as a 4 dimensional vector. | |
求取各元素的平方和。 Computes the 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(). | |
右乘一个四元数。 Multiplies this quaternion by q. | |
把两个四元数的乘机结果赋值给自己。 Sets this quaternion to a x b. | |
归一化这个四元数。 归一化后它仍旧表示相同的旋转变换,只是长度变为1。 Normalizes this quaternion - that is, calculated the quaternion that performs the same rotation as this one, but has length equal to 1. | |
左乘一个四元数。 Pre-multiplies this quaternion by q. | |
把自己变成自己的逆变换。 Reverse this quaternion. | |
设置四元数的虚部和实部。 Set quaternion's x, y, z and w | |
从绕某个给定轴旋转给定角度的表示形式转换成四元数的表示形式,并设置到自己的数据成员。 Sets this quaternion from rotation specified by axis and angle. NOTE: the axis will be normalized. | |
把一个欧拉角转化成四元数形式,并设置到自己的数据成员。 Set values by an input euler object. | |
从一个变换矩阵提取旋转变换,转换成四元数形式,并设置到自己的数据成员。 Sets this quaternion from rotation component of the input matrix. | |
从一个向量到另外一个向量的旋转变化形式,转化成四元数表示形式,并设置到自己的数据成员。 Sets this quaternion to the rotation required to rotate direction vector vFrom to direction vector vTo. | |
和另外一个四元数做球面线性插值。 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. | |
Decompose the rotation on to 2 parts http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition/index.htm twist = rotation around the direction vector swing = rotation around axis that is perpendicular to direction vector rotate = swing * twist | |
四元数转成数据表达形式。 Convert to a array containing x, y, z, w. |