Quaternion

Quaternion

new

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.
Source:

Members

:Number

The W component.
Default Value:
  • 0.0

:Number

The X component.
Default Value:
  • 0.0

:Number

The Y component.
Default Value:
  • 0.0

:Number

The Z component.
Default Value:
  • 0.0

<static>

An immutable Quaternion instance initialized to (0.0, 0.0, 0.0, 1.0).

<static>

An immutable Quaternion instance initialized to (0.0, 0.0, 0.0, 0.0).

Methods

Computes the componentwise sum of this and the provided quaternion.

Parameters:
Name Type Argument Description
right Quaternion The right hand side quaternion.
result Quaternion <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.

Duplicates this Quaternion instance.

Parameters:
Name Type Argument Description
result Quaternion <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.

Computes the conjugate of this quaternion.

Parameters:
Name Type Argument Description
result Quaternion <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.

Divides this quaternion componentwise by the provided scalar.

Parameters:
Name Type Argument Description
scalar Number The scalar to divide by.
result Quaternion <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.

Computes the dot (scalar) product of this and the provided quaternion.

Parameters:
Name Type Description
right Quaternion The right hand side quaternion.
Throws:
DeveloperError : right is required.
Returns:
Number The dot product.

Compares this and the provided quaternion componentwise and returns true if they are equal, false otherwise.

Parameters:
Name Type Argument Description
right Quaternion <optional>
The right hand side quaternion.
Returns:
Boolean true if left and right are equal, false otherwise.

Compares this and the provided quaternion componentwise and returns true if they are within the provided epsilon, false otherwise.

Parameters:
Name Type Argument Description
right Quaternion <optional>
The right hand side quaternion.
epsilon Number The epsilon to use for equality testing.
Throws:
DeveloperError : epsilon is required and must be a number.
Returns:
Boolean true if left and right are within the provided epsilon, false otherwise.

Computes the angle of rotation of this quaternion.

Returns:
Number The angle of rotation.

Computes the axis of rotation of this quaternion.

Parameters:
Name Type Argument Description
result Cartesian3 <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.

Computes the inverse of the provided quaternion.

Parameters:
Name Type Argument Description
result Quaternion <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.

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
end The value corresponding to t at 1.0.
t The point along t at which to interpolate.
result Quaternion <optional>
The object onto which to store the result.
Throws:
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided.

Computes magnitude for this quaternion.

Returns:
Number The magnitude.

Computes magnitude squared for this quaternion.

Returns:
Number The magnitude squared.

Computes the product of this and the provided quaternion.

Parameters:
Name Type Argument Description
right Quaternion The right hande side quaternion.
result Quaternion <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.

Multiplies this quaternion componentwise by the provided scalar.

Parameters:
Name Type Argument Description
scalar Number The scalar to multiply with.
result Quaternion <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.

Negates this quaternion.

Parameters:
Name Type Argument Description
result Quaternion <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.

Computes the normalized form of this quaternion.

Parameters:
Name Type Argument Description
result Quaternion <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.

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
end The value corresponding to t at 1.0.
t The point along t at which to interpolate.
result Quaternion <optional>
The object onto which to store the result.
Throws:
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided.

Computes the componentwise difference of this and the provided quaternion.

Parameters:
Name Type Argument Description
right Quaternion The right hand side quaternion.
result Quaternion <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.

Returns a string representing this quaternion in the format (x, y, z, w).

Returns:
String A string representing this Quaternion.

<static>

Computes the componentwise sum of two quaternions.

Parameters:
Name Type Argument Description
left Quaternion The first quaternion.
right Quaternion The second quaternion.
result Quaternion <optional>
The object onto which to store the result.
Throws:
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided.

<static>

Duplicates a Quaternion instance.

Parameters:
Name Type Argument Description
quaternion Quaternion The quaternion to duplicate.
result Quaternion <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>

Computes the conjugate of the provided quaternion.

Parameters:
Name Type Argument Description
quaternion Quaternion The quaternion to conjugate.
result Quaternion <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>

Divides the provided quaternion componentwise by the provided scalar.

