Quat
Associated namespace: sm.quat
A userdata object representing a quaternion.
Values:
Functions:
Operations:
| Operation | Return type | Description |
|---|---|---|
| Quat == Quat | boolean | Checks if two quaternions are equal. |
| Quat * Quat | Quat | Returns the Hamilton product of two quaternions. |
| Quat * Vec3 | Vec3 | Returns the rotation by a quaternion on a vector. |
w number
Get:
Returns the W value of a quaternion.
Set:
Sets the W value of a quaternion.
x number
Get:
Returns the X value of a quaternion.
Set:
Sets the X value of a quaternion.
y number
Get:
Returns the Y value of a quaternion.
Set:
Sets the Y value of a quaternion.
z number
Get:
Returns the Z value of a quaternion.
Set:
Sets the Z value of a quaternion.
getAt(quaternion)
Returns the quaternions at vector.
Parameters:
| Type | Name | Description |
|---|---|---|
| Quat | quaternion | The quaternion. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The at vector. |
getRight(quaternion)
Returns the quaternions right vector.
Parameters:
| Type | Name | Description |
|---|---|---|
| Quat | quaternion | The quaternion. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The right vector. |
getUp(quaternion)
Returns the quaternions up vector.
Parameters:
| Type | Name | Description |
|---|---|---|
| Quat | quaternion | The quaternion. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The up vector. |
inverse(quaternion)
Inverts the quaternion.
Parameters:
| Type | Name | Description |
|---|---|---|
| Quat | quaternion | The quaternion. |
Returns:
| Type | Description |
|---|---|
| Quat | The inverted quaternion. |
normalize(quaternion)
Normalizes a quaternion, ie. converts to a unit quaternion of length 1.
Parameters:
| Type | Name | Description |
|---|---|---|
| Quat | quaternion | The quaternion. |
Returns:
| Type | Description |
|---|---|
| Quat | The normalized quaternion. |
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. |
safeNormalize(quaternion, fallback)
Normalizes a quaternion with safety, ie. converts to a unit quaternion of length 1.
Parameters:
| Type | Name | Description |
|---|---|---|
| Quat | quaternion | The quaternion. |
| Quat | fallback | The fallback quaternion |
Returns:
| Type | Description |
|---|---|
| Quat | The normalized quaternion. |