Zum Hauptinhalt springen
Version: bleeding-edge 🩸

🧭 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

TypeNameDefaultDescription
floatpitch0Pitch
floatyawpitchYaw
floatrollpitchRoll

🧽 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.

ReturnsNameDescription
booleanEqualsChecks against another Rotator for equality, within a tolerance
VectorGetForwardVectorGet the forward (X) unit direction vector from this component, in world space.
VectorGetRightVectorGet the right (Y) unit direction vector from this component, in world space.
VectorGetUpVectorGet the up (Z) unit direction vector from this component, in world space.
VectorRotateVectorRotate a vector rotated by this rotator.
NormalizeIn-place normalize, removes all winding and creates the “shortest route” rotation.
VectorUnrotateVectorReturns the vector rotated by the inverse of this rotator.
QuatQuaternionGet Rotation as a quaternion.
RotatorGetNormalizedReturns a new Rotator normalized.
booleanIsNearlyZeroChecks whether rotator is near to zero within a specified tolerance
booleanIsZeroChecks whether all components of the rotator are exactly zero

Optimal

Equals​

Checks against another Rotator for equality, within a tolerance
local ret = my_rotator:Equals(other, tolerance?)

Parameters

TypeParameterDefaultDescription
Rotatorother Required parameter The Rotator to compare to
floattolerance?0.000001
Max difference allowed per axis, in degrees

Returns

TypeDescription
booleanWhether the Rotators are equal

Optimal

GetForwardVector​

Get the forward (X) unit direction vector from this component, in world space.
local ret = my_rotator:GetForwardVector()

Returns

TypeDescription
Vectorthe forward direction

Optimal

GetRightVector​

Get the right (Y) unit direction vector from this component, in world space.
local ret = my_rotator:GetRightVector()

Returns

TypeDescription
Vectorthe right direction

Optimal

GetUpVector​

Get the up (Z) unit direction vector from this component, in world space.
local ret = my_rotator:GetUpVector()

Returns

TypeDescription
Vectorthe up direction

Optimal

RotateVector​

Rotate a vector rotated by this rotator.
local ret = my_rotator:RotateVector(vector)

Parameters

TypeParameterDefaultDescription
Vectorvector Required parameter the vector to rotate by the Rotator

Returns

TypeDescription
Vectorthe rotated vector

Optimal

Normalize​

In-place normalize, removes all winding and creates the “shortest route” rotation.
my_rotator:Normalize()

Optimal

UnrotateVector​

Returns the vector rotated by the inverse of this rotator.
local ret = my_rotator:UnrotateVector(vector)

Parameters

TypeParameterDefaultDescription
Vectorvector Required parameter The vector to rotate by the inverse of the Rotator

Returns

TypeDescription
Vectorthe unrotated vector

Optimal

Quaternion​

Get Rotation as a quaternion.
local ret = my_rotator:Quaternion()

Returns

TypeDescription
Quatthe rotation as a quaternion

Optimal

GetNormalized​

Returns a new Rotator normalized.
local ret = my_rotator:GetNormalized()

Returns

TypeDescription
Rotatorthe normalized Rotator

Optimal

IsNearlyZero​

Checks whether rotator is near to zero within a specified tolerance
local ret = my_rotator:IsNearlyZero(tolerance?)

Parameters

TypeParameterDefaultDescription
floattolerance?0.000001
Tolerance to check

Returns

TypeDescription
booleanwhether the rotator is nearly zero

Optimal

IsZero​

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​

ReturnsNameDescription
RotatorRandomGenerates a random rotation, with optional random roll

Optimal

Random​

Generates a random rotation, with optional random roll
local ret = Rotator.Random(roll?, min?, max?)

Parameters

TypeParameterDefaultDescription
booleanroll?false
Whether to use a random roll in the rotator, otherwise uses 0 for roll
floatmin?-180
Mindestwert
floatmax?180
Höchstwert

Returns

TypeDescription
Rotatorthe random rotation