Ir para o conteúdo principal
Version: latest - a1.7.0 ⚖️

Rotator

A container for rotation information. All rotation values are stored in degrees.

Tip

This structure is Open Sourced at https://github.com/nanos-world/nanos-world-lua-lib. Feel free to push merge requests and suggest changes!

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

👌 Usage

local new_rotator = Rotator(-90, 153, 24.5)

🎚 Properties

TypeNameDescription
numberPitchRotation around the right axis (around Y axis), Looking up and down (0=Straight Ahead, +Up, -Down)
numberYawRotation around the up axis (around Z axis), Running in circles 0=East, +North, -South.
numberRollRotation around the forward axis (around X axis), Tilting your head, 0=Straight, +Clockwise, -CCW.

⏩ Functions

tip

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

ReturnsNameDescription
VectorGetForwardVector()Get the forward (X) unit direction vector from this component, in world space.
VectorGetRightVector()Get the right (Y) unit direction vector from this component, in world space.
VectorGetUpVector()Get the up (Z) unit direction vector from this component, in world space.
VectorRotateVector(vector)Rotate a vector rotated by this rotator.
Normalize()In-place normalize, removes all winding and creates the “shortest route” rotation.
VectorUnrotateVector(vector)Returns the vector rotated by the inverse of this rotator.
QuatQuaternion()Get Rotation as a quaternion.
RotatorGetNormalized()Returns a new Rotator normalized.
booleanIsNearlyZero(tolerance)Checks whether rotator is near to zero within a specified tolerance
booleanIsZero()Checks whether all components of the rotator are exactly zero

⏩ Static Functions

ReturnsNameDescription
RotatorRandom(roll)Generates a random rotation, with optional random roll