I have the following set of coordinate frames (translations are not important in this case):
- $w$, the reference frame.
- $l$, a "left" reference frame. Rotated $-20\deg$ around $Y_l$ (axes $Y$ of frame $l$), rotated $-12\deg$ around $X_l$, and translated along $-X_w$.
- $r$, a "right" reference frame, similar to left. Rotated $20\deg$ around $Y_r$, rotated $-12\deg$ around $X_r$, and translated along $X_w$.
I hope the diagram makes it more clear:
The rotation matrices that describe the orientations are ($R_{w,l}$ represents rotation from $w$ to $l$, values are rounded):
$R_{w,l} = \left[ \begin{array}{{c}} 0.94&0&-0.34\\ 0.07&0.98&0.2\\ 0.33&-0.21&0.92 \end{array}\right]$, $R_{w,r} = \left[ \begin{array}{{c}} 0.94&0&0.34\\ -0.07&0.98&0.2\\ -0.33&-0.21&0.92 \end{array}\right]$
The problem comes when I want to know the relative rotation between $l$ and $r$: $R_{l,r}$. If I am not mistaken, this rotation can be computed from the ones I have:
$R_{l,r} = R_{l,w}R_{w,r} = R^T_{w,l}R_{w,r}$.
When I do this, I get the following result:
$R_{l,r} = \left[ \begin{array}{{c}} 0.77&0&0.64\\ 0&1&0\\ -0.64&0&0.77 \end{array}\right]$
Which in Euler angles to just a rotation of $40\deg$ around $Y$ (not sure which $Y$!). However, this does not make sense to me, because the only $Y$ I can use for this to make sense is $Y_w$.
What am I missing?
Expected result
I tried directly with the Euler angles. To convert from $l$ to $r$, one should do (starting in $l$):
$R_x(12\deg) \rightarrow R_y(20\deg) \rightarrow R_y(20\deg) \rightarrow R_x(-12\deg)$
Which are computed as matrices as follows:
$R_{l,r} = R_x(12\deg)R_y(40\deg)R_x(-12\deg)$
And this provides the following result:
$R_{l,r} = \left[ \begin{array}{{c}} 0.77&-0.13&0.63\\ 0.13&0.99&0.05\\ -0.63&0.05&0.77 \end{array}\right]$
Which makes way more sense, and actually represents the rotation from $l$ to $r$.