OpenLLM-France/wikimedia huggingface dataset:
# PlanetPhysics/Direction Cosine Matrix to Euler 212 Sequence

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 212 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 212 sequence is
   $R_{2}(\psi )R_{1}(\theta )R_{2}(\phi )=\left[{\begin{matrix}c_{\psi }c_{\phi }-s_{\psi }c_{\theta }s_{\phi }&s_{\psi }s_{\theta }&-c_{\psi }s_{\phi }-s_{\psi }c_{\theta }c_{\phi }\\s_{\theta }s_{\phi }&c_{\theta }&s_{\theta }c_{\phi }\\s_{\psi }c_{\phi }+c_{\psi }c_{\theta }s_{\phi }&-c_{\psi }s_{\theta }&-s_{\psi }s_{\phi }+c_{\psi }c_{\theta }c_{\phi }\end{matrix}}\right]$
If we examine the element in coloum 2 row 2, then by inspection
$A_{22}=cos(\theta )$
Solving for $\theta$ yields
   $\theta =cos^{-1}(A_{22})$
Care must now be taken when evaluating the inverse cosine. It is a multivalued function. Analytically, the convention is to choose the principle value such that
$0\leq \theta \leq \pi$
If a numerical program is used, a function acos usually does this for us. The next step is to analyze the ratio ${\frac {A_{21}}{A_{23}}}$. Using these values from the Euler sequence we get
${\frac {A_{21}}{A_{23}}}={\frac {sin(\theta )sin(\phi )}{sin(\theta )cos(\phi )}}$
Rearranging the minus sign and using the tangent yields
$tan(\phi )={\frac {A_{21}}{A_{23}}}$
Solving the quadrant ambiquity 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 </math> \left[ \begin{matrix} y & x \\ + & + \\ \end{matrix} \right] $soifxandyarebothpositive,then<math>0\leq \phi \leq \pi /2$. Similarily for the other quadrant possibilites
quadrant 2 </math> \left[ \begin{matrix} y & x \\ + & - \\ \end{matrix} \right] $quadrant3$ \left[ \begin{matrix} y & x \\ - & - \\ \end{matrix} \right] $quadrant4$ \left[ \begin{matrix} y & x \\ - & + \\ \end{matrix} \right] $Ofcourse,itismuchsimpliertouseacalculatorornumericalprogramthatusestheatan2functionwhichwillchoosetheprinciplevalue.InasimilarfashionwecanfindthefinalEuleranglebylookingattheratio<math>{\frac {A_{12}}{A_{32}}}$ which gives the relation ${\frac {A_{12}}{A_{32}}}={\frac {sin(\psi )sin(\theta )}{-cos(\psi )sin(\theta )}}$
Canceling terms and rearrangeing gives us
$\psi =tan^{-1}({\frac {A_{12}}{-A_{32}}})$
which uses the same method to resolove quadrant ambiguity as above. To summarize, we will give the formulas for the conversion from a direction cosine matrix to the Euler 212 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_{21},A_{23})$ $\theta =acos(A_{22})$ $\psi =atan2(A_{12},-A_{32})$
# PlanetPhysics/Direction Cosine Matrix to Euler 213 Sequence

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 213 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 213 sequence is
   $R_{3}(\psi )R_{1}(\theta )R_{2}(\phi )=\left[{\begin{matrix}c_{\psi }c_{\phi }+s_{\psi }s_{\theta }s_{\phi }&s_{\psi }c_{\theta }&-c_{\psi }s_{\phi }+s_{\psi }s_{\theta }c_{\phi }\\-s_{\psi }c_{\phi }+c_{\psi }s_{\theta }s_{\phi }&c_{\psi }c_{\theta }&s_{\psi }s_{\phi }+c_{\psi }s_{\theta }c_{\phi }\\c_{\theta }s_{\phi }&-s_{\theta }&c_{\theta }c_{\phi }\end{matrix}}\right]$
