I have two rotation matrix suppose initial basis O is identity in R^3 and rotation RAO transforms a point in O into basis A and rotation RBO transforms a point in O into basis B
I tried to calculate angle differences between RAO and RBO like:
from scipy.spatial.transform import Rotation
def Rdiff(RAO, RBO):
RBA = RAO.T @ RBO
RBA = Rotation.from_matrix(RBA)
return RBA.as_euler('zyx', degrees=True)
RAO = Rotation.from_euler('zyx', [10, 0, 13],
degrees=True).as_matrix()
RBO = Rotation.from_euler('zyx', [0, 63, 40],
degrees=True).as_matrix()
print(Rdiff(RAO, RBO))
but the result:
[-16.65056217 57.31794707 41.4856089 ]
is different from what I expected: [-10, 63, 26]
Is that something wrong here? How can I fix it?
[EDIT] I used math formula from here: https://math.stackexchange.com/questions/87338/change-in-rotation-matrix/87698#comment4515183_87698 and I have checked that RAO, RBO, RBA in function Rdiff is unitary.
[EDIT] My original function in Rdiff is fault, so I changed line:
RBA = RBO @ RAO.T
into
RBA = RAO.T @ RBO
Your code seems fine. The issue is that when you compose two rotations with given Euler angles, then you don't simply get a rotation given by the sums of these angles.