Rotation matrix decomposition into mixed local/global Euler angles

3deuler's methodmatrix decomposition

I am trying to decompose a rotation matrix into Euler angles.
The standard ways appear to work fine to find the rotations around the moving/local axes (example 1) OR to find the rotations around the global or fixed axes (example 2).
I struggle with mixing local and global axes, as it is required for my application:
My first rotation has to be around global Y, second around local X, third around local Y.

I attempted an illustration here, and set a jupyter notebook here

There are a few relevant discussions but I still can’t seem to find my away around!

Based on the following rotation matrix as an example:

\begin{equation}
\mathbf{R} =
\begin{bmatrix}
0.83101165 & 0.17101007 & -0.52931577\\
0.12940952 & 0.8660254 & 0.48296291 \\
0.54099243 & -0.46984631 & 0.69754687
\end{bmatrix}
\end{equation}

1) Example 1 of xyz rotation with local axes

Rz @ Ry @ Rx, with:

$$
\begin{equation}
\begin{array}{l l}
\mathbf{R}_{\mathbf{lG},\,xyz} & = \mathbf{R_{z}} \mathbf{R_{y}} \mathbf{R_{x}} \\
\\
& = \begin{bmatrix}
\cos\gamma & \sin\gamma & 0\\
-\sin\gamma & \cos\gamma & 0 \\
0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
\cos\beta & 0 & -\sin\beta \\
0 & 1 & 0 \\
\sin\beta & 0 & \cos\beta
\end{bmatrix}
\begin{bmatrix}
1 & 0 & 0 \\
0 & \cos\alpha & \sin\alpha \\
0 & -\sin\alpha & \cos\alpha
\end{bmatrix} \\
\\
& =
\begin{bmatrix}
\cos\beta\:\cos\gamma \;&\;
\sin\alpha\:\sin\beta\:\cos\gamma+\cos\alpha\:\sin\gamma \;&\;
\cos\alpha\:\sin\beta\:\cos\gamma-\sin\alpha\:\sin\gamma \;\;\; \\
-\cos\beta\:\sin\gamma \;&\;
-\sin\alpha\:\sin\beta\:\sin\gamma+\cos\alpha\:\cos\gamma \;&\;
\cos\alpha\:\sin\beta\:\sin\gamma+\sin\alpha\:\cos\gamma \;\;\; \\
\sin\beta \;&\; -\sin\alpha\:\cos\beta \;&\; \cos\alpha\:\cos\beta \;\;\;
\end{bmatrix}
\end{array}
\end{equation}
$$

Solving for this:

$$
\alpha=\mathrm{arctan2}(-R_{21},R_{22}) = 0.59276 (rad) = 33.96 (deg)\\
\beta=\mathrm{arctan2}(R_{20},{\sqrt{\mathbf{R}_{00}^2+\mathbf{R}_{10}^2}}) = 0.57161668 (rad) = 32.75122352 (deg)\\
\gamma=\mathrm{arctan2}(-R_{10},R_{00}) = -0.15448448 (rad) = -8.85130893 (deg)\\
$$

2) Example 2 of xyz rotation with global axes

Rz @ Ry @ Rx, with:

\begin{equation}
\begin{array}{l l}
\mathbf{R_{Gl,\;XYZ}} & = \mathbf{R_{Z}} \mathbf{R_{Y}} \mathbf{R_{X}} \\
\\
& = \begin{bmatrix}
\cos\gamma & -\sin\gamma & 0\\
\sin\gamma & \cos\gamma & 0 \\
0 & 0 & 1
\end{bmatrix}
\begin{bmatrix}
\cos\beta & 0 & \sin\beta \\
0 & 1 & 0 \\
-\sin\beta & 0 & \cos\beta
\end{bmatrix}
\begin{bmatrix}
1 & 0 & 0 \\
0 & \cos\alpha & -\sin\alpha \\
0 & \sin\alpha & \cos\alpha
\end{bmatrix} \\
\\
& =
\begin{bmatrix}
\cos\beta\:\cos\gamma \;&\;
\sin\alpha\:\sin\beta\:\cos\gamma-\cos\alpha\:\sin\gamma \;&\;
\cos\alpha\:\sin\beta\:cos\gamma+\sin\alpha\:\sin\gamma \;\;\; \\
\cos\beta\:\sin\gamma \;&\;
\sin\alpha\:\sin\beta\:\sin\gamma+\cos\alpha\:\cos\gamma \;&\;
\cos\alpha\:\sin\beta\:\sin\gamma-\sin\alpha\:\cos\gamma \;\;\; \\
-\sin\beta \;&\; \sin\alpha\:\cos\beta \;&\; \cos\alpha\:\cos\beta \;\;\;
\end{bmatrix}
\end{array}
\end{equation}

