I have a rotation matrix R:
R=[[-0.22247682, -0.32863132, -0.91788099],
[-0.01426572, -0.94027818, 0.34010798],
[-0.9748336 , 0.08876037, 0.20450194]]
and I want to decompose this into three rotations, $R_Z(\alpha)R_X(\beta)R_Z(\gamma)$, where I consider clockwise rotations. The rotation matrix in terms of these Euler angles is then given by
$R=$ \begin{bmatrix} \cos\alpha\;\cos\gamma\;-\;\sin\alpha\;\cos\beta\;\sin\gamma & -\sin\gamma\;\cos\alpha\;-\;\sin\alpha\;\cos\beta\;\cos\gamma\; & \sin\alpha\;\sin\beta \\ \sin\alpha\;\cos\gamma\;+\;\sin\gamma\;\cos\alpha\;\cos\beta\; & -\sin\alpha\;\sin\gamma\;+\;\cos\alpha\;\cos\beta\;\cos\gamma & -\cos\alpha\;\sin\beta\\ \sin\beta\;\sin\gamma & \sin\beta\;\cos\gamma & \cos\beta\\ \end{bmatrix}
Then, I calculate $\beta=\arccos(R_{33})=1.36$, $\alpha=\arctan(-R_{13}/R_{23})=1.22$, and $\gamma=\arctan(R_{31}/R_{32})=-1.48$. As a double check, I reconstruct the matrix R from these Euler angles, and find the following:
R'=[[ 0.22247682, 0.32863132, -0.91788099],
[ 0.01426572, 0.94027818, 0.34010798],
[ 0.9748336 , -0.08876037, 0.20450194]])
I double checked everything, but I cannot find what the problem is. What could I be missing?
Edit: It turns out the transpose problem was because my python code had some indexation problem. The sign issues still persist, however. I updated the matrix R' above.
I have confirmed the rotation matrix expression, but I would extract the angles a little differently than you.
where
atan2(dy,dx)is the arc tangent covering the entire unit circle.The recustruction is thus
R = RZ(1.2159450042115176)*RX(1.3648414591977873)*RZ(-1.4799948857740634)$\checkmark$