new Quaternion
A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space.
Parameters:
| Name | Type | Argument | Default | Description |
|---|---|---|---|---|
x |
Number |
<optional> |
0.0 | The X component. |
y |
Number |
<optional> |
0.0 | The Y component. |
z |
Number |
<optional> |
0.0 | The Z component. |
w |
Number |
<optional> |
0.0 | The W component. |
See:
Source:
Members
-
w :Number
-
The W component.
- Default Value:
- 0.0
-
x :Number
-
The X component.
- Default Value:
- 0.0
-
y :Number
-
The Y component.
- Default Value:
- 0.0
-
z :Number
-
The Z component.
- Default Value:
- 0.0
-
<static> IDENTITY
-
An immutable Quaternion instance initialized to (0.0, 0.0, 0.0, 1.0).
-
<static> packedInterpolationLength :Number
-
The number of elements used to store the object into an array in its interpolatable form.
-
<static> packedLength :Number
-
The number of elements used to pack the object into an array.
-
<static> ZERO
-
An immutable Quaternion instance initialized to (0.0, 0.0, 0.0, 0.0).
Methods
-
add
-
Computes the componentwise sum of this and the provided quaternion.
Parameters:
Name Type Argument Description rightQuaternion The right hand side quaternion. resultQuaternion <optional>
The object onto which to store the result. Throws:
DeveloperError : right is required.Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
clone
-
Duplicates this Quaternion instance.
Parameters:
Name Type Argument Description resultQuaternion <optional>
The object onto which to store the result. Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
conjugate
-
Computes the conjugate of this quaternion.
Parameters:
Name Type Argument Description resultQuaternion <optional>
The object onto which to store the result. Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
divideByScalar
-
Divides this quaternion componentwise by the provided scalar.
Parameters:
Name Type Argument Description scalarNumber The scalar to divide by. resultQuaternion <optional>
The object onto which to store the result. Throws:
DeveloperError : scalar is required and must be a number.Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
dot
-
Computes the dot (scalar) product of this and the provided quaternion.
Parameters:
Name Type Description rightQuaternion The right hand side quaternion. Throws:
DeveloperError : right is required.Returns:
Number The dot product. -
equals
-
Compares this and the provided quaternion componentwise and returns
trueif they are equal,falseotherwise.Parameters:
Name Type Argument Description rightQuaternion <optional>
The right hand side quaternion. Returns:
Booleantrueif left and right are equal,falseotherwise. -
equalsEpsilon
-
Compares this and the provided quaternion componentwise and returns
trueif they are within the provided epsilon,falseotherwise.Parameters:
Name Type Argument Description rightQuaternion <optional>
The right hand side quaternion. epsilonNumber The epsilon to use for equality testing. Throws:
DeveloperError : epsilon is required and must be a number.Returns:
Booleantrueif left and right are within the provided epsilon,falseotherwise. -
getAngle
-
Computes the angle of rotation of this quaternion.
Returns:
Number The angle of rotation. -
getAxis
-
Computes the axis of rotation of this quaternion.
Parameters:
Name Type Argument Description resultCartesian3 <optional>
The object onto which to store the result. Returns:
Cartesian3 The modified result parameter or a new Cartesian3 instance if one was not provided. -
inverse
-
Computes the inverse of the provided quaternion.
Parameters:
Name Type Argument Description resultQuaternion <optional>
The object onto which to store the result. Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
lerp
-
Computes the linear interpolation or extrapolation at t using the provided quaternions. This quaternion is assumed to be t at 0.0.
Parameters:
Name Type Argument Description endThe value corresponding to t at 1.0. tThe point along t at which to interpolate. resultQuaternion <optional>
The object onto which to store the result. Throws:
-
DeveloperError : end is required.
-
DeveloperError : t is required and must be a number.
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
-
magnitude
-
Computes magnitude for this quaternion.
Returns:
Number The magnitude. -
magnitudeSquared
-
Computes magnitude squared for this quaternion.
Returns:
Number The magnitude squared. -
multiply
-
Computes the product of this and the provided quaternion.
Parameters:
Name Type Argument Description rightQuaternion The right hande side quaternion. resultQuaternion <optional>
The object onto which to store the result. Throws:
DeveloperError : right is required.Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
multiplyByScalar
-
Multiplies this quaternion componentwise by the provided scalar.
Parameters:
Name Type Argument Description scalarNumber The scalar to multiply with. resultQuaternion <optional>
The object onto which to store the result. Throws:
DeveloperError : scalar is required and must be a number.Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
negate
-
Negates this quaternion.
Parameters:
Name Type Argument Description resultQuaternion <optional>
The object onto which to store the result. Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
normalize
-
Computes the normalized form of this quaternion.
Parameters:
Name Type Argument Description resultQuaternion <optional>
The object onto which to store the result. Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
slerp
-
Computes the spherical linear interpolation or extrapolation at t using the provided quaternions. This quaternion is assumed to be t at 0.0.
Parameters:
Name Type Argument Description endThe value corresponding to t at 1.0. tThe point along t at which to interpolate. resultQuaternion <optional>
The object onto which to store the result. Throws:
-
DeveloperError : end is required.
-
DeveloperError : t is required and must be a number.
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
-
subtract
-
Computes the componentwise difference of this and the provided quaternion.
Parameters:
Name Type Argument Description rightQuaternion The right hand side quaternion. resultQuaternion <optional>
The object onto which to store the result. Throws:
DeveloperError : right is required.Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
toString
-
Returns a string representing this quaternion in the format (x, y, z, w).
Returns:
String A string representing this Quaternion. -
<static> add
-
Computes the componentwise sum of two quaternions.
Parameters:
Name Type Argument Description leftQuaternion The first quaternion. rightQuaternion The second quaternion. resultQuaternion <optional>
The object onto which to store the result. Throws:
-
DeveloperError : left is required.
-
DeveloperError : right is required.
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
-
<static> clone
-
Duplicates a Quaternion instance.
Parameters:
Name Type Argument Description quaternionQuaternion The quaternion to duplicate. resultQuaternion <optional>
The object onto which to store the result. Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. (Returns undefined if quaternion is undefined) -
<static> conjugate
-
Computes the conjugate of the provided quaternion.
Parameters:
Name Type Argument Description quaternionQuaternion The quaternion to conjugate. resultQuaternion <optional>
The object onto which to store the result. Throws:
DeveloperError : quaternion is required.Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
<static> convertPackedArrayForInterpolation
-
Converts a packed array into a form suitable for interpolation.
Parameters:
Name Type Argument Default Description packedArrayArray The packed array. startingIndexNumber <optional>
0 The index of the first element to be converted. lastIndexNumber <optional>
packedArray.length The index of the last element to be converted. resultArray <optional>
The object into which to store the result. Throws:
DeveloperError : packedArray is required. -
<static> divideByScalar
-
Divides the provided quaternion componentwise by the provided scalar.
Parameters:
Name Type Argument Description quaternionQuaternion The quaternion to be divided. scalarNumber The scalar to divide by. resultQuaternion <optional>
The object onto which to store the result. Throws:
-
DeveloperError : quaternion is required.
-
DeveloperError : scalar is required and must be a number.
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
-
<static> dot
-
Computes the dot (scalar) product of two quaternions.
Parameters:
Name Type Description leftQuaternion The first quaternion. rightQuaternion The second quaternion. Throws:
-
DeveloperError : left is required.
-
DeveloperError : right is required.
Returns:
Number The dot product. -
-
<static> equals
-
Compares the provided quaternions componentwise and returns
trueif they are equal,falseotherwise.Parameters:
Name Type Argument Description leftQuaternion <optional>
The first quaternion. rightQuaternion <optional>
The second quaternion. Returns:
Booleantrueif left and right are equal,falseotherwise. -
<static> equalsEpsilon
-
Compares the provided quaternions componentwise and returns
trueif they are within the provided epsilon,falseotherwise.Parameters:
Name Type Argument Description leftQuaternion <optional>
The first quaternion. rightQuaternion <optional>
The second quaternion. epsilonNumber The epsilon to use for equality testing. Throws:
DeveloperError : epsilon is required and must be a number.Returns:
Booleantrueif left and right are within the provided epsilon,falseotherwise. -
<static> fromAxisAngle
-
Computes a quaternion representing a rotation around an axis.
Parameters:
Name Type Argument Description axisCartesian3 The axis of rotation. angleNumber The angle in radians to rotate around the axis. resultQuaternion <optional>
The object onto which to store the result. Throws:
-
DeveloperError : axis is required.
-
DeveloperError : angle is required and must be a number.
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
-
<static> fromRotationMatrix
-
Computes a Quaternion from the provided Matrix3 instance.
Parameters:
Name Type Argument Description matrixMatrix3 The rotation matrix. resultQuaternion <optional>
The object onto which to store the result. Throws:
DeveloperError : matrix is required.Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
<static> getAngle
-
Computes the angle of rotation of the provided quaternion.
Parameters:
Name Type Description quaternionQuaternion The quaternion to use. Throws:
DeveloperError : quaternion is required.Returns:
Number The angle of rotation. -
<static> getAxis
-
Computes the axis of rotation of the provided quaternion.
Parameters:
Name Type Argument Description quaternionQuaternion The quaternion to use. resultCartesian3 <optional>
The object onto which to store the result. Throws:
DeveloperError : quaternion is required.Returns:
Cartesian3 The modified result parameter or a new Cartesian3 instance if one was not provided. -
<static> inverse
-
Computes the inverse of the provided quaternion.
Parameters:
Name Type Argument Description quaternionQuaternion The quaternion to normalize. resultQuaternion <optional>
The object onto which to store the result. Throws:
DeveloperError : quaternion is required.Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
<static> lerp
-
Computes the linear interpolation or extrapolation at t using the provided quaternions.
Parameters:
Name Type Argument Description startThe value corresponding to t at 0.0. endThe value corresponding to t at 1.0. tThe point along t at which to interpolate. resultQuaternion <optional>
The object onto which to store the result. Throws:
-
DeveloperError : start is required.
-
DeveloperError : end is required.
-
DeveloperError : t is required and must be a number.
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
-
<static> magnitude
-
Computes magnitude for the provided quaternion.
Parameters:
Name Type Description quaternionQuaternion The quaternion to conjugate. Throws:
DeveloperError : quaternion is required.Returns:
Number The magnitude. -
<static> magnitudeSquared
-
Computes magnitude squared for the provided quaternion.
Parameters:
Name Type Description quaternionQuaternion The quaternion to conjugate. Throws:
DeveloperError : quaternion is required.Returns:
Number The magnitude squared. -
<static> multiply
-
Computes the product of two quaternions.
Parameters:
Name Type Argument Description leftQuaternion The first quaternion. rightQuaternion The second quaternion. resultQuaternion <optional>
The object onto which to store the result. Throws:
-
DeveloperError : left is required.
-
DeveloperError : right is required.
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
-
<static> multiplyByScalar
-
Multiplies the provided quaternion componentwise by the provided scalar.
Parameters:
Name Type Argument Description quaternionQuaternion The quaternion to be scaled. scalarNumber The scalar to multiply with. resultQuaternion <optional>
The object onto which to store the result. Throws:
-
DeveloperError : quaternion is required.
-
DeveloperError : scalar is required and must be a number.
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
-
<static> negate
-
Negates the provided quaternion.
Parameters:
Name Type Argument Description quaternionQuaternion The quaternion to be negated. resultQuaternion <optional>
The object onto which to store the result. Throws:
DeveloperError : quaternion is required.Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
<static> normalize
-
Computes the normalized form of the provided quaternion.
Parameters:
Name Type Argument Description quaternionQuaternion The quaternion to normalize. resultQuaternion <optional>
The object onto which to store the result. Throws:
DeveloperError : quaternion is required.Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
<static> pack
-
Stores the provided instance into the provided array.
Parameters:
Name Type Argument Default Description valueQuaternion The value to pack. arrayArray The array to pack into. startingIndexNumber <optional>
0 The index into the array at which to start packing the elements. Throws:
-
DeveloperError : value is required.
-
DeveloperError : array is required.
-
-
<static> slerp
-
Computes the spherical linear interpolation or extrapolation at t using the provided quaternions.
Parameters:
Name Type Argument Description startThe value corresponding to t at 0.0. endThe value corresponding to t at 1.0. tThe point along t at which to interpolate. resultQuaternion <optional>
The object onto which to store the result. Throws:
-
DeveloperError : start is required.
-
DeveloperError : end is required.
-
DeveloperError : t is required and must be a number.
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
-
<static> subtract
-
Computes the componentwise difference of two quaternions.
Parameters:
Name Type Argument Description leftQuaternion The first quaternion. rightQuaternion The second quaternion. resultQuaternion <optional>
The object onto which to store the result. Throws:
-
DeveloperError : left is required.
-
DeveloperError : right is required.
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided. -
-
<static> unpack
-
Retrieves an instance from a packed array.
Parameters:
Name Type Argument Default Description arrayArray The packed array. startingIndexNumber <optional>
0 The starting index of the element to be unpacked. resultQuaternion <optional>
The object into which to store the result. Throws:
DeveloperError : array is required. -
<static> unpackInterpolationResult
-
Retrieves an instance from a packed array converted with convertPackedArrayForInterpolation.
Parameters:
Name Type Argument Default Description arrayArray The original packed array. sourceArrayArray The converted array. startingIndexNumber <optional>
0 The startingIndex used to convert the array. lastIndexNumber <optional>
packedArray.length The lastIndex used to convert the array. resultQuaternion <optional>
The object into which to store the result. Throws:
-
DeveloperError : array is required.
-
DeveloperError : sourceArray is required.
-
