# Find the rotation from two sets of 3 vectors?

I have three linearly independent vectors ($$\vec{a}$$, $$\vec{b}$$, and $$\vec{c}$$) which have been rotated to three other linearly independent vectors $$\vec{a}'$$, $$\vec{b}'$$, and $$\vec{c}'$$. I would like to find this rotation.

I've looked at quaternions but each pair of vectors $$\vec{a}$$ and $$\vec{a}'$$ yields different quaternions, non of which are correct.

For example, let $$\vec{a} = (1, 1, 4)$$, $$\vec{b} = (4, 1, -1)$$, $$\vec{c} = (-5, 17, -3)$$, $$\vec{a}' = (2.760834, 1, 3.062319)$$, $$\vec{b}' = (3.062319, 1, -2.760834)$$, and $$\vec{c}' = (-5.823153, -17, -0.301485)$$.

Using this method, I get $$q_{a} = 2.91634 + -0.160763i + 1.36833j + -0.301891k$$, $$q_{b} = 2.91634 + -0.301891i + 1.36833j + 0.160763k$$, and $$q_{c} = 12.6495 + 1.8133i + 0.630935j + 0.553128k$$.

The real rotation is 28 degree in the y axis.

My question is, is there a way of finding the angle of rotation and the axis of rotation, preferably in the form of quaternions but I don't mind, of these three vectors?

$$R\cdot(\vec{a},\vec{b},\vec{c})=(\vec{a}',\vec{b}',\vec{c}')$$
$$R=(\vec{a}',\vec{b}',\vec{c}')(\vec{a},\vec{b},\vec{c})^{-1}$$
Here $$R$$ is the rotation matrix, and $$(\vec{a},\vec{b},\vec{c})$$ is the matrix with the three vectors as columns