I originally wanted to derive a general rotation matrix that can transform a given 3-vector into another specified 3-vector of equal length. In failing to do so, I derived a matrix that contains information about the axis and angle of rotation. I wanted to share my matrix and ask for confirmation that such a matrix can always be found for two equal length nonzero 3-vectors.
Although my matrix is not a rotation matrix, I find my matrix to be valuable for its ease of use, especially in comparison to the standard method, or Rodrigues' rotation formula.
Let $\vec{u} = (x,y,z), \vec{v}=(p,q,r)$ . Then the relationship between $\vec{u}$ and $\vec{v}$ can be expressed as $$ \frac{1}{d} \begin{bmatrix} d\cos\theta & -c\sin\theta & b\sin\theta \\c\sin\theta & d\cos\theta & -a\sin\theta \\\ -b\sin\theta & a\sin\theta & d\cos\theta\end{bmatrix} \begin{bmatrix} p \\\ q \\\ r\end{bmatrix}=\begin{bmatrix} x\\y\\z\end{bmatrix} $$ where $d=\sqrt{a^2+b^2+c^2}$, $(a,b,c)$ is orthogonal to the plane containing $\vec{u}$ and $\vec{v}$, and $\theta$ is the angle between $\vec{u}$ and $\vec{v}$.
My derivation is as follows:
Let $\vec{v}=(p,q,r)$ be a non-zero 3-vector. Pick a unit vector $\vec{a}=(a,b,c)$ orthogonal to it.
Then $(x,y,z)=\vec{v}\cos(\theta)+\vec{a}$x$\vec{v}\sin(\theta)$
So
$ \begin{bmatrix} p\cos(\theta) \\\ q\cos(\theta) \\\ r\cos(\theta)\end{bmatrix}+ \begin{bmatrix} (br-cq)\sin(\theta) \\\ (cp-ar)\sin(\theta)\\\ (aq-bp)\sin(\theta)\end{bmatrix}=\begin{bmatrix} x\\y\\z\end{bmatrix} $
I should add that since learning about Rodrigues' rotation formula I now understand how to derive the general rotation matrix that I originally set out to derive.