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 identity lookRotation new new rotNegX90 rotNegY90 rotNegZ90 rotX180 rotX90 rotY180 rotY90 rotZ180 rotZ90 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.identity()
Creates a new identity quaternion.
Returns:
| Type | Description |
| Quat | The created 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(quaternion)
Creates a new quaternion.
Parameters:
| Type | Name | Description |
| Quat | quaternion | The original quaternion. |
Returns:
| Type | Description |
| Quat | The created 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.rotNegX90()
Returns the rotation constant for rotating -90 degrees around the X-axis.
Returns:
| Type | Description |
| Quat | The rotation quaternion. |
sm.quat.rotNegY90()
Returns the rotation constant for rotating -90 degrees around the Y-axis.
Returns:
| Type | Description |
| Quat | The rotation quaternion. |
sm.quat.rotNegZ90()
Returns the rotation constant for rotating -90 degrees around the Z-axis.
Returns:
| Type | Description |
| Quat | The rotation quaternion. |
sm.quat.rotX180()
Returns the rotation constant for rotating 180 degrees around the X-axis.
Returns:
| Type | Description |
| Quat | The rotation quaternion. |
sm.quat.rotX90()
Returns the rotation constant for rotating 90 degrees around the X-axis.
Returns:
| Type | Description |
| Quat | The rotation quaternion. |
sm.quat.rotY180()
Returns the rotation constant for rotating 180 degrees around the Y-axis.
Returns:
| Type | Description |
| Quat | The rotation quaternion. |
sm.quat.rotY90()
Returns the rotation constant for rotating 90 degrees around the Y-axis.
Returns:
| Type | Description |
| Quat | The rotation quaternion. |
sm.quat.rotZ180()
Returns the rotation constant for rotating 180 degrees around the Z-axis.
Returns:
| Type | Description |
| Quat | The rotation quaternion. |
sm.quat.rotZ90()
Returns the rotation constant for rotating 90 degrees around the Z-axis.
Returns:
| Type | Description |
| Quat | The rotation 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. |