new Quaternion(x, y, z, w)
A set of four-dimensional coordinates used to represent rotation in three-dimensional space.
| Name | Type | Default | Description |
|---|---|---|---|
x |
Number | 0.0 |
optional
Part X. |
y |
Number | 0.0 |
optional
Part Y. |
z |
Number | 0.0 |
optional
Part Z. |
w |
Number | 0.0 |
optional
Part W. |
- See:
-
- PackableForInterpolation
Members
-
(static, constant) IDENTITYQuaternion
-
Initialize as an immutable quaternion instance of (0.0, 0.0, 0.0, 1.0).
-
static packedInterpolationLengthNumber
-
The number of elements used to store objects in an array in an interpolated form.
-
static packedLengthNumber
-
The number of elements used to package an object into an array.
-
(static, constant) ZEROQuaternion
-
Initialize as an immutable quaternion instance of (0.0, 0.0, 0.0, 0.0).
-
wNumber
-
Part W.
- Default Value: 0.0
xNumber
Part X.
- Default Value: 0.0
yNumber
Part Y.
- Default Value: 0.0
zNumber
Part Z.
- Default Value: 0.0
Methods
-
static add(left, right, result){Quaternion}
-
Calculate the sum of the components of two quaternions.
Name Type Description leftQuaternion The first quaternion.
rightQuaternion The second quaternion.
resultQuaternion The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters. -
static clone(quaternion, result){Quaternion}
-
Copy quaternion instances.
Name Type Description quaternionQuaternion The quaternion to be copied.
resultQuaternion optional The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters, or a new quaternion instance (if no quaternion instance is provided). If the quaternion is undefined, return undefined. -
static computeAngle(quaternion){Number}
-
Calculate the rotation angle of the provided quaternion.
Name Type Description quaternionQuaternion The quaternion to be used.
Returns:
Type Description Number Rotation angle. -
static computeAxis(quaternion, result){Cartesian3}
-
Calculate the rotation axis of the quaternion provided.
Name Type Description quaternionQuaternion The quaternion to be used.
resultCartesian3 The object that stores the results.
Returns:
Type Description Cartesian3 The modified result parameters. -
static computeInnerQuadrangle(q0, q1, q2, result){Quaternion}
-
Calculate an inner quadrilateral point. This will calculate quaternions to ensure that the lineup curve is C1.
Name Type Description q0Quaternion The first quaternion.
q1Quaternion The second quaternion.
q2Quaternion The third quaternion.
resultQuaternion The object that stores the results.
- See:
-
- Quaternion#squad
Returns:
Type Description Quaternion The modified result parameters. -
static conjugate(quaternion, result){Quaternion}
-
Calculate the conjugate number of the quaternion provided.
Name Type Description quaternionQuaternion A quaternion used for conjugation.
resultQuaternion The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters. -
static convertPackedArrayForInterpolation(packedArray, startingIndex, lastIndex, result)
-
Convert the packaged array into a form suitable for interpolation.
Name Type Default Description packedArrayArray.<Number> Package the array.
startingIndexNumber 0 optional The index of the first element to be converted.
lastIndexNumber packedArray.length optional The index of the last element to be converted.
resultArray.<Number> The object in which to store the results.
-
static divideByScalar(quaternion, scalar, result){Quaternion}
-
Divide the provided scalar component by the provided quaternion.
Name Type Description quaternionQuaternion The quaternion to be divided.
scalarNumber The scalar to be divided by.
resultQuaternion The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters. -
static dot(left, right){Number}
-
Calculate the point (scalar) product of two quaternions.
Name Type Description leftQuaternion The first quaternion.
rightQuaternion The second quaternion.
Returns:
Type Description Number Dot product. -
static equals(left, right){Boolean}
-
Compare the components of the provided quaternions, return true if they are equal, otherwise return false.
Name Type Description leftQuaternion optional The first quaternion.
rightQuaternion optional The second quaternion.
Returns:
Type Description Boolean If they are equal, it is true; otherwise, it is false. -
static equalsEpsilon(left, right, epsilon){Boolean}
-
Compare the components of the provided quaternions, return true if they are within the provided range of ε, otherwise return false.
Name Type Description leftQuaternion optional The first quaternion.
rightQuaternion optional The second quaternion.
epsilonNumber Tolerance values used for equation testing.
Returns:
Type Description Boolean If within the provided tolerance range, it is true; Otherwise, it is false. -
static exp(cartesian, result){Quaternion}
-
Exponential quaternion function.
Name Type Description cartesianCartesian3 cartesian。
resultQuaternion The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters. -
static fastSlerp(start, end, t, result){Quaternion}
-
Calculate spherical linear interpolation or extrapolation at t using the provided quaternions. This implementation is faster than Quaternion # slip, but can only be precise to 10-6.
Name Type Description startQuaternion Corresponding to the value of t at 0.0.
endQuaternion Corresponding to the value of t at 1.0.
tNumber The point interpolated along t.
resultQuaternion The object that stores the results.
- See:
-
- Quaternion#slerp
Returns:
Type Description Quaternion The modified result parameters. -
static fastSquad(q0, q1, s0, s1, t, result){Quaternion}
-
Calculate the spherical quadrilateral interpolation between quaternions. A faster implementation than Quaternion # squad, but not very accurate.
Name Type Description q0Quaternion The first quaternion.
q1Quaternion The second quaternion.
s0Quaternion The first quadrilateral.
s1Quaternion The second quadrilateral.
tNumber The time used for interpolation in [0,1].
resultQuaternion The object that stores the results.
- See:
-
- Quaternion#squad
Returns:
Type Description Quaternion The modified result parameters, if not provided, will be a new instance. -
static fromAxisAngle(axis, angle, result){Quaternion}
-
Calculate the quaternion representing rotation around an axis.
Name Type Description axisCartesian3 Rotating axis.
angleNumber The angle of rotation around the axis (in radians).
resultQuaternion optional The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters, or a new quaternion instance (if not provided). -
static fromHeadingPitchRoll(headingPitchRoll, result){Quaternion}
-
Calculate the rotation angle based on the given azimuth, elevation, and roll angles. The azimuth angle is the rotation around the negative Z-axis. The pitch angle is the rotation angle around the negative y-axis. Rolling is the rotation around the positive x-axis.
Name Type Description headingPitchRollHeadingPitchRoll Rotation represented by azimuth, pitch, and roll.
resultQuaternion optional The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters, or a new quaternion instance (if not provided). -
static fromRotationMatrix(matrix, result){Quaternion}
-
Calculate quaternions based on the provided Matrix3 instance.
Name Type Description matrixMatrix3 Rotation matrix
resultQuaternion optional The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters, or a new quaternion instance (if not provided). -
static inverse(quaternion, result){Quaternion}
-
Calculate the inverse of the quaternion provided.
Name Type Description quaternionQuaternion To standardize quaternions.
resultQuaternion The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters. -
static lerp(start, end, t, result){Quaternion}
-
Calculate the linear interpolation or extrapolation value at t using the provided quaternions.
Name Type Description startQuaternion The value corresponding to t at 0.0.
endQuaternion The value corresponding to t=1.0.
tNumber The point interpolated along t.
resultQuaternion The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters. -
static log(quaternion, result){Cartesian3}
-
Logarithmic quaternion function.
Name Type Description quaternionQuaternion Unit quaternion.
resultCartesian3 The object that stores the results.
Returns:
Type Description Cartesian3 The modified result parameters. -
static magnitude(quaternion){Number}
-
Calculate the magnitude of the quaternion provided.
Name Type Description quaternionQuaternion To conjugate quaternions.
Returns:
Type Description Number The magnitude. -
static magnitudeSquared(quaternion){Number}
-
Calculate the square of the amplitude of the quaternion provided.
Name Type Description quaternionQuaternion To conjugate quaternions.
Returns:
Type Description Number The square of the amplitude. -
static multiply(left, right, result){Quaternion}
-
Calculate the product of two quaternions.
Name Type Description leftQuaternion The first quaternion.
rightQuaternion The second quaternion.
resultQuaternion The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters. -
static multiplyByScalar(quaternion, scalar, result){Quaternion}
-
Multiply the provided quaternion by the provided scalar as a component.
Name Type Description quaternionQuaternion The quaternion to be scaled.
scalarNumber The scalar to be multiplied with.
resultQuaternion The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters. -
static negate(quaternion, result){Quaternion}
-
Deny the quaternion provided.
Name Type Description quaternionQuaternion The quaternion to be negated.
resultQuaternion The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters. -
static normalize(quaternion, result){Quaternion}
-
Calculate the standardized form of the quaternion provided.
Name Type Description quaternionQuaternion To standardize quaternions.
resultQuaternion The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters. -
static pack(value, array, startingIndex){Array.<Number>}
-
Store the provided instance in the provided array.
Name Type Default Description valueQuaternion The value to be packaged.
arrayArray.<Number> The array to be loaded.
startingIndexNumber 0 optional Start packaging the array index of elements.
Returns:
Type Description Array.<Number> The array that has been loaded. -
static slerp(start, end, t, result){Quaternion}
-
Calculate the spherical linear interpolation or extrapolation at t using the provided quaternions.
Name Type Description startQuaternion The value corresponding to t at 0.0.
endQuaternion The value corresponding to t=1.0.
tNumber The point interpolated along t.
resultQuaternion The object that stores the results.
- See:
-
- Quaternion#fastSlerp
Returns:
Type Description Quaternion The modified result parameters. -
static squad(q0, q1, s0, s1, t, result){Quaternion}
-
Calculate the spherical quaternion interpolation between quaternions.
Name Type Description q0Quaternion The first quaternion.
q1Quaternion The second quaternion.
s0Quaternion The first quadrilateral.
s1Quaternion The second quadrilateral.
tNumber The time used for interpolation in [0,1].
resultQuaternion The object that stores the results.
- See:
-
- Quaternion#computeInnerQuadrangle
Returns:
Type Description Quaternion The modified result parameters. Example
// 1. compute the squad interpolation between two quaternions on a curve var s0 = SuperMap3D.Quaternion.computeInnerQuadrangle(quaternions[i - 1], quaternions[i], quaternions[i + 1], new SuperMap3D.Quaternion()); var s1 = SuperMap3D.Quaternion.computeInnerQuadrangle(quaternions[i], quaternions[i + 1], quaternions[i + 2], new SuperMap3D.Quaternion()); var q = SuperMap3D.Quaternion.squad(quaternions[i], quaternions[i + 1], s0, s1, t, new SuperMap3D.Quaternion()); // 2. compute the squad interpolation as above but where the first quaternion is a end point. var s1 = SuperMap3D.Quaternion.computeInnerQuadrangle(quaternions[0], quaternions[1], quaternions[2], new SuperMap3D.Quaternion()); var q = SuperMap3D.Quaternion.squad(quaternions[0], quaternions[1], quaternions[0], s1, t, new SuperMap3D.Quaternion()); -
static subtract(left, right, result){Quaternion}
-
Calculate the difference between the components of two quaternions.
Name Type Description leftQuaternion The first quaternion.
rightQuaternion The second quaternion.
resultQuaternion The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters. -
static unpack(array, startingIndex, result){Quaternion}
-
Retrieve instances from the packaged array.
Name Type Default Description arrayArray.<Number> Package the array.
startingIndexNumber 0 optional The starting index of the element to be decompressed.
resultQuaternion optional The object in which to store the results.
Returns:
Type Description Quaternion The modified result parameters or a new Quaternion instance (if not provided). -
static unpackInterpolationResult(array, sourceArray, firstIndex, lastIndex, result){Quaternion}
-
Read instances from the packaged array converted using convertPackedArrayForInterpolation.
Name Type Default Description arrayArray.<Number> The array previously packaged for interpolation.
sourceArrayArray.<Number> The original packaging array.
firstIndexNumber 0 optional The firstIndex used when converting arrays.
lastIndexNumber packedArray.length optional Used to convert the last index of an array.
resultQuaternion optional The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters, or a new quaternion instance (if not provided). -
clone(result){Quaternion}
-
Copy this quaternion instance.
Name Type Description resultQuaternion optional The object that stores the results.
Returns:
Type Description Quaternion The modified result parameters, or a new quaternion instance (if not provided). -
equals(right){Boolean}
-
Compare the components of this quaternion with the provided quaternion. If they are equal, return true; otherwise, return false.
Name Type Description rightQuaternion optional The quaternion on the right.
Returns:
Type Description Boolean If they are equal, it is true; otherwise, it is false. -
equalsEpsilon(right, epsilon){Boolean}
-
Compare the components of this quaternion with the provided quaternion, return true if within the provided tolerance range, otherwise return false.
Name Type Description rightQuaternion optional The quaternion on the right.
epsilonNumber Tolerance values used for equation testing.
Returns:
Type Description Boolean If within the provided tolerance range, it is true; Otherwise, it is false. -
toString(){String}
-
Return a string representing this quaternion in the format (x, y, z, w).
Returns:
Type Description String The string representing this quaternion.