Given Tait–Bryan angles $ x-y'-z^{''} $ (intrinsic), how can i get Tait–Bryan angles $ z-y'-x^{''} $ (intrinsic)? I've been reading https://en.wikipedia.org/wiki/Euler_angles for hours and cannot figure out how to solve it. https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions#Euler_angles_.E2.86.94_quaternion gives formulas on conventions between ($ z-y′-x^{″} $ intrinsic) and Quaternion but I don't know how to calculate quaternion from $ x-y′-z^{″} $.
 A: With Tait-Bryan angles orientation representation with rotation order $xyz$, the rotation matrix is 
\begin{equation}\label{eq:euler-model-matrix}
%\hspace*{-6cm}
\begin{split}
R &= R_Z(\psi) R_Y(\theta)  R_X(\phi) \\
 &= 
\left[
\begin{array}{ccc}
\cos{\psi}  & -\sin{\psi} & 0 \\
\sin{\psi}  & \cos{\psi}  & 0 \\
0  & 0  & 1 \\
\end{array} \right]
\left[
\begin{array}{ccc}
\cos{\theta}  &  0 & \sin{\theta}  \\
0  & 1 & 0  \\
-\sin{\theta} & 0 & \cos{\theta}  \\
\end{array} \right]
\left[
\begin{array}{ccc}
1 & 0 & 0 \\
0 & \cos{\phi} & -\sin{\phi} \\
0 & \sin{\phi} &  \cos{\phi} \\
\end{array} \right] 
\\
&= 
\left[
\begin{array}{ccc}
\cos{\theta}\cos{\psi} & \cos{\psi} \sin{\theta} \sin{\phi} - \cos{\phi} \sin{\psi} & \cos{\phi} \cos{\psi} \sin{\theta} + \sin{\phi} \sin{\psi} \\
%
\cos{\theta}\sin{\psi} & \cos{\phi} \cos{\psi} + \sin{\theta} \sin{\phi} \sin{\psi} & \cos{\phi}\sin{\theta} \sin{\psi} - \cos{\psi} \sin{\phi} \\
%
-\sin{\theta}   & \cos{\theta}\sin{\phi} & \cos{\theta}\cos{\phi}
\end{array}
\right]
\end{split}
\end{equation}
With the $zyx$ rotation order, the same matrix is
$$
R =
\left[
\begin{array}{cccc}
\cos{\theta'}\cos{\phi'} & -\cos{\theta'}\sin{\phi'}  & \sin{\theta'}  \\
\cos{\psi'}\sin{\phi'}+ \cos{\phi'} \sin{\theta'}\sin{\psi'}  & \cos{\phi'}\cos{\psi'} - \sin{\theta'}\sin{\phi'}\sin{\psi'} & -\cos{\theta'}\sin{\psi'} \\
\sin{\phi'}\sin{\psi'}- \cos{\phi'}\cos{\psi'}\sin{\theta'}  & \cos{\psi'}\sin{\theta'}\sin{\phi'} + \cos{\phi'}\sin{\psi'} & \cos{\theta'}\cos{\psi'} \\
\end{array}
    \right]
$$
What you're asking is how to convert this to the $zyx$ rotation order. So let's assume that you have calculated the rotation matrix $R$ with the $xyz$ rotation order (the first method). We need to now interpret the angles as if you had created the matrix with the second method. It's relatively easy to extract the angles from the second matrix:
$$
\left\{
\begin{array}{ll}
\phi'  =& \arctan{\frac{-R_{01}}{R_{00}}}  \\
\theta'  =& \arcsin{R_{02}}  \\
\psi'=& \arctan{\frac{-R_{12}}{R_{22}}}  \\
\end{array}
\right.
$$ 
Note that the entries here are from the second $R$-matrix. I've added the prime symbol to these angles to denote that they are the angles of the $zyx$-rotation order. The non-prime angle symbols are from the $xyz$-rotation order. Now we can plug in the values from the first matrix to obtain
$$
\left\{
\begin{array}{ll}
\phi'  =& \arctan{\frac{-\cos{\psi} \sin{\theta} \sin{\phi} + \cos{\phi} \sin{\psi}}{\cos{\theta}\cos{\psi} }}  \\
\theta'  =& \arcsin{\left( \cos{\phi} \cos{\psi} \sin{\theta} + \sin{\phi} \sin{\psi}  \right)}  \\
\psi'=& \arctan{\frac{-\cos{\phi}\sin{\theta} \sin{\psi} + \cos{\psi} \sin{\phi} }{\cos{\theta}\cos{\phi}}}  \\
\end{array}
\right.
$$ 
You might want to double-check these results yourself, as there are quite many terms.
