-
new Quaternion(x, y, z, w)
-
Name Type Default Description xNumber 0 optional X component
yNumber 0 optional Y component
zNumber 0 optional Z component
wNumber 1 optional W component
Members Show Inherited
| Name | Type | Default | Description |
|---|---|---|---|
className
|
String | Quaternion |
类名 |
isQuaternion
|
Boolean | true | |
elements
|
Float32Array |
数据 |
|
x
|
Number |
X component |
|
y
|
Number |
Y component |
|
z
|
Number |
Z component |
|
w
|
Number |
W component |
Methods Show Inherited
-
copy(q){Quaternion}
-
Copy the values from one quat to this
Name Type Description qQuaternion Returns:
Type Description Quaternion this -
clone(){Quaternion}
-
Creates a new quat initialized with values from an existing quaternion
Returns:
Type Description Quaternion a new quaternion -
toArray(array, offset){Array}
-
转换到数组
Name Type Default Description arrayArray.<number> | TypedArray [] optional 数组
offsetNumber 0 optional 数组偏移值
Returns:
Type Description Array -
fromArray(array, offset){Quaternion}
-
从数组赋值
Name Type Default Description arrayArray.<number> | TypedArray 数组
offsetNumber 0 optional 数组偏移值
Returns:
Type Description Quaternion this -
set(x, y, z, w){Quaternion}
-
Set the components of a quat to the given values
Name Type Description xNumber X component
yNumber Y component
zNumber Z component
wNumber W component
Returns:
Type Description Quaternion this -
identity(){Quaternion}
-
Set this to the identity quaternion
Returns:
Type Description Quaternion this -
rotationTo(a, b){Quaternion}
-
Sets a quaternion to represent the shortest rotation from one vector to another.
Name Type Description aVector3 the initial vector
bVector3 the destination vector
Returns:
Type Description Quaternion this -
setAxes(view, right, up){Quaternion}
-
Sets the specified quaternion with values corresponding to the given axes. Each axis is a vec3 and is expected to be unit length and perpendicular to all other specified axes.
Name Type Description viewVector3 the vector representing the viewing direction
rightVector3 the vector representing the local "right" direction
upVector3 the vector representing the local "up" direction
Returns:
Type Description Quaternion this -
setAxisAngle(axis, rad){Quaternion}
-
Sets a quat from the given angle and rotation axis, then returns it.
Name Type Description axisVector3 the axis around which to rotate
radNumber the angle in radians
Returns:
Type Description Quaternion this -
getAxisAngle(out_axis){Number}
-
Gets the rotation axis and angle for a given quaternion. If a quaternion is created with setAxisAngle, this method will return the same values as providied in the original parameter list OR functionally equivalent values. Example: The quaternion formed by axis [0, 0, 1] and angle -90 is the same as the quaternion formed by [0, 0, 1] and 270. This method favors the latter.
Name Type Description out_axisVector3 Vector receiving the axis of rotation
Returns:
Type Description Number Angle, in radians, of the rotation -
add(q){Quaternion}
-
Adds two quat's
Name Type Description qQuaternion Returns:
Type Description Quaternion this -
multiply(q){Quaternion}
-
Multiplies two quat's
Name Type Description qQuaternion Returns:
Type Description Quaternion this -
premultiply(q){Quaternion}
-
premultiply the quat
Name Type Description qQuaternion Returns:
Type Description Quaternion this -
scale(scale){Quaternion}
-
Scales a quat by a scalar number
Name Type Description scaleVector3 the vector to scale
Returns:
Type Description Quaternion this -
rotateX(rad){Quaternion}
-
Rotates a quaternion by the given angle about the X axis
Name Type Description radNumber angle (in radians) to rotate
Returns:
Type Description Quaternion this -
rotateY(rad){Quaternion}
-
Rotates a quaternion by the given angle about the Y axis
Name Type Description radNumber angle (in radians) to rotate
Returns:
Type Description Quaternion this -
rotateZ(rad){Quaternion}
-
Rotates a quaternion by the given angle about the Z axis
Name Type Description radNumber angle (in radians) to rotate
Returns:
Type Description Quaternion this -
calculateW(){Quaternion}
-
Calculates the W component of a quat from the X, Y, and Z components. Assumes that quaternion is 1 unit in length. Any existing W component will be ignored.
Returns:
Type Description Quaternion this -
dot(q){Number}
-
Calculates the dot product of two quat's
Name Type Description qQuaternion Returns:
Type Description Number dot product of two quat's -
lerp(q, t){Quaternion}
-
Performs a linear interpolation between two quat's
Name Type Description qQuaternion tNumber interpolation amount between the two inputs
Returns:
Type Description Quaternion this -
slerp(q, t){Quaternion}
-
Performs a spherical linear interpolation between two quat
Name Type Description qQuaternion tNumber interpolation amount between the two inputs
Returns:
Type Description Quaternion this -
sqlerp(qa, qb, qc, qd, t){Quaternion}
-
Performs a spherical linear interpolation with two control points
Name Type Description qaQuaternion qbQuaternion qcQuaternion qdQuaternion tNumber interpolation amount
Returns:
Type Description Quaternion this -
invert(){Quaternion}
-
Calculates the inverse of a quat
Returns:
Type Description Quaternion this -
conjugate(){Quaternion}
-
Calculates the conjugate of a quat If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
Returns:
Type Description Quaternion this -
length(){Number}
-
Calculates the length of a quat
Returns:
Type Description Number length of this -
squaredLength(){Number}
-
Calculates the squared length of a quat
Returns:
Type Description Number squared length of this -
normalize(){Quaternion}
-
Normalize this
Returns:
Type Description Quaternion this -
fromMat3(m){Quaternion}
-
Creates a quaternion from the given 3x3 rotation matrix.
NOTE: The resultant quaternion is not normalized, so you should be sure to renormalize the quaternion yourself where necessary.
Name Type Description mMatrix3 rotation matrix
Returns:
Type Description Quaternion this -
fromMat4(m){Quaternion}
-
Creates a quaternion from the given 3x3 rotation matrix.
NOTE: The resultant quaternion is not normalized, so you should be sure to renormalize the quaternion yourself where necessary.
Name Type Description mMatrix4 rotation matrix
Returns:
Type Description Quaternion this -
exactEquals(q){Boolean}
-
Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)
Name Type Description qQuaternion Returns:
Type Description Boolean -
equals(q){Boolean}
-
Returns whether or not the quaternions have approximately the same elements in the same position.
Name Type Description qQuaternion Returns:
Type Description Boolean -
fromEuler(euler){Quaternion}
-
Creates a quaternion from the given euler.
Name Type Description eulerEuler Returns:
Type Description Quaternion this -
mul(q)
-
Alias for
Quaternion#multiplyName Type Description qQuaternion -
len()
-
Alias for
Quaternion#length -
sqrLen()
-
Alias for
Quaternion#squaredLength