sm.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
sm.quat.angleAxis( angle, axis )
Creates a new quaternion from angle and axis.
Parameters:
| Name | Type | Description |
|---|---|---|
angle |
number | The rotation angle in radians. |
axis |
Vec3 | The axis vector to rotate around. |
Returns:
| Type | Description |
|---|---|
| Quat | The quaternion for rotating angle radians around axis. |
fromEuler
sm.quat.fromEuler( euler )
Create a new quaternion from an euler angle vector.
Parameters:
| Name | Type | Description |
|---|---|---|
euler |
Vec3 | The euler angle vector. |
Returns:
| Type | Description |
|---|---|
| Quat | The quaternion. |
identity
sm.quat.identity( )
Creates a new identity quaternion.
Returns:
| Type | Description |
|---|---|
| Quat | The created quaternion. |
lookRotation
sm.quat.lookRotation( at, up )
Create a new quaternion from direction vectors. DEPRECATED
Parameters:
Returns:
| Type | Description |
|---|---|
| Quat | The quaternion. |
new - Quat
sm.quat.new( quaternion )
Creates a new quaternion.
Parameters:
| Name | Type | Description |
|---|---|---|
quaternion |
Quat | The original quaternion. |
Returns:
| Type | Description |
|---|---|
| Quat | The created quaternion. |
new - number
sm.quat.new( x, y, z, w )
Creates a new quaternion.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | The X value. |
y |
number | The Y value. |
z |
number | The Z value. |
w |
number | The W value. |
Returns:
| Type | Description |
|---|---|
| Quat | The created quaternion. |
rotNegX90
sm.quat.rotNegX90( )
Returns the rotation constant for rotating -90 degrees around the X-axis.
Returns:
| Type | Description |
|---|---|
| Quat | The rotation quaternion. |
rotNegY90
sm.quat.rotNegY90( )
Returns the rotation constant for rotating -90 degrees around the Y-axis.
Returns:
| Type | Description |
|---|---|
| Quat | The rotation quaternion. |
rotNegZ90
sm.quat.rotNegZ90( )
Returns the rotation constant for rotating -90 degrees around the Z-axis.
Returns:
| Type | Description |
|---|---|
| Quat | The rotation quaternion. |
rotX180
sm.quat.rotX180( )
Returns the rotation constant for rotating 180 degrees around the X-axis.
Returns:
| Type | Description |
|---|---|
| Quat | The rotation quaternion. |
rotX90
sm.quat.rotX90( )
Returns the rotation constant for rotating 90 degrees around the X-axis.
Returns:
| Type | Description |
|---|---|
| Quat | The rotation quaternion. |
rotY180
sm.quat.rotY180( )
Returns the rotation constant for rotating 180 degrees around the Y-axis.
Returns:
| Type | Description |
|---|---|
| Quat | The rotation quaternion. |
rotY90
sm.quat.rotY90( )
Returns the rotation constant for rotating 90 degrees around the Y-axis.
Returns:
| Type | Description |
|---|---|
| Quat | The rotation quaternion. |
rotZ180
sm.quat.rotZ180( )
Returns the rotation constant for rotating 180 degrees around the Z-axis.
Returns:
| Type | Description |
|---|---|
| Quat | The rotation quaternion. |
rotZ90
sm.quat.rotZ90( )
Returns the rotation constant for rotating 90 degrees around the Z-axis.
Returns:
| Type | Description |
|---|---|
| Quat | The rotation quaternion. |
slerp
sm.quat.slerp( quaternion1, quaternion2, t )
Performs a spherical linear interpolation between two quaternion.
Parameters:
| Name | Type | Description |
|---|---|---|
quaternion1 |
Quat | The first quaternion. |
quaternion2 |
Quat | The second quaternion. |
t |
number | Interpolation amount between the two inputs. |
Returns:
| Type | Description |
|---|---|
| Quat | The interpolated quaternion. |