sm.quat
Associated object type: Quat
A quaternion is used to represent rotation as a generalization of complex numbers.
To create one, use sm.quat.new.
It is uncommon to modify individual X, Y, Z, W components directly.
To create a new quaternion, consider using sm.vec3.getRotation.
Functions
angleAxis
sm.quat.angleAxis( angle, axis )
Creates a new quaternion from angle and axis.
The angle is counterclockwise.
angle
[ number ]: The rotation angle in radians.axis
[ Vec3 ]: The axis vector to rotate around.
- [ Quat ]: The quaternion for rotating angle radians around an axis.
fromEuler
sm.quat.fromEuler( euler )
Create a new quaternion from an euler angle vector.
Arguments:euler
[ Vec3 ]: The euler angle vector.
- [ Quat ]: The quaternion.
getAt
sm.quat.getAt( quat )
Returns the quaternion's at vector.
This does the same as doing quat * sm.vec3.new( 0, 0, 1 )
.
quat
[ Quat ]: The quaternion.
- [ Vec3 ]: The at vector.
getRight
sm.quat.getRight( quat )
Returns the quaternion's right vector.
This does the same as doing quat * sm.vec3.new( 1, 0, 0 )
.
quat
[ Quat ]: The quaternion.
- [ Vec3 ]: The right vector.
getUp
sm.quat.getUp( quat )
Returns the quaternion's up vector.
This does the same as doing quat * sm.vec3.new( 0, 1, 0 )
.
quat
[ Quat ]: The quaternion.
- [ Vec3 ]: The up vector.
identity
sm.quat.identity()
Creates a new identity quaternion.
Returns:- [ Quat ]: The created quaternion.
inverse
sm.quat.inverse( quat )
Inverts the quaternion.
Arguments:quat
[ Quat ]: The quaternion.
- [ Quat ]: The inverted quaternion.
lookRotation
sm.quat.lookRotation( at, up )
This function is deprecated.
Creates a new quaternion from direction vectors.
Arguments:Returns:
- [ Quat ]: The quaternion.
new
sm.quat.new( x, y, z, w )
Creates a new quaternion.
Arguments:x
[ number ]: The X value.y
[ number ]: The Y value.z
[ number ]: The Z value.w
[ number ]: The W value.
- [ Quat ]: The created quaternion.
round90
sm.quat.round90( quat )
Rounds the quaternion rotation into 90 degree steps.
Arguments:quat
[ Quat ]: The quaternion.
- [ Quat ]: The rounded quaternion.
slerp
sm.quat.slerp( quat1, quat2, t )
Performs a spherical linear interpolation between two quaternion.
Arguments:quat1
[ Quat ]: The first quaternion.quat2
[ Quat ]: The second quaternion.t
[ number ]: The Interpolation amount between the two inputs.
- [ Quat ]: The interpolated quaternion.