Let $n = (n_1, n_2, n_3) \in \mathbb{R}^3 \setminus \left\{0\right\}$. I want to define a linear map $f: \mathbb{R}^3 \rightarrow \mathbb{R}^3$, $f(x)=Ax$, which maps the xy-plane $z = 0$ to the plane $$n_1 x+n_2 y+n_3z =0,$$ i.e., rotates the xy-plane so that the resulting plane has the normal vector $n$ and still contains the origin.
However, I am unable to derive a general formula for the rotation matrix $A\in \mathbb{R}^{3\times 3}$. As $e_1 = (1, 0, 0)$ and $e_2 = (0, 1, 0)$ span the xy-plane, $Ae_1$ and $Ae_2$ span the rotated plane. I suppose that one could use the properties $$Ae_1 \times Ae_2 = n,$$ $$Ae_1 \cdot Ae_2 =e_1^T A^T A e_2 = 0,$$ and $$\Vert Ae_1 \Vert = \Vert Ae_2 \Vert = 1,$$ but the derivation of $A$ seems to become very complicated.
Any help would be appreciated.
Find a vector that is orthogonal to $N = (n_1, n_2, n_3)$, for example,
$V = (- n_2, n_1, 0) $
and define $W$ as follows
$W = N \times V = (n_1, n_2, n_3) \times (-n_2, n_1, 0) $
Then
$ W = (- n_1 n_3 , - n_2 n_3, n_1^2 + n_2^2 ) $
Next normalize both $V$ and $W$ to obtain $u_1$ and $u_2$ , i.e.
$ u_1 = \dfrac{V}{\| V \| } $
$ u_2 = \dfrac{W}{\| W \| } $
also normalize $N$ to obtain $u_3$
$ u_3 = \dfrac{N}{ \| N \| } $
Now the matrix $A$ is simply given by
$ A = [u_1, u_2, u_3] $