Quat:set
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.
- Alternatively, a
vec3
can be used for the axis.
- 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.
q = Quat:set(angle, ax, ay, az, raw)
Arguments
Name | Type | Default | Description |
angle | | 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 |
q | quat | The original quaternion.
|
q = Quat:set(angle, axis)
Arguments
Name | Type | Default | Description |
angle | | 0 | The angle to use for the rotation, in radians.
|
axis | vec3 | | The axis of rotation (does not need to be normalized).
|
Returns
Name | Type | Description |
q | quat | The original quaternion.
|
q = Quat:set(r)
Arguments
Name | Type | Description |
r | quat | An existing quaternion to copy the values from.
|
Returns
Name | Type | Description |
q | quat | The original quaternion.
|
Sets the values from a direction vector.
q = Quat:set(v)
Arguments
Name | Type | Description |
v | vec3 | A normalized direction vector.
|
Returns
Name | Type | Description |
q | quat | The original quaternion.
|
Sets the values to represent the rotation between two vectors.
q = Quat:set(v, u)
Arguments
Name | Type | Description |
v | vec3 | A normalized direction vector.
|
u | vec3 | Another normalized direction vector.
|
Returns
Name | Type | Description |
q | quat | The original quaternion.
|
q = Quat:set(m)
Arguments
Name | Type | Description |
m | mat4 | A matrix to use the rotation from.
|
Returns
Name | Type | Description |
q | quat | The original quaternion.
|
Reset the quaternion to the identity (0, 0, 0, 1).
q = Quat:set()
Arguments
None
Returns
Name | Type | Description |
q | quat | The original quaternion.
|
See also