🧭 Rotator
A container for rotation information (Pitch, Yaw, Roll). All rotation values are stored in degrees.
👐Open Source
This library implementation is Open Sourced on GitHub!
🧑💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!
info
Rotators are internally and automatically compressed, which reduces it's size in the network up to 90%. Their components are usually compressed into 1 byte each (with some exceptions which we need more precision).
🎒 Examples
local new_rotator = Rotator(-90, 153, 24.5)
🛠 Constructors
Default Constructor
No description provided
local my_rotator = Rotator(pitch?, yaw?, roll?)
🧽 Properties
| Type | Name | Description |
|---|---|---|
| number | Pitch | Rotation around the right axis (around Y axis), Looking up and down (0=Straight Ahead, +Up, -Down) |
| number | Yaw | Rotation around the up axis (around Z axis), Running in circles 0=East, +North, -South. |
| number | Roll | Rotation around the forward axis (around X axis), Tilting your head, 0=Straight, +Clockwise, -CCW. |
🦠 Functions
info
This structure supports +, -, * and tostring operations.
| Returns | Name | Description | |
|---|---|---|---|
| Vector | GetForwardVector | Get the forward (X) unit direction vector from this component, in world space. | |
| Vector | GetRightVector | Get the right (Y) unit direction vector from this component, in world space. | |
| Vector | GetUpVector | Get the up (Z) unit direction vector from this component, in world space. | |
| Vector | RotateVector | Rotate a vector rotated by this rotator. | |
Normalize | In-place normalize, removes all winding and creates the “shortest route” rotation. | ||
| Vector | UnrotateVector | Returns the vector rotated by the inverse of this rotator. | |
| Quat | Quaternion | Get Rotation as a quaternion. | |
| Rotator | GetNormalized | Returns a new Rotator normalized. | |
| boolean | IsNearlyZero | Checks whether rotator is near to zero within a specified tolerance | |
| boolean | IsZero | Checks whether all components of the rotator are exactly zero |
GetForwardVector
Get the forward (X) unit direction vector from this component, in world space.
local ret = my_rotator:GetForwardVector()
Returns
| Type | Description |
|---|---|
| Vector | the forward direction |
GetRightVector
Get the right (Y) unit direction vector from this component, in world space.
local ret = my_rotator:GetRightVector()
Returns
| Type | Description |
|---|---|
| Vector | the right direction |
GetUpVector
Get the up (Z) unit direction vector from this component, in world space.
local ret = my_rotator:GetUpVector()
Returns
| Type | Description |
|---|---|
| Vector | the up direction |
RotateVector
Rotate a vector rotated by this rotator.
local ret = my_rotator:RotateVector(vector)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | vector | Required parameter | the vector to rotate by the Rotator |
Returns
| Type | Description |
|---|---|
| Vector | the rotated vector |
Normalize
In-place normalize, removes all winding and creates the “shortest route” rotation.
my_rotator:Normalize()
UnrotateVector
Returns the vector rotated by the inverse of this rotator.
local ret = my_rotator:UnrotateVector(vector)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | vector | Required parameter | The vector to rotate by the inverse of the Rotator |
Returns
| Type | Description |
|---|---|
| Vector | the unrotated vector |
Quaternion
Get Rotation as a quaternion.
local ret = my_rotator:Quaternion()
Returns
| Type | Description |
|---|---|
| Quat | the rotation as a quaternion |
GetNormalized
Returns a new Rotator normalized.
local ret = my_rotator:GetNormalized()
Returns
| Type | Description |
|---|---|
| Rotator | the normalized Rotator |
IsNearlyZero
Checks whether rotator is near to zero within a specified tolerance
local ret = my_rotator:IsNearlyZero(tolerance?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| number | tolerance? | 0.000001 | Tolerance to check |
Returns
| Type | Description |
|---|---|
| boolean | whether the rotator is nearly zero |
IsZero
Checks whether all components of the rotator are exactly zero
local ret = my_rotator:IsZero()
Returns
| Type | Description |
|---|---|
| boolean | whether the rotator is exactly zero |
🗿 Static Functions
Random
Generates a random rotation, with optional random roll
local ret = Rotator.Random(roll?, min?, max?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | roll? | false | Whether to use a random roll in the rotator, otherwise uses 0 for roll |
| float | min? | -180 | Minimum value |
| float | max? | 180 | Maximum value |
Returns
| Type | Description |
|---|---|
| Rotator | the random rotation |