Find by how much a CFrame has to rotate in order to match another CFrame

How can I find the angular distance between two CFrames?

Let me explain better, given a CFrame “CFOrigin” and a CFrame “CFTarget”, how can I find the X, Y and Z values in the following equation?
CFOrigin * CFrame.Angles(X,Y,Z) = CFTarget

Thank you.

so, your goal is to find the value between the two? Origin - Angle?
Correct me if I’m wrong, the wording is rather confusing.

Well, you could find the CFrame by doing left side multiplication with CFOrigin:inverse() so it’s
CFrame.Angles(X,Y,Z) = CFOrigin:inverse() * CFTarget and then use a function to grab the angles.

1 Like
local mainPart = ?;
local otherPart = ?;
local differenceComplete = otherPart:ToObjectSpace(mainPart)
local differenceOrientation = differenceComplete - differenceComplete.p
local X,Y,Z = differenceOrientation:ToEulerAnglesXYZ()

The difference is the object space location of the second part.

This works when applied all together, but when I try, for example, to apply only the X component by getting the result :ToEulerAnglesXYZ() and using it as CFOrigin * CFrame.Angles(X,0,0) I get a weird and inconsistent result. Is there a way to get the rotation of a CFrame like Part.Orientation does?

Nevermind, I was using the wrong method. You’re supposed to use :ToEulerAnglesYXZ() instead of :ToEulerAnglesXYZ()

Thank you for the solution!