Transformation matrix to go from one vector to another I've two vectors $a = (a_1, a_2, a_3)$ and $b = (b_1, b_2, b_3)$. How to find  transformation matrix for transform from a to b?
 A: One can use axis-angle representation to get the rotation matrix.
$$Rot(u,\phi)=I \cos\phi + u u^T(1-\cos\phi) + \hat{u}\sin\phi$$
where $u$ is unit axis vector and $\phi$ is angle of rotation.
To find axis vector you need to use cross product of given two vectors $(\overline a\times\overline b)$, and from this cross product you can get first $\sin\phi$ and then $\cos\phi$.


*

*Rodrigues' rotation formula

*Hat operator
A: Try using the dyadic product, the definition is
$$
    \mathbf{a b} \equiv \mathbf{a}\otimes\mathbf{b} \equiv \mathbf{a b}^\mathrm{T} = \begin{pmatrix} a_1 \\ a_2 \\ a_3 \end{pmatrix}\begin{pmatrix} b_1 & b_2 & b_3 \end{pmatrix} = \begin{pmatrix} a_1b_1 & a_1b_2 & a_1b_3 \\ a_2b_1 & a_2b_2 & a_2b_3 \\ a_3b_1 & a_3b_2 & a_3b_3 \end{pmatrix}. 
$$
You can construct the rotation matrix $\mathbf{R}$ you're looking for as following
$$
\mathbf{b} = \mathbf{R} \mathbf{a} \\ \\
\begin{pmatrix} b_1 \\ b_2 \\ b_3 \end{pmatrix} = 
\frac{1}{3}
\begin{pmatrix} 
\frac{1}{a_1}b_1 & \frac{1}{a_2}b_1 & \frac{1}{a_3}b_1 \\ 
\frac{1}{a_1}b_2 & \frac{1}{a_2}b_2 & \frac{1}{a_3}b_2 \\ 
\frac{1}{a_1}b_3 & \frac{1}{a_2}b_3 & \frac{1}{a_3}b_3
\end{pmatrix}
\begin{pmatrix} a_1 \\ a_2 \\ a_3 \end{pmatrix}
\\
\mathbf{R} = 
\frac{1}{3}
\begin{pmatrix} b_1 \\ b_2 \\ b_3 \end{pmatrix}
\begin{pmatrix} \frac{1}{a_1} & \frac{1}{a_2} & \frac{1}{a_3} \end{pmatrix}
$$
