Derive equations for the roll, pitch, and yaw angles? How to derive equations for the roll, pitch, and yaw angles corresponding to the rotation matrix R having ijth element rij?
 A: Taking forward-backwards as the $x$-axis and roll is rotations about the $x$- axis
\begin{eqnarray*}
R_x(r)= \left(
\begin{array}{ccc}
1 & 0 & 0  \\
0 & \cos(r) & \sin(r) \\
0 & -\sin(r) & \cos(r) \\
\end{array} \right)
\end{eqnarray*}
Taking left-right as the $y$-axis and pitch is rotations about the $y$-axis
\begin{eqnarray*}
R_y(p)= \left(
\begin{array}{ccc}
\cos(p) & 0 & -\sin(p)  \\
0 & 1 & 0 \\
\sin(p) & 0 & \cos(p) \\
\end{array} \right)
\end{eqnarray*}
Taking up-down as the $z$-axis and yaw is rotations about the $z$-axis
\begin{eqnarray*}
R_z(y) =\left(
\begin{array}{ccc}
\cos(y) & \sin(y) & 0  \\
-\sin(y) & \cos(y) & 0 \\
0 & 0 & 1  
\end{array}\right)
\end{eqnarray*}
Do the matrix multiplication ...
\begin{eqnarray*}
R_z(y) R_y(p) R_x(r) = \\ \left(
\begin{array}{ccc}
\cos(y) \cos(p) & \cos(y)\sin(p)\sin(r)+\sin(y)\cos(r) & -\cos(y)\sin(p)\cos(r)+\sin(y)\sin(r)  \\
-\sin(y\cos(p)) & -\sin(y)\sin(p)\sin(r)+\cos(y)\cos(r) & \sin(y)\sin(p)\cos(r)+\cos(y)\cos(r) \\
\sin(p) & \sin(r)\cos(p) & \cos(p)\cos(r) 
\end{array} \right)
\end{eqnarray*}
Your rotation matrix should have the structure above. The angles can be deduced from the following formulea
\begin{eqnarray*}
p =\sin^{-1}( R_{1,3}) \\
r= \cos^{-1}(\frac{R_{3,3}}{\cos(p)}) \\
y= \cos^{-1}(\frac{R_{1,1}}{\cos(p)}) \\
\end{eqnarray*}
You should check the other component satisfy this structure. 
