Coordinate System¶
Luanti uses a left-handed coordinate system: Y is "up", X is "right", Z is "forward". This is the convention used by Unity, DirectX and Irrlicht. It means that when you're pointing in +Z direction in-game ("forward"), +X is to your right; +Y is up.
Consistently, rotation is left-handed as well.
Luanti uses Tait-Bryan angles for rotations,
often referred to simply as "euler angles" (even though they are not "proper" euler angles).
The rotation order is extrinsic X-Y-Z:
First rotation around the (unrotated) X-axis is applied,
then rotation around the (unrotated) Y-axis follows,
and finally rotation around the (unrotated) Z-axis is applied.
(Note: As a product of rotation matrices, this will be written in reverse, so Z*Y*X
.)
Attachment and bone override rotations both use these conventions.
There is an exception, however: Object rotation (ObjectRef:set_rotation
, ObjectRef:get_rotation
, automatic_rotate
)
does not use left-handed (extrinsic) X-Y-Z rotations.
Instead, it uses right-handed (extrinsic) Z-X-Y rotations:
First roll (Z) is applied, then pitch (X); yaw (Y) is applied last.
See Scratchapixel or Wikipedia for a more detailed and pictorial explanation of these terms.