I have the unit vector $\begin{bmatrix} x \\ y \\ z \end{bmatrix}$ and I want to rotate a linear transformation which rotates it into the vector $\begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix}$. A simple matrix which I found to do the vector converting part is:
$$ \begin{bmatrix} 0 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$
but, the issue is that the above collapses whole of space into the $z$ line, I want the matrix which rotates the vector into the required without collapsing space.
There is an infinite number of possible rotation matrices, but there is one rotation matrix that has the minimum rotation angle, and that is generated as follows.
Let $u= \begin{bmatrix} x \\ y \\ z \end{bmatrix} $ and $ v = \begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix} $
Define the unit vector $w$ as the normalized cross product as follows
$ w = \dfrac{u \times v} { \| u \times v \| } $
Vector $w$ is the rotation axis. The rotation angle $\theta = \cos^{-1} u \cdot v $
Now the rotation matrix can be expressed using the Rodrigues' rotation matrix formula:
$R = w w^T + (I - w w ^T ) \cos \theta + S_w \sin \theta $
where
$S_w = \begin{bmatrix} 0 && - w_z && w_y \\ w_z && 0 && -w_x \\ -w_y && w_x && 0 \end{bmatrix}$
On the other hand, to obtain the rotation matrix with the maximum rotation angle of $180^\circ$, just use, as the rotation axis, the vector
$ w = \dfrac{ u + v }{\| u + v \| } $
And apply the Rodrigues' formula but with $\theta = 180^\circ$, which simplifies it into,
$ R = w w^T + (I - w w ^T ) (-1) + 0 = 2 w w^T - I $