If we examine the element in coloum 2 row 3, then by inspection
$A_{32}=-sin(\theta )$
Solving for $\theta$ yields
   $\theta =sin^{-1}(-A_{32})$
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\leq \theta \leq \pi /2$
If a numerical program is used, a function asin usually does this for us. The next step is to analyze the ratio ${\frac {A_{31}}{A_{33}}}$. Using these values from the Euler sequence we get
${\frac {A_{31}}{A_{33}}}={\frac {cos(\theta )sin(\phi )}{cos(\theta )cos(\phi )}}$
Rearranging the minus sign and using the tangent yields
$tan(\phi )={\frac {A_{31}}{A_{33}}}$
Solving the quadrant ambiquity 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\leq \phi \leq \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_{12}}{A_{22}}}$ which gives the relation ${\frac {A_{12}}{A_{22}}}={\frac {sin(\psi )cos(\theta )}{cos(\psi )cos(\theta )}}$
Cancelling terms and rearranging gives us
$\psi =tan^{-1}({\frac {A_{12}}{A_{22}}})$
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 213 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_{31},A_{33})$ $\theta =asin(-A_{32})$ $\psi =atan2(A_{12},A_{22})$
# PlanetPhysics/Direction Cosine Matrix to Euler 312 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 312 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 312 sequence is
   $R_{2}(\psi )R_{1}(\theta )R_{3}(\phi )=\left[{\begin{matrix}c_{\psi }c_{\phi }-s_{\psi }s_{\theta }s_{\phi }&c_{\psi }s_{\phi }+s_{\psi }s_{\theta }c_{\phi }&-s_{\psi }c_{\theta }\\-s_{\phi }c_{\theta }&c_{\theta }c_{\phi }&s_{\theta }\\s_{\psi }c_{\phi }+c_{\psi }s_{\theta }s_{\phi }&s_{\psi }s_{\phi }-c_{\psi }s_{\theta }c_{\phi }&c_{\psi }c_{\theta }\end{matrix}}\right]$
If we examine the element in coloum 3 row 2, then by inspection
$A_{23}=sin(\theta )$
Solving for $\theta$ yields
   $\theta =sin^{-1}(A_{23})$
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\leq \theta \leq \pi /2$
If a numerical program is used, a function asin usually does this for us. The next step is to analyze the ratio ${\frac {A_{21}}{A_{22}}}$. Using these values from the Euler sequence we get
${\frac {A_{21}}{A_{22}}}={\frac {-sin(\phi )cos(\theta )}{cos(\phi )cos(\theta )}}$
Rearranging the minus sign and using the tangent yields
$tan(\phi )={\frac {-A_{21}}{A_{22}}}$
Solving the quadrant ambiquity 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\leq \phi \leq \pi /2$. Similarily for the other quadrant possibilites
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]$
Ofcourse, it is much simplier 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_{13}}{A_{33}}}$ which gives the relation ${\frac {A_{13}}{A_{33}}}={\frac {-sin(\psi )cos(\theta )}{cos(\psi )cos(\theta )}}$
Canceling terms and rearrangeing gives us
$\psi =tan^{-1}({\frac {-A_{13}}{A_{33}}})$
which uses the same method to resolove quadrant ambiguity as above. To summarize, we will give the formulas for the conversion from a direction cosine matrix to the Euler 312 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_{21},A_{22})$ $\theta =asin(A_{23})$ $\psi =atan2(-A_{13},A_{33})$
# PlanetPhysics/Direction Cosine Matrix to Euler 121 Sequence

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 121 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 121 sequence is
   $R_{1}(\psi )R_{2}(\theta )R_{1}(\phi )=\left[{\begin{matrix}c_{\theta }&-s_{\theta }s_{\phi }&s_{\theta }c_{\phi }\\-s_{\psi }s_{\theta }&c_{\psi }c_{\phi }-s_{\psi }c_{\theta }s_{\phi }&c_{\psi }s_{\phi }+s_{\psi }c_{\theta }c_{\phi }\\-s_{\theta }c_{\psi }&-s_{\psi }c_{\phi }-c_{\psi }c_{\theta }s_{\phi }&-s_{\psi }s_{\phi }+c_{\psi }c_{\theta }c_{\phi }\end{matrix}}\right]$
If we examine the element in coloum 1 row 1, then by inspection
$A_{11}=cos(\theta )$
Solving for $\theta$ yields
   $\theta =cos^{-1}(A_{11})$
