lovr.math.quat

Creates a new quat. Have a look at quat:set for more information about how all these variants can be used.

Note that this function is also a table containing the __index key of the quat metatable. This means that you can add your own functions onto the lovr.math.quat table to extend the built-in functionality.

q = lovr.math.quat(angle, ax, ay, az, raw)

Arguments

NameTypeDefaultDescription
angle0The angle to use for the rotation, in radians.
axnumber0The x component of the axis of rotation.
aynumber0The y component of the axis of rotation.
aznumber0The z component of the axis of rotation.
rawbooleanfalseWhether the components should be interpreted as raw (x, y, z, w) components.

Returns

NameTypeDescription
qquatThe new quaternion.

q = lovr.math.quat(angle, axis)

Arguments

NameTypeDefaultDescription
angle0The angle to use for the rotation, in radians.
axisvec3The axis of rotation (does not need to be normalized).

Returns

NameTypeDescription
qquatThe new quaternion.

q = lovr.math.quat(r)

Arguments

NameTypeDescription
rquatAn existing quaternion to copy the values from.

Returns

NameTypeDescription
qquatThe new quaternion.

Sets the values from a direction vector.

q = lovr.math.quat(v)

Arguments

NameTypeDescription
vvec3A normalized direction vector.

Returns

NameTypeDescription
qquatThe new quaternion.

Sets the values to represent the rotation between two vectors.

q = lovr.math.quat(v, u)

Arguments

NameTypeDescription
vvec3A normalized direction vector.
uvec3Another normalized direction vector.

Returns

NameTypeDescription
qquatThe new quaternion.

q = lovr.math.quat(m)

Arguments

NameTypeDescription
mmat4A matrix to use the rotation from.

Returns

NameTypeDescription
qquatThe new quaternion.

Notes

This function takes the same arguments as quat:set.

See also