new Quaternion(xopt, yopt, zopt, wopt)
A set of 4-dimensional coordinates used to represent rotation in 3-dimensional space.
Parameters:
Name | Type | Attributes | 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. |
- Source:
- See:
-
- PackableForInterpolation
Members
(static, constant) IDENTITY :Quaternion
An immutable Quaternion instance initialized to (0.0, 0.0, 0.0, 1.0).
Type:
- Source:
(static) packedInterpolationLength :Number
The number of elements used to store the object into an array in its interpolatable form.
Type:
- Number
- Source:
(static) packedLength :Number
The number of elements used to pack the object into an array.
Type:
- Number
- Source:
(static, constant) ZERO :Quaternion
An immutable Quaternion instance initialized to (0.0, 0.0, 0.0, 0.0).
Type:
- Source:
w :Number
The W component.
Type:
- Number
- Default Value:
- 0.0
- Source:
x :Number
The X component.
Type:
- Number
- Default Value:
- 0.0
- Source:
y :Number
The Y component.
Type:
- Number
- Default Value:
- 0.0
- Source:
z :Number
The Z component.
Type:
- Number
- Default Value:
- 0.0
- Source:
Methods
(static) add(left, right, result) → {Quaternion}
Computes the componentwise sum of two quaternions.
Parameters:
Name | Type | Description |
---|---|---|
left |
Quaternion | The first quaternion. |
right |
Quaternion | The second quaternion. |
result |
Quaternion | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Quaternion
(static) clone(quaternion, resultopt) → {Quaternion}
Duplicates a Quaternion instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
quaternion |
Quaternion | The quaternion to duplicate. | |
result |
Quaternion |
<optional> |
The object onto which to store the result. |
- Source:
Returns:
The modified result parameter or a new Quaternion instance if one was not provided. (Returns undefined if quaternion is undefined)
- Type
- Quaternion
(static) computeAngle(quaternion) → {Number}
Computes the angle of rotation of the provided quaternion.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Quaternion | The quaternion to use. |
- Source:
Returns:
The angle of rotation.
- Type
- Number
(static) computeAxis(quaternion, result) → {Cartesian3}
Computes the axis of rotation of the provided quaternion.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Quaternion | The quaternion to use. |
result |
Cartesian3 | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Cartesian3
(static) computeInnerQuadrangle(q0, q1, q2, result) → {Quaternion}
Computes an inner quadrangle point.
This will compute quaternions that ensure a squad curve is C1.
Parameters:
Name | Type | Description |
---|---|---|
q0 |
Quaternion | The first quaternion. |
q1 |
Quaternion | The second quaternion. |
q2 |
Quaternion | The third quaternion. |
result |
Quaternion | The object onto which to store the result. |
- Source:
- See:
-
- Quaternion#squad
Returns:
The modified result parameter.
- Type
- Quaternion
(static) conjugate(quaternion, result) → {Quaternion}
Computes the conjugate of the provided quaternion.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Quaternion | The quaternion to conjugate. |
result |
Quaternion | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Quaternion
(static) convertPackedArrayForInterpolation(packedArray, startingIndexopt, lastIndexopt, result)
Converts a packed array into a form suitable for interpolation.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
packedArray |
Array.<Number> | The packed array. | ||
startingIndex |
Number |
<optional> |
0 | The index of the first element to be converted. |
lastIndex |
Number |
<optional> |
packedArray.length | The index of the last element to be converted. |
result |
Array.<Number> | The object into which to store the result. |
- Source:
(static) divideByScalar(quaternion, scalar, result) → {Quaternion}
Divides the provided quaternion componentwise by the provided scalar.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Quaternion | The quaternion to be divided. |
scalar |
Number | The scalar to divide by. |
result |
Quaternion | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Quaternion
(static) dot(left, right) → {Number}
Computes the dot (scalar) product of two quaternions.
Parameters:
Name | Type | Description |
---|---|---|
left |
Quaternion | The first quaternion. |
right |
Quaternion | The second quaternion. |
- Source:
Returns:
The dot product.
- Type
- Number
(static) equals(leftopt, rightopt) → {Boolean}
Compares the provided quaternions componentwise and returns
true
if they are equal, false
otherwise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
left |
Quaternion |
<optional> |
The first quaternion. |
right |
Quaternion |
<optional> |
The second quaternion. |
- Source:
Returns:
true
if left and right are equal, false
otherwise.
- Type
- Boolean
(static) equalsEpsilon(leftopt, rightopt, epsilon) → {Boolean}
Compares the provided quaternions componentwise and returns
true
if they are within the provided epsilon,
false
otherwise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
left |
Quaternion |
<optional> |
The first quaternion. |
right |
Quaternion |
<optional> |
The second quaternion. |
epsilon |
Number | The epsilon to use for equality testing. |
- Source:
Returns:
true
if left and right are within the provided epsilon, false
otherwise.
- Type
- Boolean
(static) exp(cartesian, result) → {Quaternion}
The exponential quaternion function.
Parameters:
Name | Type | Description |
---|---|---|
cartesian |
Cartesian3 | The cartesian. |
result |
Quaternion | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Quaternion
(static) fastSlerp(start, end, t, result) → {Quaternion}
Computes the spherical linear interpolation or extrapolation at t using the provided quaternions.
This implementation is faster than
Quaternion#slerp
, but is only accurate up to 10-6.
Parameters:
Name | Type | Description |
---|---|---|
start |
Quaternion | The value corresponding to t at 0.0. |
end |
Quaternion | The value corresponding to t at 1.0. |
t |
Number | The point along t at which to interpolate. |
result |
Quaternion | The object onto which to store the result. |
- Source:
- See:
-
- Quaternion#slerp
Returns:
The modified result parameter.
- Type
- Quaternion
(static) fastSquad(q0, q1, s0, s1, t, result) → {Quaternion}
Computes the spherical quadrangle interpolation between quaternions.
An implementation that is faster than
Quaternion#squad
, but less accurate.
Parameters:
Name | Type | Description |
---|---|---|
q0 |
Quaternion | The first quaternion. |
q1 |
Quaternion | The second quaternion. |
s0 |
Quaternion | The first inner quadrangle. |
s1 |
Quaternion | The second inner quadrangle. |
t |
Number | The time in [0,1] used to interpolate. |
result |
Quaternion | The object onto which to store the result. |
- Source:
- See:
-
- Quaternion#squad
Returns:
The modified result parameter or a new instance if none was provided.
- Type
- Quaternion
(static) fromAxisAngle(axis, angle, resultopt) → {Quaternion}
Computes a quaternion representing a rotation around an axis.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
axis |
Cartesian3 | The axis of rotation. | |
angle |
Number | The angle in radians to rotate around the axis. | |
result |
Quaternion |
<optional> |
The object onto which to store the result. |
- Source:
Returns:
The modified result parameter or a new Quaternion instance if one was not provided.
- Type
- Quaternion
(static) fromHeadingPitchRoll(heading, pitch, roll, resultopt) → {Quaternion}
Computes a rotation from the given heading, pitch and roll angles. Heading is the rotation about the
negative z axis. Pitch is the rotation about the negative y axis. Roll is the rotation about
the positive x axis.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
heading |
Number | The heading angle in radians. | |
pitch |
Number | The pitch angle in radians. | |
roll |
Number | The roll angle in radians. | |
result |
Quaternion |
<optional> |
The object onto which to store the result. |
- Source:
Returns:
The modified result parameter or a new Quaternion instance if none was provided.
- Type
- Quaternion
(static) fromRotationMatrix(matrix, resultopt) → {Quaternion}
Computes a Quaternion from the provided Matrix3 instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
matrix |
Matrix3 | The rotation matrix. | |
result |
Quaternion |
<optional> |
The object onto which to store the result. |
- Source:
- See:
Returns:
The modified result parameter or a new Quaternion instance if one was not provided.
- Type
- Quaternion
(static) inverse(quaternion, result) → {Quaternion}
Computes the inverse of the provided quaternion.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Quaternion | The quaternion to normalize. |
result |
Quaternion | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Quaternion
(static) lerp(start, end, t, result) → {Quaternion}
Computes the linear interpolation or extrapolation at t using the provided quaternions.
Parameters:
Name | Type | Description |
---|---|---|
start |
Quaternion | The value corresponding to t at 0.0. |
end |
Quaternion | The value corresponding to t at 1.0. |
t |
Number | The point along t at which to interpolate. |
result |
Quaternion | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Quaternion
(static) log(quaternion, result) → {Cartesian3}
The logarithmic quaternion function.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Quaternion | The unit quaternion. |
result |
Cartesian3 | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Cartesian3
(static) magnitude(quaternion) → {Number}
Computes magnitude for the provided quaternion.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Quaternion | The quaternion to conjugate. |
- Source:
Returns:
The magnitude.
- Type
- Number
(static) magnitudeSquared(quaternion) → {Number}
Computes magnitude squared for the provided quaternion.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Quaternion | The quaternion to conjugate. |
- Source:
Returns:
The magnitude squared.
- Type
- Number
(static) multiply(left, right, result) → {Quaternion}
Computes the product of two quaternions.
Parameters:
Name | Type | Description |
---|---|---|
left |
Quaternion | The first quaternion. |
right |
Quaternion | The second quaternion. |
result |
Quaternion | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Quaternion
(static) multiplyByScalar(quaternion, scalar, result) → {Quaternion}
Multiplies the provided quaternion componentwise by the provided scalar.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Quaternion | The quaternion to be scaled. |
scalar |
Number | The scalar to multiply with. |
result |
Quaternion | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Quaternion
(static) negate(quaternion, result) → {Quaternion}
Negates the provided quaternion.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Quaternion | The quaternion to be negated. |
result |
Quaternion | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Quaternion
(static) normalize(quaternion, result) → {Quaternion}
Computes the normalized form of the provided quaternion.
Parameters:
Name | Type | Description |
---|---|---|
quaternion |
Quaternion | The quaternion to normalize. |
result |
Quaternion | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Quaternion
(static) pack(value, array, startingIndexopt) → {Array.<Number>}
Stores the provided instance into the provided array.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
value |
Quaternion | The value to pack. | ||
array |
Array.<Number> | The array to pack into. | ||
startingIndex |
Number |
<optional> |
0 | The index into the array at which to start packing the elements. |
- Source:
Returns:
The array that was packed into
- Type
- Array.<Number>
(static) slerp(start, end, t, result) → {Quaternion}
Computes the spherical linear interpolation or extrapolation at t using the provided quaternions.
Parameters:
Name | Type | Description |
---|---|---|
start |
Quaternion | The value corresponding to t at 0.0. |
end |
Quaternion | The value corresponding to t at 1.0. |
t |
Number | The point along t at which to interpolate. |
result |
Quaternion | The object onto which to store the result. |
- Source:
- See:
-
- Quaternion#fastSlerp
Returns:
The modified result parameter.
- Type
- Quaternion
(static) squad(q0, q1, s0, s1, t, result) → {Quaternion}
Computes the spherical quadrangle interpolation between quaternions.
Parameters:
Name | Type | Description |
---|---|---|
q0 |
Quaternion | The first quaternion. |
q1 |
Quaternion | The second quaternion. |
s0 |
Quaternion | The first inner quadrangle. |
s1 |
Quaternion | The second inner quadrangle. |
t |
Number | The time in [0,1] used to interpolate. |
result |
Quaternion | The object onto which to store the result. |
- Source:
- See:
-
- Quaternion#computeInnerQuadrangle
Returns:
The modified result parameter.
- Type
- Quaternion
Example
// 1. compute the squad interpolation between two quaternions on a curve
var s0 = Cesium.Quaternion.computeInnerQuadrangle(quaternions[i - 1], quaternions[i], quaternions[i + 1], new Cesium.Quaternion());
var s1 = Cesium.Quaternion.computeInnerQuadrangle(quaternions[i], quaternions[i + 1], quaternions[i + 2], new Cesium.Quaternion());
var q = Cesium.Quaternion.squad(quaternions[i], quaternions[i + 1], s0, s1, t, new Cesium.Quaternion());
// 2. compute the squad interpolation as above but where the first quaternion is a end point.
var s1 = Cesium.Quaternion.computeInnerQuadrangle(quaternions[0], quaternions[1], quaternions[2], new Cesium.Quaternion());
var q = Cesium.Quaternion.squad(quaternions[0], quaternions[1], quaternions[0], s1, t, new Cesium.Quaternion());
(static) subtract(left, right, result) → {Quaternion}
Computes the componentwise difference of two quaternions.
Parameters:
Name | Type | Description |
---|---|---|
left |
Quaternion | The first quaternion. |
right |
Quaternion | The second quaternion. |
result |
Quaternion | The object onto which to store the result. |
- Source:
Returns:
The modified result parameter.
- Type
- Quaternion
(static) unpack(array, startingIndexopt, resultopt) → {Quaternion}
Retrieves an instance from a packed array.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array |
Array.<Number> | The packed array. | ||
startingIndex |
Number |
<optional> |
0 | The starting index of the element to be unpacked. |
result |
Quaternion |
<optional> |
The object into which to store the result. |
- Source:
Returns:
The modified result parameter or a new Quaternion instance if one was not provided.
- Type
- Quaternion
(static) unpackInterpolationResult(array, sourceArray, startingIndexopt, lastIndexopt, resultopt) → {Quaternion}
Retrieves an instance from a packed array converted with
convertPackedArrayForInterpolation
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array |
Array.<Number> | The array previously packed for interpolation. | ||
sourceArray |
Array.<Number> | The original packed array. | ||
startingIndex |
Number |
<optional> |
0 | The startingIndex used to convert the array. |
lastIndex |
Number |
<optional> |
packedArray.length | The lastIndex used to convert the array. |
result |
Quaternion |
<optional> |
The object into which to store the result. |
- Source:
Returns:
The modified result parameter or a new Quaternion instance if one was not provided.
- Type
- Quaternion
clone(resultopt) → {Quaternion}
Duplicates this Quaternion instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
result |
Quaternion |
<optional> |
The object onto which to store the result. |
- Source:
Returns:
The modified result parameter or a new Quaternion instance if one was not provided.
- Type
- Quaternion
equals(rightopt) → {Boolean}
Compares this and the provided quaternion componentwise and returns
true
if they are equal, false
otherwise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
right |
Quaternion |
<optional> |
The right hand side quaternion. |
- Source:
Returns:
true
if left and right are equal, false
otherwise.
- Type
- Boolean
equalsEpsilon(rightopt, epsilon) → {Boolean}
Compares this and the provided quaternion componentwise and returns
true
if they are within the provided epsilon,
false
otherwise.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
right |
Quaternion |
<optional> |
The right hand side quaternion. |
epsilon |
Number | The epsilon to use for equality testing. |
- Source:
Returns:
true
if left and right are within the provided epsilon, false
otherwise.
- Type
- Boolean
toString() → {String}
Returns a string representing this quaternion in the format (x, y, z, w).
- Source:
Returns:
A string representing this Quaternion.
- Type
- String