Computing Euler angles between two 3D points from Cartesian coordinates We are given the three-dimensional cartesian coordinates of a point $A$, a point $B$ and a point $C$. The distance from $A$ to $B$ is the same as the distance from $A$ to $C$ ($|\vec{AB}| = |\vec{AC}|)$.
The goal is to compute the Euler angle triplet ($\phi$, $\theta$, $\psi$) which rotates the vector $\vec{AB}$ such that it aligns with $\vec{AC}$. These Euler angles describe a rotation around the $z$-axis followed by the $y$-axis and then finally the $x$-axis.
One approach would be to compute a rotation matrix $R$ that encompasses this rotation, and then compute the Euler angles by using $R$. This last step is described here: http://eecs.qmul.ac.uk/~gslabaugh/publications/euler.pdf and here https://web.mit.edu/2.05/www/Handout/HO2.PDF.
Then the question remains: how we do compute this general rotation matrix $R$ by only using the cartesian coordinates of $A$, $B$ and $C$?
If we had the Euler angles, we could compute $R = R_z(\phi)R_y(\theta)R_x(\psi)$.
The question is similar to this one: Reaching a point B in Cartesian coordinate via Euler angles knows its initial point A Euler angles and Cartesian coordinates. However, I do not understand how the answer of the question leads to the general rotation matrix $R$. Instead, it describes how one can compute rotation matrices which map the axis unit vectors $\hat{x}$, $\hat{y}$, $\hat{z}$ onto the normalised vector $\hat{AB}$.
Any help will be greatly appreciated!
 A: Project $\vec{AB}$ onto the $x,y$ plane.
Find the angle the projected vector makes with the $x$ axis.
Construct a vector in the $x,y$ plane of the same length as the projected vector,
but whose $y$ component is the same as the $y$ component of $\vec{AC}.$
For example, if the length of the projected vector is $r_1$ and the $y$ component of $\vec{AC}$ is $y_2,$ then a vector of length $r_1$ at angle $\arcsin(y_2/r_1)$ with the $x$ axis will do.
The $z$ rotation angle will be the difference between the angles these two vectors make with the $x$ axis. You will need to pay attention to the signs of angles in order to find a rotation angle of the correct magnitude and direction.
After performing the $z$ rotation on $\vec{AB},$ you will have a vector $v$ with the same $y$ coordinate as $\vec{AC}.$ Project both vectors onto the $x,z$ plane, measure their angles with the $x$ axis, and determine the rotation angle around the $y$ axis that rotates $v$ onto $\vec{AC}.$
You do not need a rotation around the $x$ axis.
A: You can find a nice simple formula for computing the rotation matrix from the two given vectors here.
Then the two references you cited tell you how to obtain Euler angles from any given rotation matrix. But you need to read carefully, because there are numerous different definitions of Euler angles.