Care must now be taken when evaluating the inverse cosine. It is a multivalued function. Analytically, the convention is to choose the principle value such that
$0\leq \theta \leq \pi$
If a numerical program is used, a function acos usually does this for us. The next step is to analyze the ratio ${\frac {A_{12}}{A_{13}}}$. Using these values from the Euler sequence we get
${\frac {A_{12}}{A_{13}}}={\frac {-sin(\theta )sin(\phi )}{sin(\theta )cos(\phi )}}$
Rearranging the minus sign and using the tangent yields
$tan(\phi )={\frac {-A_{12}}{A_{13}}}$
Solving the quadrant ambiquity 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 </math> \left[ \begin{matrix} y & x \\ + & + \\ \end{matrix} \right] $soifxandyarebothpositive,then<math>0\leq \phi \leq \pi /2$. Similarily for the other quadrant possibilites
quadrant 2 </math> \left[ \begin{matrix} y & x \\ + & - \\ \end{matrix} \right] $quadrant3$ \left[ \begin{matrix} y & x \\ - & - \\ \end{matrix} \right] $quadrant4$ \left[ \begin{matrix} y & x \\ - & + \\ \end{matrix} \right] $Ofcourse,itismuchsimpliertouseacalculatorornumericalprogramthatusestheatan2functionwhichwillchoosetheprinciplevalue.InasimilarfashionwecanfindthefinalEuleranglebylookingattheratio<math>{\frac {A_{21}}{A_{31}}}$ which gives the relation ${\frac {A_{21}}{A_{31}}}={\frac {-sin(\psi )sin(\theta )}{-sin(\theta )cos(\psi )}}$
Canceling terms and rearrangeing gives us
$\psi =tan^{-1}({\frac {-A_{21}}{A_{31}}})$
which uses the same method to resolove quadrant ambiguity as above. To summarize, we will give the formulas for the conversion from a direction cosine matrix to the Euler 121 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_{13})$ $\theta =acos(A_{11})$ $\psi =atan2(A_{21},A_{31})$
# PlanetPhysics/Direction Cosine Matrix to Euler 131 Sequence

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 131 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 131 sequence is
   $R_{1}(\psi )R_{3}(\theta )R_{1}(\phi )=\left[{\begin{matrix}c_{\theta }&s_{\theta }c_{\phi }&s_{\theta }s_{\phi }\\-c_{\psi }s_{\theta }&c_{\psi }c_{\theta }c_{\phi }-s_{\psi }s_{\phi }&c_{\psi }c_{\theta }s_{\phi }+s_{\psi }c_{\phi }\\s_{\psi }s_{\theta }&-s_{\psi }c_{\theta }c_{\phi }-c_{\psi }s_{\phi }&-s_{\psi }c_{\theta }s_{\phi }+c_{\psi }c_{\phi }\end{matrix}}\right]$
If we examine the element in coloum 1 row 1, then by inspection
$A_{11}=cos(\theta )$
Solving for $\theta$ yields
   $\theta =cos^{-1}(A_{11})$
Care must now be taken when evaluating the inverse cosine. It is a multivalued function. Analytically, the convention is to choose the principle value such that
$0\leq \theta \leq \pi$
If a numerical program is used, a function acos usually does this for us. The next step is to analyze the ratio ${\frac {A_{13}}{A_{12}}}$. Using these values from the Euler sequence we get
${\frac {A_{13}}{A_{12}}}={\frac {sin(\theta )sin(\phi )}{sin(\theta )cos(\phi )}}$
Rearranging and using the tangent yields
$tan(\phi )={\frac {A_{13}}{A_{12}}}$
Solving the quadrant ambiquity 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 </math> \left[ \begin{matrix} y & x \\ + & + \\ \end{matrix} \right] $soifxandyarebothpositive,then<math>0\leq \phi \leq \pi /2$. Similarily for the other quadrant possibilites
quadrant 2 </math> \left[ \begin{matrix} y & x \\ + & - \\ \end{matrix} \right] $quadrant3$ \left[ \begin{matrix} y & x \\ - & - \\ \end{matrix} \right] $quadrant4$ \left[ \begin{matrix} y & x \\ - & + \\ \end{matrix} \right] $Ofcourse,itismuchsimpliertouseacalculatorornumericalprogramthatusestheatan2functionwhichwillchoosetheprinciplevalue.InasimilarfashionwecanfindthefinalEuleranglebylookingattheratio<math>{\frac {A_{31}}{A_{21}}}$ which gives the relation ${\frac {A_{31}}{A_{21}}}={\frac {sin(\psi )sin(\theta )}{-cos(\psi )sin(\theta )}}$
Canceling terms and rearrangeing gives us
$\psi =tan^{-1}({\frac {A_{31}}{-A_{21}}})$
which uses the same method to resolove quadrant ambiguity as above. To summarize, we will give the formulas for the conversion from a direction cosine matrix to the Euler 131 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_{13},A_{12})$ $\theta =acos(A_{11})$ $\psi =atan2(A_{31},-A_{21})$
# PlanetPhysics/Direction Cosine Matrix to Euler 231 Sequence

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 231 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 231 sequence is
   $R_{1}(\psi )R_{3}(\theta )R_{2}(\phi )=\left[{\begin{matrix}c_{\theta }c_{\phi }&s_{\theta }&-c_{\theta }s_{\phi }\\-c_{\psi }s_{\theta }c_{\phi }+s_{\psi }s_{\phi }&c_{\psi }c_{\theta }&c_{\psi }s_{\theta }s_{\phi }+s_{\psi }s_{\theta }s_{\phi }\\s_{\psi }s_{\theta }c_{\phi }+c_{\psi }s_{\phi }&-s_{\psi }c_{\theta }&-s_{\psi }s_{\theta }s_{\phi }+c_{\psi }c_{\phi }\end{matrix}}\right]$
