Quat:set

Edit

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.
``````self = Quat:set(angle, ax, ay, az, raw)
self = Quat:set(r)
self = Quat:set(v)
self = Quat:set(v, u)
self = Quat:set(m)
self = Quat:set()
``````

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).

None

Returns

 Name Type Description self quat The modified quaternion.

• `Quat:unpack`
• `Quat`