Sets the components of the quaternion. There are lots of different ways to specify the new components, the summary is:
- Four numbers can be used to specify an angle/axis rotation, similar to other LÖVR functions.
- Four numbers plus the fifth
raw
flag can be used to set the raw values of the quaternion.
- An existing quaternion can be passed in to copy its values.
- A single direction vector can be specified to turn its direction (relative to the default
forward direction of "negative z") into a rotation.
- Two direction vectors can be specified to set the quaternion equal to the rotation between the
two vectors.
- A matrix can be passed in to extract the rotation of the matrix into a quaternion.
Arguments
Name | Type | Default | Description |
angle | number | 0 |
The angle to use for the rotation, in radians.
|
ax | number | 0 |
The x component of the axis of rotation.
|
ay | number | 0 |
The y component of the axis of rotation.
|
az | number | 0 |
The z component of the axis of rotation.
|
raw | boolean | false |
Whether the components should be interpreted as raw (x, y, z, w) components.
|
Returns
Name | Type | Description |
self | Quat |
The modified quaternion.
|
Arguments
Name | Type | Description |
r | Quat |
An existing quaternion to copy the values from.
|
Returns
Name | Type | Description |
self | Quat |
The modified quaternion.
|
Sets the values from a direction vector.
Arguments
Name | Type | Description |
v | Vec3 |
A normalized direction vector.
|
Returns
Name | Type | Description |
self | Quat |
The modified quaternion.
|
Sets the values to represent the rotation between two vectors.
Arguments
Name | Type | Description |
v | Vec3 |
A normalized direction vector.
|
u | Vec3 |
Another normalized direction vector.
|
Returns
Name | Type | Description |
self | Quat |
The modified quaternion.
|
Arguments
Name | Type | Description |
m | Mat4 |
A matrix to use the rotation from.
|
Returns
Name | Type | Description |
self | Quat |
The modified quaternion.
|
Reset the quaternion to the identity (0, 0, 0, 1).
Arguments
None
Returns
Name | Type | Description |
self | Quat |
The modified quaternion.
|
See also