PlanetPhysics/Direction Cosine Matrix to Euler 321 Angles

Starting with a direction cosine matrix (DCM), we need to determine the three Euler angles. The connection is made by comparing the DCM elements with the combined Euler 321 sequence. It is important to note that the 12 combinations of Euler angles for a given sequence can be found from a given DCM. The DCM matrix is

$$ DCM = \left[ \begin{matrix} A_{11} & A_{12} & A_{13} \\ A_{21} & A_{22} & A_{23} \\ A_{31} & A_{32} & A_{33} \end{matrix} \right] $$

The Euler 321 sequence is

$$ R_1(\psi)R_2(\theta)R_3(\phi) = \left[ \begin{matrix} c_{\theta} c_{\phi} & c_{\theta} s_{\phi} & -s_{\theta}  \\ - c_{\psi} s_{\phi} + s_{\psi} s_{\theta} c_{\phi} & c_{\psi} c_{\phi} + s_{\psi} s_{\theta} s_{\phi} & s_{\psi} c_{\theta} \\ s_{\psi} s_{\phi} + c_{\psi} s_{\theta} c_{\phi} & -s_{\psi} c_{\phi} + c_{\psi} s_{\theta} s_{\phi} & c_{\psi} c_{\theta}  \end{matrix} \right] $$

If we examine the element in column 3 row 1, then by inspection

$$A_{13} = -sin(\theta)$$

Solving for $$\theta$$ yields

$$ \theta = sin^{-1}(-A_{13}) $$

Care must now be taken when evaluating the inverse sine. It is a multivalued function, which will have values of $$\theta$$ and $$\pi - \theta$$. Analytically, the convention is to choose the principle value such that

$$-\pi/2 \le \theta \le \pi/2$$

If a numerical program is used, a function arcsine usually does this for us. The next step is to analyze the ratio $$\frac{A_{12}}{A_{11}}$$. Using these values from the Euler sequence we get

$$\frac{A_{12}}{A_{11}}= \frac{sin(\phi) cos(\theta) }{cos(\phi) cos(\theta) }$$

Rearranging the minus sign and using the tangent yields

$$tan(\phi) = \frac{A_{12}}{A_{11}}$$

Solving the quadrant ambiguity caused by the inverse tangent is done by examining the signs of the numerator and denominator. Denoting y as the numerator and x as the denominator, then the quadrant is chosen by:

quadrant 1 $$ \left[ \begin{matrix} y & x \\ + & + \\ \end{matrix} \right] $$

so if x and y are both positive, then $$0 \le \phi \le \pi /2$$. Similarly for the other quadrant possibilities

quadrant 2 $$ \left[ \begin{matrix} y & x \\ + & - \\ \end{matrix} \right] $$

quadrant 3 $$ \left[ \begin{matrix} y & x \\ - & - \\ \end{matrix} \right] $$

quadrant 4 $$ \left[ \begin{matrix} y & x \\ - & + \\ \end{matrix} \right] $$

Of course, it is much simpler to use a calculator or numerical program that uses the atan2 function which will choose the principle value. In a similar fashion we can find the final Euler angle by looking at the ratio $$\frac{A_{23}}{A_{33}}$$ which gives the relation $$\frac{A_{23}}{A_{33}} = \frac{sin(\psi) cos(\theta)}{cos(\psi) cos(\theta) }$$

Canceling terms and rearranging gives us

$$\psi = tan^{-1}(\frac{A_{23}}{A_{33}})$$

which uses the same method to resolve quadrant ambiguity as above. To summarize, we will give the formulas for the conversion from a direction cosine matrix to the Euler 313 angles in Matlab syntax. Be careful how you implement this in other numerical programs. In Matlab it goes atan2(y,x) and in Mathematica it is Arctan[x, y].

$$\phi = atan2(A_{12}, A_{11})$$ $$\theta = asin(-A_{13})$$ $$\psi = atan2(A_{23}, A_{33})$$