Methods
(static) identity() → {Quaternion}
Returns a quaternion that represents an oreintation matching
the identity matrix.
- Source:
Returns:
The identity quaternion.
- Type
- Quaternion
(static) random() → {Quaternion}
Returns a random Quaternion of unit length.
- Source:
Returns:
A random vector of unit length.
- Type
- Quaternion
(static) rotation(angle, axis) → {Quaternion}
Returns a quaternion representing the rotation defined by an axis
and an angle.
Parameters:
Name | Type | Description |
---|---|---|
angle |
number | The angle of the rotation, in radians. |
axis |
Vec3 | Array | The axis of the rotation. |
- Source:
Returns:
The quaternion representing the rotation.
- Type
- Quaternion
(static) rotationFromTo(from, to) → {Quaternion}
Returns a rotation matrix to rotate a vector from one direction to
another.
Parameters:
Name | Type | Description |
---|---|---|
from |
Vec3 | The starting direction. |
to |
Vec3 | The ending direction. |
- Source:
Returns:
The quaternion representing the rotation.
- Type
- Quaternion
(static) slerp(fromRot, toRot, t) → {Quaternion}
Returns a quaternion that has been spherically interpolated between
two provided quaternions for a given t value.
Parameters:
Name | Type | Description |
---|---|---|
fromRot |
Quaternion | The rotation at t = 0. |
toRot |
Quaternion | The rotation at t = 1. |
t |
number | The t value, from 0 to 1. |
- Source:
Returns:
The quaternion representing the interpolated rotation.
- Type
- Quaternion
axes() → {Object}
Returns the axes of the rotation matrix that the quaternion represents.
- Source:
Returns:
The axes of the matrix represented by the quaternion.
- Type
- Object
conjugate() → {Quaternion}
Returns the conjugate of the quaternion.
- Source:
Returns:
The conjugate of the quaternion.
- Type
- Quaternion
equals(that, epsilon) → {boolean}
Returns true if the vector components match those of a provided vector.
An optional epsilon value may be provided.
Parameters:
Name | Type | Description |
---|---|---|
that |
Quaternion | Array | The vector to calculate the dot product with. |
epsilon |
number | The epsilon value. Optional. |
- Source:
Returns:
Whether or not the vector components match.
- Type
- boolean
inverse() → {Quaternion}
Returns the inverse of the quaternion.
- Source:
Returns:
The inverse of the quaternion.
- Type
- Quaternion
matrix() → {Mat33}
Returns the rotation matrix that the quaternion represents.
- Source:
Returns:
The rotation matrix represented by the quaternion.
- Type
- Mat33
multQuat(that) → {Quaternion}
Concatenates the rotations of the two quaternions, returning
a new Quaternion object.
Parameters:
Name | Type | Description |
---|---|---|
that |
Quaternion | Array | The quaterion to concatenate. |
- Source:
Returns:
The resulting concatenated quaternion.
- Type
- Quaternion
negate() → {Quaternion}
Returns a new Quaternion with each component negated.
- Source:
Returns:
The negated quaternion.
- Type
- Quaternion
normalize() → {Quaternion}
Returns a new Quaternion of unit length.
- Source:
Returns:
The quaternion of unit length.
- Type
- Quaternion
rotate(that) → {Vec3}
Applies the orientation of the quaternion as a rotation
matrix to the provided vector, returning a new Vec3 object.
Parameters:
Name | Type | Description |
---|---|---|
that |
Vec3 | Vec4 | Array | The vector to rotate. |
- Source:
Returns:
The resulting rotated vector.
- Type
- Vec3
toArray() → {Array}
Returns an array representation of the quaternion.
- Source:
Returns:
The quaternion as an array.
- Type
- Array
toString() → {String}
Returns a string representation of the quaternion.
- Source:
Returns:
The string representation of the quaternion.
- Type
- String
xAxis() → {Vec3}
Returns the x-axis of the rotation matrix that the quaternion represents.
- Source:
Returns:
The x-axis of the rotation matrix represented by the quaternion.
- Type
- Vec3
yAxis() → {Vec3}
Returns the y-axis of the rotation matrix that the quaternion represents.
- Source:
Returns:
The y-axis of the rotation matrix represented by the quaternion.
- Type
- Vec3
zAxis() → {Vec3}
Returns the z-axis of the rotation matrix that the quaternion represents.
- Source:
Returns:
The z-axis of the rotation matrix represented by the quaternion.
- Type
- Vec3