Internally, ROBLOX doesn’t store those three values (the XYZ orientation). It stores a part’s position and rotation in a single 4x4 matrix – a coordinate frame (CFrame).
Both (180, 0, 0) and (0, 180, 180) represent the exact same orientation because they represent the exact same rotation matrix.
When you print the orientation, roblox calculates the roll, pitch, and yaw from the CFrame (either on-the-fly or it’s cached).
That calculation, according to this page, probably looks something like this (but they write it in c
):
-- (untested, might have gotten the order of things mixed up)
-- Calculates pitch, yaw, and roll from a CFrame
-- and returns them in that order.
-- EDIT: this returns radians, not degrees. So pass the results through math.deg
-- if you wanted to compare directly.
function GetOrientationXYZ(cframe)
-- get the matrix (see https://developer.roblox.com/en-us/articles/CFrame-Math-Operations)
local x, y, z, r11, r12, r13, r21, r22, r23, r31, r32, r33 = a:components();
-- get pitch (x-axis)
local alpha = math.atan2(r21 / r11);
-- get yaw (y-axis)
local beta = math.atan2(-r31 / math.sqrt(r32*r32 + r33*r33));
-- get roll (z-axis)
local gamma = math.atan2(r32 / r33);
return alpha, beta, gamma
end
It just so happens that the way that formula spits out angles isn’t the same ones you gave it.
edit: How do they convert the roll, pitch, and yaw that you give into a CFrame in the first place? Probably something like the “Tait-Bryan angles” column in this table.