# Extrinsic and intrinsic Euler angles to rotation matrix and back

currently I'm working on the visualization of coordinate systems in space to understand rotation matrices better. Until now I thought everything would be ok, but there is a thing that does not get into my head, maybe you can help. I'll be as precise as I can.

# Conventions

1. I use the basis rotation matrices from eg http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations. Let $p_i \in \mathbb{R}^{3\times 1}$ be a vector expressed in the coordinate system $\text{cs}_i:(O_i,\mathrm{i}_i,\mathrm{j}_i,\mathrm{k}_i)$ and $R \in \mathbb{R}^{3\times3}$ the aforementioned rotation matrix. Let $p \in \mathbb{R}^{3\times 1}$ be another arbitrary vector whose meaning can change. $p_0=R \, p$ can be interpreted in various ways:
• a rotation of a vector $p$ to the rotated version $p_0$ in the same coordinate system.
• let $p=p_1$ be the coordinates of a point in another coordinatesystem $\text{cs}_1$, then $p_0=R_0^1 \, p_1$ with $R_0^1=R$ is the same point expressed in $\text{cs}_0$. This can be seen as a body ($\text{cs}_1$) and a world ($\text{cs}_0$) coordinate system.
• the rotationmatrix $R_0^1$ gives us the orientation of $\text{cs}_1$ relative to $\text{cs}_0$. The columns in $R_0^1$ are the direction vectors of the system $\text{cs}_1$.
2. These rotations are called active or alibi transformation, see http://en.wikipedia.org/wiki/Active_and_passive_transformation
3. Successive rotation can be around the global coordinate sytem $\text{cs}_0$ or around a local one. This depends on the order of multiplication. For example: $p_0=R_0^1R_1^2p_2=R_0^2p_2$ is a vector which is rotaed two times. The rotation takes place arount the local or rotated axis, this is called intrinsic rotation. For extrinsic rotation around the global axis of $\text{cs}_0$ the following holds: $p_0=R_1^2R_0^1p_2$, so the matrices are swapped. This is true for $n$ rotation sequences around different axis and angles.

4. The orientation is described by $R$. But there are 9 parameters to store and without a plot of the unit vectors it is hard to imagine the orientation. So another method to calculate the orientation are the euler or tait-bryan angles, see Euler_angles in Wikipedia, I can't post more than 2 links, sorry. There are a lot of definitions, I tried to use only two:

• z-y'-x'' (intrinsic) which means: First rotate around the z axis with an angle $\Psi$, then around the new y axis with $\Theta$ and then around the new x axis with $\Phi$. The angles are commonly called yaw pitch roll or heading, elevation and bank. $R_\text{zy'x''}=R_z(\Psi)R_y(\Theta)R_x(\Phi)$
• z-y-x (extrinsic) The same as above, but always rotate around the global axis. $R_\text{zyx}=R_x(\Phi)R_y(\Theta)R_z(\Psi)$. The full matrices are given in the appendix.

It would be incredible, if you guys can confirm the above said, or tell me if there are any errors.

# Problem

Now the hard part (for me) comes. Assume you want to get the euler angles from the rotation matrices. In the rotation matrices you can see for the intrinsic rotation $R_\text{zx'y''}$ , the $r(i,j)$ are the Matrix elements. \begin{align} \Phi &= \operatorname{atan2}(r(3,2),r(3,3)) \\ \Theta&=\operatorname{asin}(-r(3,1))\\ \Psi&=\operatorname{atan2}(r(2,1),r(1,1)) \end{align}

and for the extrinsic rotation $R_\text{zxy}$ \begin{align} \Phi &= \operatorname{atan2}(-r(2,3),r(3,3)) \\ \Theta&=\operatorname{asin}(r(1,3))\\ \Psi&=\operatorname{atan2}(-r(1,2),r(1,1)) \end{align}

The problem: I can't interpret the angles correctly. Let's stick to the first rotation sequence and rotate a coordinate system to an initial orientation. For example rotate $\pi/8=22.5°$ around the x axis, so that the euler angles are $[\Phi,\Theta,\Psi]=[22.5\:0 \:0].$ Now rotate around the new y (green) axis in 10 degree steps a few times. See the picture, the bolded coordinate system is the initial orientation, the dotted is the world system. For help I've drawed the xz plane, too. Calculating the intrinsic euler angles from the rotation matrix with the above mentioned formulars I get following angles for the 6 positions

  Phi         Theta       Psi
22.5        0           0
22.812      9.2319      3.8603
23.788       18.42      7.9294
25.561      27.512      12.459
28.401      36.431      17.802
32.798      45.051      24.516


So what I really expected was, that the Phi and Psi remain constant and only Thetachanges. Unfortunately this is the case, when I calculate the EXTRINSIC angles from the second definition:

22.5          10          -0
22.5          20          -0
22.5          30          -0
22.5          40          -0
22.5          50          -0


Can this be explained easily? I thought the yaw,pitch,roll angles (intrinsic) describe the rotation around these axis, for example of an airplane. Did I mix something in my calculations (I checked though, and it seams to be consistent) or is there an easy explanation?

Only for completeness, here is a picture of a rotation around the GLOBAL y axis: The angles behave similar (of course the values are different, and don't lie in the xz plane anymore)

intrinsic
Phi             Theta        Psi
22.5          10           0
22.5          20           0
22.5          30           0
22.5          40           0
22.5          50           0

extrinsic
Phi             Theta        Psi
22.812      9.2319     -3.8603
23.788       18.42     -7.9294
25.561      27.512     -12.459
28.401      36.431     -17.802
32.798      45.051     -24.516


I wrote the whole text above to be really sure we are talking about the same rotation order and convention, since this is the source of most errors.

Thank you very much!

## Appendix

\begin{alignat}{1} R_x(\theta) &= \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos \theta & -\sin \theta \\[3pt] 0 & \sin \theta & \cos \theta \\[3pt] \end{bmatrix} \\[6pt] R_y(\theta) &= \begin{bmatrix} \cos \theta & 0 & \sin \theta \\[3pt] 0 & 1 & 0 \\[3pt] -\sin \theta & 0 & \cos \theta \\ \end{bmatrix} \\[6pt] R_z(\theta) &= \begin{bmatrix} \cos \theta & -\sin \theta & 0 \\[3pt] \sin \theta & \cos \theta & 0\\[3pt] 0 & 0 & 1\\ \end{bmatrix} \end{alignat}

$$R_\text{zy'z''} = \begin{bmatrix} c_\Psi c_\Theta & c_\Psi s_\Theta s_\Phi - c_\Phi s_\Psi & s_\Psi s_\Phi + c_\Psi c_\Phi s_\Theta \\ c_\Theta s_\Psi & c_\Psi c_\Phi + s_\Psi s_\Theta s_\Phi & c_\Phi s_\Psi s_\Theta - c_\Psi s_\Phi \\ - s_\Theta & c_\Theta s_\Phi & c_\Theta c_\Phi \end{bmatrix}$$

$$R_\text{zyx} = \begin{bmatrix} c_\Psi c_\Theta & -s_\Phi c_\Theta & s_\Theta \\ s_\Phi c_\Psi s_\Theta + c_\Phi s_\Psi & c_\Phi c_\Psi -s_\Phi s_\Psi s_\Theta & -s_\Phi c_\Theta \\ s_\Phi s_\Psi -c_\Theta c_\Psi s_\Theta & c_\Phi s_\Psi s_\Theta +s_\Phi c_\Psi & c_\Theta c_\Phi \end{bmatrix}$$

• Is something wrong with the question?
– Jan
May 26 '15 at 11:49