System coordinate rotation, using a vector's value [closed]

Solution 1:

As first step note that, if $\vec v_A=(x_A,y_A,z_A)$ and $\vec v_B=(x_B,y_B,z_B)$ are the two set of coordinates tat you know, then you can consider $\vec v_B$ as obtained from $\vec v_A$ with an active rotation $R$. The corresponding rotation of the reference system (passive rotation) that you want is the inverse rotation $R^{-1}$.

Now you can find the axis of rotation as the unit vector orthogonal to the two vectors $\vec v_A$ and $\vec v_B$: $$ \vec u= \frac{\vec v_A \times \vec v_B}{||\vec v_A \times \vec v_B||} $$ (where $ \cdot\times\cdot$ is the cross product). And the angle of rotation can be found from the dot product $$ \theta= \arccos \left(\frac{\vec v_a \cdot \vec v_B}{||\vec v_A|| ||v_B||}\right) $$

From this you can find the matrix that represents the rotation.