Quat
A userdata object representing a quaternion.
Values:
-
Get: Returns the W value of a quaternion.Set: Sets the W value of a quaternion.
-
Get: Returns the X value of a quaternion.Set: Sets the X value of a quaternion.
-
Get: Returns the Y value of a quaternion.Set: Sets the Y value of a quaternion.
-
Get: Returns the Z value of a quaternion.Set: Sets the Z value of a quaternion.
Operations:
| Operation | Returns | 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. |
Functions
getAt
quat:getAt( )
Returns the quaternions at vector.
Parameters:
| Name | Type | Description |
|---|---|---|
quaternion |
Quat | The quaternion. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The at vector. |
getRight
quat:getRight( )
Returns the quaternions right vector.
Parameters:
| Name | Type | Description |
|---|---|---|
quaternion |
Quat | The quaternion. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The right vector. |
getUp
quat:getUp( )
Returns the quaternions up vector.
Parameters:
| Name | Type | Description |
|---|---|---|
quaternion |
Quat | The quaternion. |
Returns:
| Type | Description |
|---|---|
| Vec3 | The up vector. |
inverse
quat:inverse( )
Inverts the quaternion.
Parameters:
| Name | Type | Description |
|---|---|---|
quaternion |
Quat | The quaternion. |
Returns:
| Type | Description |
|---|---|
| Quat | The inverted quaternion. |
normalize
quat:normalize( )
Normalizes a quaternion, ie. converts to a unit quaternion of length 1.
Parameters:
| Name | Type | Description |
|---|---|---|
quaternion |
Quat | The quaternion. |
Returns:
| Type | Description |
|---|---|
| Quat | The normalized quaternion. |
round90
quat:round90( )
Rounds the quaternion rotation into 90 degree steps
Parameters:
| Name | Type | Description |
|---|---|---|
quaternion |
Quat | The quaternion. |
Returns:
| Type | Description |
|---|---|
| Quat | The rounded quaternion. |
safeNormalize
quat:safeNormalize( fallback )
Normalizes a quaternion with safety, ie. converts to a unit quaternion of length 1.
Parameters:
Returns:
| Type | Description |
|---|---|
| Quat | The normalized quaternion. |