Parameters:
Name Type Argument Description
quaternion Quaternion The quaternion to be divided.
scalar Number The scalar to divide by.
result Quaternion <optional>
The object onto which to store the result.
Throws:
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided.

<static>

Computes the dot (scalar) product of two quaternions.

Parameters:
Name Type Description
left Quaternion The first quaternion.
right Quaternion The second quaternion.
Throws:
Returns:
Number The dot product.

<static>

Compares the provided quaternions componentwise and returns true if they are equal, false otherwise.

Parameters:
Name Type Argument Description
left Quaternion <optional>
The first quaternion.
right Quaternion <optional>
The second quaternion.
Returns:
Boolean true if left and right are equal, false otherwise.

<static>

Compares the provided quaternions componentwise and returns true if they are within the provided epsilon, false otherwise.

Parameters:
Name Type Argument Description
left Quaternion <optional>
The first quaternion.
right Quaternion <optional>
The second quaternion.
epsilon Number The epsilon to use for equality testing.
Throws:
DeveloperError : epsilon is required and must be a number.
Returns:
Boolean true if left and right are within the provided epsilon, false otherwise.

<static>

Computes a quaternion representing a rotation around an axis.

Parameters:
Name Type Argument 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.
Throws:
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided.

<static>

Computes a Quaternion from the provided Matrix3 instance.

Parameters:
Name Type Argument Description
matrix Matrix3 The rotation matrix.
result Quaternion <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.
See:

<static>

Computes the angle of rotation of the provided quaternion.

Parameters:
Name Type Description
quaternion Quaternion The quaternion to use.
Throws:
DeveloperError : quaternion is required.
Returns:
Number The angle of rotation.

<static>

Computes the axis of rotation of the provided quaternion.

Parameters:
Name Type Argument Description
quaternion Quaternion The quaternion to use.
result Cartesian3 <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>

Computes the inverse of the provided quaternion.

Parameters:
Name Type Argument Description
quaternion Quaternion The quaternion to normalize.
result Quaternion <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>

Computes the linear interpolation or extrapolation at t using the provided quaternions.

Parameters:
Name Type Argument Description
start The value corresponding to t at 0.0.
end The value corresponding to t at 1.0.
t The point along t at which to interpolate.
result Quaternion <optional>
The object onto which to store the result.
Throws:
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided.

<static>

Computes magnitude for the provided quaternion.

Parameters:
Name Type Description
quaternion Quaternion The quaternion to conjugate.
Throws:
DeveloperError : quaternion is required.
Returns:
Number The magnitude.

<static>

Computes magnitude squared for the provided quaternion.

Parameters:
Name Type Description
quaternion Quaternion The quaternion to conjugate.
Throws:
DeveloperError : quaternion is required.
Returns:
Number The magnitude squared.

<static>

Computes the product of two quaternions.

Parameters:
Name Type Argument Description
left Quaternion The first quaternion.
right Quaternion The second quaternion.
result Quaternion <optional>
The object onto which to store the result.
Throws:
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided.

<static>

Multiplies the provided quaternion componentwise by the provided scalar.

Parameters:
Name Type Argument Description
quaternion Quaternion The quaternion to be scaled.
scalar Number The scalar to multiply with.
result Quaternion <optional>
The object onto which to store the result.
Throws:
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided.

<static>

Negates the provided quaternion.

Parameters:
Name Type Argument Description
quaternion Quaternion The quaternion to be negated.
result Quaternion <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>

Computes the normalized form of the provided quaternion.

Parameters:
Name Type Argument Description
quaternion Quaternion The quaternion to normalize.
result Quaternion <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>

Computes the spherical linear interpolation or extrapolation at t using the provided quaternions.

Parameters:
Name Type Argument Description
start The value corresponding to t at 0.0.
end The value corresponding to t at 1.0.
t The point along t at which to interpolate.
result Quaternion <optional>
The object onto which to store the result.
Throws:
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided.

<static>

Computes the componentwise difference of two quaternions.

Parameters:
Name Type Argument Description
left Quaternion The first quaternion.
right Quaternion The second quaternion.
result Quaternion <optional>
The object onto which to store the result.
Throws:
Returns:
Quaternion The modified result parameter or a new Quaternion instance if one was not provided.