Skip to main content
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
NameTypeDescription
pitch?floatPitch Default 0
yaw?floatYaw Default pitch
roll?floatRoll Default pitch

๐Ÿงฝ Propertiesโ€‹

TypeNameDescription
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

Equalsโ€‹

Optimal

Checks against another Rotator for equality, within a tolerance

local ret = my_rotator:Equals(other, tolerance?)
Parameters
NameTypeDescription
otherRotatorThe Rotator to compare to
tolerance?floatMax difference allowed per axis, in degrees Default 0.000001
Returns
TypeDescription
booleanWhether the Rotators are equal

GetForwardVectorโ€‹

Optimal

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

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

GetRightVectorโ€‹

Optimal

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

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

GetUpVectorโ€‹

Optimal

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

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

RotateVectorโ€‹

Optimal

Rotate a vector rotated by this rotator

local ret = my_rotator:RotateVector(vector)
Parameters
NameTypeDescription
vectorVectorthe vector to rotate by the Rotator
Returns
TypeDescription
Vectorthe rotated vector

Normalizeโ€‹

Optimal

In-place normalize, removes all winding and creates the โ€œshortest routeโ€ rotation

my_rotator:Normalize()

UnrotateVectorโ€‹

Optimal

Returns the vector rotated by the inverse of this rotator

local ret = my_rotator:UnrotateVector(vector)
Parameters
NameTypeDescription
vectorVectorThe vector to rotate by the inverse of the Rotator
Returns
TypeDescription
Vectorthe unrotated vector

Quaternionโ€‹

Optimal

Get Rotation as a quaternion

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

GetNormalizedโ€‹

Optimal

Returns a new Rotator normalized

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

IsNearlyZeroโ€‹

Optimal

Checks whether rotator is near to zero within a specified tolerance

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

IsZeroโ€‹

Optimal

Checks whether all components of the rotator are exactly zero

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

๐Ÿ—ฟ Static Functionsโ€‹

Random: RotatorGenerates a random rotation, with optional random roll

Randomโ€‹

Optimal

Generates a random rotation, with optional random roll

local ret = Rotator.Random(roll?, min?, max?)
Parameters
NameTypeDescription
roll?booleanWhether to use a random roll in the rotator, otherwise uses 0 for roll Default false
min?floatMinimum value Default -180
max?floatMaximum value Default 180
Returns
TypeDescription
Rotatorthe random rotation