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.
Warning:
It is uncommon to modify individual X, Y, Z, W components directly. To create a new quaternion, consider using sm.vec3.getRotation.
Functions:
angleAxis fromEuler getAt getRight getUp identity inverse lookRotation new round90 slerp
sm.quat.angleAxis(angle, axis)
Creates a new quaternion from angle and axis.
Parameters:
Type | Name | Description |
number | angle | The rotation angle in radians. |
Vec3 | axis | The axis vector to rotate around. |
Returns:
Type | Description |
Quat | The quaternion for rotating angle radians around axis. |
sm.quat.fromEuler(euler)
Create a new quaternion from an euler angle vector.
Parameters:
Type | Name | Description |
Vec3 | euler | The euler angle vector. |
Returns:
Type | Description |
Quat | The quaternion. |
sm.quat.getAt(quaternion)
Returns the quaternions at vector.
Parameters:
Type | Name | Description |
Quat | quaternion | The quaternion. |
Returns:
Type | Description |
Vec3 | The at vector. |
sm.quat.getRight(quaternion)
Returns the quaternions right vector.
Parameters:
Type | Name | Description |
Quat | quaternion | The quaternion. |
Returns:
Type | Description |
Vec3 | The right vector. |
sm.quat.getUp(quaternion)
Returns the quaternions up vector.
Parameters:
Type | Name | Description |
Quat | quaternion | The quaternion. |
Returns:
Type | Description |
Vec3 | The up vector. |
sm.quat.identity()
Creates a new identity quaternion.
Returns:
Type | Description |
Quat | The created quaternion. |
sm.quat.inverse(quaternion)
Inverts the quaternion.
Parameters:
Type | Name | Description |
Quat | quaternion | The quaternion. |
Returns:
Type | Description |
Quat | The inverted quaternion. |
sm.quat.lookRotation(at, up)
Create a new quaternion from direction vectors. DEPRECATED
Parameters:
Type | Name | Description |
Vec3 | at | The forward vector. |
Vec3 | up | The up vector. |
Returns:
Type | Description |
Quat | The quaternion. |
sm.quat.new(x, y, z, w)
Creates a new quaternion.
Parameters:
Type | Name | Description |
number | x | The X value. |
number | y | The Y value. |
number | z | The Z value. |
number | w | The W value. |
Returns:
Type | Description |
Quat | The created quaternion. |
sm.quat.round90(quaternion)
Rounds the quaternion rotation into 90 degree steps
Parameters:
Type | Name | Description |
Quat | quaternion | The quaternion. |
Returns:
Type | Description |
Quat | The rounded quaternion. |
sm.quat.slerp(quaternion1, quaternion2, t)
Performs a spherical linear interpolation between two quaternion.
Parameters:
Type | Name | Description |
Quat | quaternion1 | The first quaternion. |
Quat | quaternion2 | The second quaternion. |
number | t | Interpolation amount between the two inputs. |
Returns:
Type | Description |
Quat | The interpolated quaternion. |