How to subtract two CFrame Rotation?

For eazy example, CFrame named as “A” looking random direction. for example, 50°.
From angle “A”, I need to subtract angle “B”, which has an angle of 30° for example
both have Position (0,0,0)
for result, we can get 20°

But, how to subtract two 3D CFrame Rotation?

for harder example,
Subtract

CFrame.new(0, 0, 0, 0.931248188, -0.346774906, 0.111910142, -0, -0.307120293, -0.951670706, 0.364385366, 0.886241734, -0.286005229)

and

CFrame.new(0, 0, 0, 0.985184252, 0, -0.171499282, 0, 1, 0, 0.171499282, 0, 0.985184252)

Need more clarification, what exactly is this angle referring to?

Is this referring to Orientation angles such as the X axis rotation?

Is this rotation relative to the world’s axis xyz or relative to the previous CFrame axis? Do you want to know how to do it for both?

1 Like

this rotation thing. the CFrame value we can get from SomeCFrame.Rotation
i have two random CFrame like this.

1 Like

for some reason, CFrame * CFrame:inverse() making bug

i’m in this situation. i have to subtract Torso CFrame.

Now this is an XY question,

Seems like you are working with welds.

Welds require a special formula if you want to use a world space CFrame like CFrame.new( pos1, pos2) or CFrame.lookAt(pos1, pos2)

This is another formula I found to work. Normally this is used to subtract the TorsoCFrame, however the order matters as noted in the formula below Part0 refers to the Torso.

It’s

Torso.CFrame:Inverse() * armRotation

rather than

armRotation*Torso.CFrame:Inverse()

The order matters a lot.

2 Likes