🧭 Rotator
A container for rotation information (Pitch, Yaw, Roll). All rotation values are stored in degrees
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
🧽 Properties
| Type | Name | Beschreibung |
|---|---|---|
| float | Pitch | Rotation around the right axis (around Y axis), Looking up and down (0=Straight Ahead, +Up, -Down) |
| float | Yaw | Rotation around the up axis (around Z axis), Running in circles 0=East, +North, -South |
| float | Roll | Rotation around the forward axis (around X axis), Tilting your head, 0=Straight, +Clockwise, -CCW |
🦠 Functions
This structure supports +, -, * and tostring operations.
Equals: boolean | Checks against another Rotator for equality, within a tolerance | |
GetForwardVector: Vector | Get the forward (X) unit direction vector from this component, in world space | |
GetRightVector: Vector | Get the right (Y) unit direction vector from this component, in world space | |
GetUpVector: Vector | Get the up (Z) unit direction vector from this component, in world space | |
RotateVector: Vector | Rotate a vector rotated by this rotator | |
Normalize | In-place normalize, removes all winding and creates the “shortest route” rotation | |
UnrotateVector: Vector | Returns the vector rotated by the inverse of this rotator | |
Quaternion: Quat | Get Rotation as a quaternion | |
GetNormalized: Rotator | Returns a new Rotator normalized | |
IsNearlyZero: boolean | Checks whether rotator is near to zero within a specified tolerance | |
IsZero: boolean | Checks whether all components of the rotator are exactly zero |
EqualsOptimal
Checks against another Rotator for equality, within a tolerance
local ret = my_rotator:Equals(other, tolerance?)
Parameters
| Name | Type | Beschreibung |
|---|---|---|
other | Rotator | The Rotator to compare to |
tolerance? | float | Max difference allowed per axis, in degrees Default 0.000001 |
Returns
| Type | Beschreibung |
|---|---|
| boolean | Whether the Rotators are equal |
GetForwardVectorOptimal
Get the forward (X) unit direction vector from this component, in world space
local ret = my_rotator:GetForwardVector()
Returns
| Type | Beschreibung |
|---|---|
| Vector | the forward direction |
GetRightVectorOptimal
Get the right (Y) unit direction vector from this component, in world space
local ret = my_rotator:GetRightVector()
Returns
| Type | Beschreibung |
|---|---|
| Vector | the right direction |
GetUpVectorOptimal
Get the up (Z) unit direction vector from this component, in world space
local ret = my_rotator:GetUpVector()
Returns
| Type | Beschreibung |
|---|---|
| Vector | the up direction |
RotateVectorOptimal
Rotate a vector rotated by this rotator
local ret = my_rotator:RotateVector(vector)
Parameters
| Name | Type | Beschreibung |
|---|---|---|
vector | Vector | the vector to rotate by the Rotator |
Returns
| Type | Beschreibung |
|---|---|
| Vector | the rotated vector |
NormalizeOptimal
In-place normalize, removes all winding and creates the “shortest route” rotation
my_rotator:Normalize()
UnrotateVectorOptimal
Returns the vector rotated by the inverse of this rotator
local ret = my_rotator:UnrotateVector(vector)
Parameters
| Name | Type | Beschreibung |
|---|---|---|
vector | Vector | The vector to rotate by the inverse of the Rotator |
Returns
| Type | Beschreibung |
|---|---|
| Vector | the unrotated vector |
QuaternionOptimal
Get Rotation as a quaternion
local ret = my_rotator:Quaternion()
Returns
| Type | Beschreibung |
|---|---|
| Quat | the rotation as a quaternion |
GetNormalizedOptimal
Returns a new Rotator normalized
local ret = my_rotator:GetNormalized()
Returns
| Type | Beschreibung |
|---|---|
| Rotator | the normalized Rotator |
IsNearlyZeroOptimal
Checks whether rotator is near to zero within a specified tolerance
local ret = my_rotator:IsNearlyZero(tolerance?)
Parameters
| Name | Type | Beschreibung |
|---|---|---|
tolerance? | float | Tolerance to check Default 0.000001 |
Returns
| Type | Beschreibung |
|---|---|
| boolean | whether the rotator is nearly zero |
IsZeroOptimal
Checks whether all components of the rotator are exactly zero
local ret = my_rotator:IsZero()
Returns
| Type | Beschreibung |
|---|---|
| boolean | whether the rotator is exactly zero |
🗿 Static Functions
RandomOptimal
Generates a random rotation, with optional random roll
local ret = Rotator.Random(roll?, min?, max?)
Parameters
| Name | Type | Beschreibung |
|---|---|---|
roll? | boolean | Whether to use a random roll in the rotator, otherwise uses 0 for roll Default false |
min? | float | Mindestwert Default -180 |
max? | float | Höchstwert Default 180 |
Returns
| Type | Beschreibung |
|---|---|
| Rotator | the random rotation |
