Questions about the difference between ToEulerAnglesXYZ and ToEulerAnglesYXZ

Hi there! I encountered a problem with getting the Y component of orientation, and solved it by switching from ToEulerAnglesXYZ to ToEulerAnglesYXZ, while I solved my issue, I still have no idea why it was solved! These two methods seem very unintuitive for me, especially since it seems like ToEulerAnglesYXZ applies to CFrame.Angles much better than ToEulerAnglesXYZ, and this is confusing since ROBLOX coordinates are usually XYZ!

So, my two questions:

  • First, I am wondering why these are named the way they are, when they both seem like they return angles in X, Y, Z order.

  • Second, I am wondering why the Y angle returned by ToEulerAnglesXYZ never goes above |90|, since this was the original source of my issue

Here is a video of the second question, and the source code which helps illustrate my first question.

-- XYZ TextLabel
local localPlayer = game:GetService("Players").LocalPlayer

game:GetService("RunService").RenderStepped:Connect(function()
	if (localPlayer.Character) then
		local x, y, z = localPlayer.Character:GetPivot():ToEulerAnglesXYZ()
		local degAngleX = math.floor(math.deg(x))
		local degAngleY = math.floor(math.deg(y))
		local degAngleZ = math.floor(math.deg(z))

		script.Parent.Text = "("..degAngleX..", "..degAngleY..","..degAngleZ..")"
	end
	 
end)

-- YXZ TextLabel
local localPlayer = game:GetService("Players").LocalPlayer

game:GetService("RunService").RenderStepped:Connect(function()
	if (localPlayer.Character) then
		local x, y, z = localPlayer.Character:GetPivot():ToEulerAnglesYXZ()
		local degAngleX = math.floor(math.deg(x))
		local degAngleY = math.floor(math.deg(y))
		local degAngleZ = math.floor(math.deg(z))

		script.Parent.Text = "("..degAngleX..", "..degAngleY..","..degAngleZ..")"
	end

end)

Thank you if anyone has any idea why this happens! The documentation for both of these have the exact same description, and I couldn’t find any info anywhere else! (CFrame | Documentation - Roblox Creator Hub)

1 Like