An airplane is flying in a know orientation and wants to go to another direction; what is the required pitch and roll?
OR:
With initial ZYX euler-angles (yaw, pitch and roll); how do I obtain the pitch and roll to obtain a specific direction vector?
The rotation matrix from the initial euler-angles:
$$R_0 = R_z( \varphi_{z,0} )R_y( \varphi_{y,0} ) R_x( \varphi_{x,0} )$$
We can calculate the initial vector:
$$\begin{bmatrix}x_0\\y_0\\z_0\end{bmatrix} = R_0 \cdot \begin{bmatrix}1\\0\\0\end{bmatrix}$$
I want to know $\varphi_{y,1}$ and $\varphi_{x,1}$, so:
$$R_1 = R_y( \varphi_{y,1} ) R_x( \varphi_{x,1} )$$
$$\begin{bmatrix}x_1\\y_1\\z_1\end{bmatrix} = R_1 \cdot \begin{bmatrix}x_0\\y_0\\z_0\end{bmatrix}$$
Where $\begin{bmatrix}x_1\\y_1\\z_1\end{bmatrix}$ is the known direction vector. (disclaimer: not sure if above notations are correct :/)
for example; the plane is flying in $\begin{bmatrix}\pi/2\\0\\0\end{bmatrix}$ (direction vector $\overline{X}_0=\begin{bmatrix}0\\1\\0\end{bmatrix}$);
to obtain vector $\overline{X}_1=\begin{bmatrix}-1\\0\\0\end{bmatrix}$, a solution is $\varphi_{y,1}=\pi/2$ and $\varphi_{x,1}=\pi/2$
OK... I think this is correct: $\varphi_{y,1}$ equals the dot product angle between the two vectors:
$$\cos \varphi_{y,1} = \frac{\overline{X}_0 \cdot \overline{X}_1}{\left|\left|\overline{X}_0\right|\right|\left|\left|\overline{X}_1\right|\right|}$$
We can project the second vector in the $x$-direction with the inversed rotation matrix:
$$\begin{bmatrix}x_1' \\ y_1' \\ z_1'\end{bmatrix} = _0^{-1} \cdot \begin{bmatrix}x_1 \\ y_1 \\ z_1\end{bmatrix}$$
Rotation around local $x$ is simply: $$\tan \varphi_{x,1} = \frac{y_1'}{z_1'}$$