Zum Hauptinhalt springen
Version: latest - a1.172.0 ⚖️

🧭 Rotator

A container for rotation information (Pitch, Yaw, Roll). All rotation values are stored in degrees


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?)
Parameters
NameTypeBeschreibung
pitch?floatPitch Default 0
yaw?floatYaw Default pitch
roll?floatRoll Default pitch

🧽 Properties​

TypeNameBeschreibung
floatPitchRotation around the right axis (around Y axis), Looking up and down (0=Straight Ahead, +Up, -Down)
floatYawRotation around the up axis (around Z axis), Running in circles 0=East, +North, -South
floatRollRotation around the forward axis (around X axis), Tilting your head, 0=Straight, +Clockwise, -CCW

🦠 Functions​

info

This structure supports +, -, * and tostring operations.

Equals: booleanChecks against another Rotator for equality, within a tolerance
GetForwardVector: VectorGet the forward (X) unit direction vector from this component, in world space
GetRightVector: VectorGet the right (Y) unit direction vector from this component, in world space
GetUpVector: VectorGet the up (Z) unit direction vector from this component, in world space
RotateVector: VectorRotate a vector rotated by this rotator
NormalizeIn-place normalize, removes all winding and creates the “shortest route” rotation
UnrotateVector: VectorReturns the vector rotated by the inverse of this rotator
Quaternion: QuatGet Rotation as a quaternion
GetNormalized: RotatorReturns a new Rotator normalized
IsNearlyZero: booleanChecks whether rotator is near to zero within a specified tolerance
IsZero: booleanChecks 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
NameTypeBeschreibung
otherRotatorThe Rotator to compare to
tolerance?floatMax difference allowed per axis, in degrees Default 0.000001
Returns
TypeBeschreibung
booleanWhether the Rotators are equal

GetForwardVectorOptimal​

Get the forward (X) unit direction vector from this component, in world space

local ret = my_rotator:GetForwardVector()
Returns
TypeBeschreibung
Vectorthe forward direction

GetRightVectorOptimal​

Get the right (Y) unit direction vector from this component, in world space

local ret = my_rotator:GetRightVector()
Returns
TypeBeschreibung
Vectorthe right direction

GetUpVectorOptimal​

Get the up (Z) unit direction vector from this component, in world space

local ret = my_rotator:GetUpVector()
Returns
TypeBeschreibung
Vectorthe up direction

RotateVectorOptimal​

Rotate a vector rotated by this rotator

local ret = my_rotator:RotateVector(vector)
Parameters
NameTypeBeschreibung
vectorVectorthe vector to rotate by the Rotator
Returns
TypeBeschreibung
Vectorthe 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
NameTypeBeschreibung
vectorVectorThe vector to rotate by the inverse of the Rotator
Returns
TypeBeschreibung
Vectorthe unrotated vector

QuaternionOptimal​

Get Rotation as a quaternion

local ret = my_rotator:Quaternion()
Returns
TypeBeschreibung
Quatthe rotation as a quaternion

GetNormalizedOptimal​

Returns a new Rotator normalized

local ret = my_rotator:GetNormalized()
Returns
TypeBeschreibung
Rotatorthe normalized Rotator

IsNearlyZeroOptimal​

Checks whether rotator is near to zero within a specified tolerance

local ret = my_rotator:IsNearlyZero(tolerance?)
Parameters
NameTypeBeschreibung
tolerance?floatTolerance to check Default 0.000001
Returns
TypeBeschreibung
booleanwhether the rotator is nearly zero

IsZeroOptimal​

Checks whether all components of the rotator are exactly zero

local ret = my_rotator:IsZero()
Returns
TypeBeschreibung
booleanwhether the rotator is exactly zero

🗿 Static Functions​

Random: RotatorGenerates a random rotation, with optional random roll

RandomOptimal​

Generates a random rotation, with optional random roll

local ret = Rotator.Random(roll?, min?, max?)
Parameters
NameTypeBeschreibung
roll?booleanWhether to use a random roll in the rotator, otherwise uses 0 for roll Default false
min?floatMindestwert Default -180
max?floatHöchstwert Default 180
Returns
TypeBeschreibung
Rotatorthe random rotation