If we examine the element in coloum 2 row 1, then by inspection
$A_{12}=sin(\theta )$
Solving for $\theta$ yields
   $\theta =sin^{-1}(A_{12})$
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\leq \theta \leq \pi /2$
If a numerical program is used, a function asin usually does this for us. The next step is to analyze the ratio ${\frac {A_{13}}{A_{11}}}$. Using these values from the Euler sequence we get
${\frac {A_{13}}{A_{11}}}={\frac {-cos(\theta )sin(\phi )}{cos(\theta )cos(\phi )}}$
Rearranging the minus sign and using the tangent yields
$tan(\phi )={\frac {-A_{13}}{A_{11}}}$
Solving the quadrant ambiquity 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 </math> \left[ \begin{matrix} y & x \\ + & + \\ \end{matrix} \right] $soifxandyarebothpositive,then<math>0\leq \phi \leq \pi /2$. Similarily for the other quadrant possibilites
quadrant 2 </math> \left[ \begin{matrix} y & x \\ + & - \\ \end{matrix} \right] $quadrant3$ \left[ \begin{matrix} y & x \\ - & - \\ \end{matrix} \right] $quadrant4$ \left[ \begin{matrix} y & x \\ - & + \\ \end{matrix} \right] $Ofcourse,itismuchsimpliertouseacalculatorornumericalprogramthatusestheatan2functionwhichwillchoosetheprinciplevalue.InasimilarfashionwecanfindthefinalEuleranglebylookingattheratio<math>{\frac {A_{32}}{A_{22}}}$ which gives the relation ${\frac {A_{32}}{A_{22}}}={\frac {-sin(\psi )cos(\theta )}{cos(\psi )cos(\theta )}}$
Canceling terms and rearrangeing gives us
$\psi =tan^{-1}({\frac {-A_{32}}{A_{22}}})$
which uses the same method to resolove quadrant ambiguity as above. To summarize, we will give the formulas for the conversion from a direction cosine matrix to the Euler 231 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_{13},A_{11})$ $\theta =asin(A_{12})$ $\psi =atan2(-A_{32},A_{22})$
# PlanetPhysics/Direction Cosine Matrix to Euler 123 Sequence

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 123 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 123 sequence is
   $R_{3}(\psi )R_{2}(\theta )R_{1}(\phi )=\left[{\begin{matrix}c_{\psi }c_{\theta }&c_{\psi }s_{\theta }s_{\phi }+s_{\psi }c_{\phi }&-c_{\psi }s_{\theta }c_{\phi }+s_{\psi }s_{\phi }\\-s_{\psi }c_{\theta }&-s_{\psi }s_{\theta }s_{\phi }+c_{\psi }c_{\phi }&s_{\psi }s_{\theta }c_{\phi }+c_{\psi }s_{\phi }\\s_{\theta }&-c_{\theta }s_{\phi }&c_{\theta }c_{\phi }\end{matrix}}\right]$
If we examine the element in coloum 1 row 3, then by inspection
$A_{31}=sin(\theta )$
Solving for $\theta$ yields
   $\theta =sin^{-1}(A_{31})$
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\leq \theta \leq \pi /2$
If a numerical program is used, a function asin usually does this for us. The next step is to analyze the ratio ${\frac {A_{32}}{A_{33}}}$. Using these values from the Euler sequence we get
${\frac {A_{32}}{A_{33}}}={\frac {-sin(\phi )cos(\theta )}{cos(\phi )cos(\theta )}}$
Rearranging the minus sign and using the tangent yields
$tan(\phi )={\frac {-A_{32}}{A_{33}}}$
Solving the quadrant ambiquity 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\leq \phi \leq \pi /2$. Similarily for the other quadrant possibilites
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]$
Ofcourse, it is much simplier 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_{21}}{A_{11}}}$ which gives the relation ${\frac {A_{21}}{A_{11}}}={\frac {-cos(\theta )sin(\psi )}{cos(\theta )cos(\psi )}}$
Canceling terms and rearrangeing gives us
$\psi =tan^{-1}({\frac {-A_{21}}{A_{11}}})$
which uses the same method to resolove quadrant ambiguity as above. To summarize, we will give the formulas for the conversion from a direction cosine matrix to the Euler 123 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_{32},A_{33})$ $\theta =asin(A_{31})$ $\psi =atan2(-A_{21},A_{11})$