Solving for this:

$$
\alpha=\mathrm{arctan2}(R_{21},R_{22}) = = -0.5927662886828803 (rad) = -33.96300657916242 (deg)\\
\beta=\mathrm{arctan2}(-R_{20},{\sqrt{\mathbf{R}_{00}^2+\mathbf{R}_{10}^2}}) = -0.5716166844955842 (rad) = -32.75122352085813 (deg)\\
\gamma=\mathrm{arctan2}(-R_{10},R_{00}) = 0.15448448400601972 (rad) = 8.851308933801198 (deg)\\
$$

My problem is when I am trying to mix the global and local axes

α is the first rotation around the Global Y axis,
β is the second rotation around the Local y axis,
γ is the third rotation around the Local y axis

The order or rotation is right to left, so $R_{M}$ = $R_{M,y}$ @ $R_{M,x}$ @ $R_{M,Y}$

\begin{equation}
\begin{array}{l l}
\displaystyle R_{M,Yxy} = \left[\begin{matrix}\cos{\left(\gamma \right)} & 0 & – \sin{\left(\gamma \right)}\\0 & 1 & 0\\\sin{\left(\gamma \right)} & 0 & \cos{\left(\gamma \right)}\end{matrix}\right]+\left[\begin{matrix}1 & 0 & 0\\0 & \cos{\left(\beta \right)} & \sin{\left(\beta \right)}\\0 & – \sin{\left(\beta \right)} & \cos{\left(\beta \right)}\end{matrix}\right]+\left[\begin{matrix}\cos{\left(\alpha \right)} & 0 & \sin{\left(\alpha \right)}\\0 & 1 & 0\\- \sin{\left(\alpha \right)} & 0 & \cos{\left(\alpha \right)}\end{matrix}\right]
\end{array}
\end{equation}

\begin{equation}
\begin{array}{l l}
\displaystyle R_{M,Yxy} = \left[\begin{matrix}\sin{\left(\alpha \right)} \sin{\left(\gamma \right)} \cos{\left(\beta \right)} + \cos{\left(\alpha \right)} \cos{\left(\gamma \right)} & \sin{\left(\beta \right)} \sin{\left(\gamma \right)} & \sin{\left(\alpha \right)} \cos{\left(\gamma \right)} – \sin{\left(\gamma \right)} \cos{\left(\alpha \right)} \cos{\left(\beta \right)}\\- \sin{\left(\alpha \right)} \sin{\left(\beta \right)} & \cos{\left(\beta \right)} & \sin{\left(\beta \right)} \cos{\left(\alpha \right)}\\- \sin{\left(\alpha \right)} \cos{\left(\beta \right)} \cos{\left(\gamma \right)} + \sin{\left(\gamma \right)} \cos{\left(\alpha \right)} & – \sin{\left(\beta \right)} \cos{\left(\gamma \right)} & \sin{\left(\alpha \right)} \sin{\left(\gamma \right)} + \cos{\left(\alpha \right)} \cos{\left(\beta \right)} \cos{\left(\gamma \right)}\end{matrix}\right]\end{array}
\end{equation}

Does this approach make sense? If yes, how would you go solving for

this?

Solving for this, with:
$\alpha$ = ???
$\beta$ = ???
$\gamma$ = ???

Edit: it is a standard Local rotation as initially the two Y axes are similar… so example 1 is correct!

Best Answer

In any 3 angle rotation scheme, there are actually four reference frames at play. Lets define:

Frame Description
$G$ Global frame before rotations
$L_1$ Local frame after 1st rotation
$L_2$ Local frame after 2nd rotation
$L_3$ Local frame after all 3 rotations

Since the before the first rotation we are always in the global frame, your worry about mixing global and local frames is unfounded. The rotation sequence you appear to be describing is actually just the common 2-1-2 or Y-X-Y rotation sequence. See Appendix C in Analytical Mechanics of Space Systems by Schaub and Junkins for example (google for pdf). I would highly recommend working through the first few sections of the attitude kinematics chapter in this book as well to improve your facility with composite rotations.

Finally, check https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix

for the inverse transformation you appear to be seeking. Specifically, see the $Y_1 X_2 Y_3$ column of the second table in the Rotation Matrix section.

Related Question