Find rotation that maps a point to its target

I have a 3D point that is rotated about the $x$-axis and after that about the $y$-axis. I know the result of this transformation. Is there an analytical way to compute the rotation angles?

Here, $v$ and $v’$ are known and I want to compute $\alpha$ and $\beta$. $R_x$ and $R_y$ are the rotation matrices about the x and y axis respectively. The overall matrix will then be:

\cos \beta & \sin\alpha * \sin\beta & \cos\alpha * \sin\beta \\
0 & \cos \alpha & -\sin\alpha \\
-\sin\beta & \cos\beta * \sin\alpha & \cos\alpha * \cos\beta \end{pmatrix}

Solutions Collecting From Web of "Find rotation that maps a point to its target"

Rotation about the $y$ axis won’t change the $y$ coordinate anymore, so the first rotation has to get that coordinate right straight away. There are in general two angles that do the job, but there might be none, namely if $\sqrt{v_y^2+v_z^2}<|v’_y|$. If there are such angles, then for each there will be a unique rotation about the $y$ axis that gets the vector to the destination $v’$, provided we had $|v|=|v’|$ to begin with, which is of course a necessary condition to succeed with any number of rotations fixing the origin. You can easily write down the required angles using inverse trigonometric functions.