Derive a transformation matrix that mirrors the image over a line passing through the origin with angle $\phi$ to the $x$-axis. Question: Using homogeneous coordinates, derive a $3$x$3$ transformation matrix $M$ that mirrors an image over a line passing through the origin, with angle $\phi$ to the $x$-axis.
Comment: This is from an old exam in computer graphics. I don't remember how we did this back in linear algebra so I'd be grateful if someone could show me the steps. If you don't know what "homogeneous coordinates" means, pay no attention to it, a $2$x$2$ transformation matrix without homogenous coordinates would suffice and I can do the rest.

If vector $A$ is reflected across vector $B$ to create vector $C$,


*

*The  midpoint of $A$ and $C$ is along $B$:
$C + (A - C)/2 \in kB$, so $A + C \in kB$

*Length is preserved: $|A| = |C|$


Your $B$ vector is $\begin{bmatrix} \cos(\phi) \\ \sin(\phi)\end{bmatrix}$
First consider the x-axis unit: $e_1 = \begin{bmatrix} 1 \\ 0 \end{bmatrix}$ translates to $f(e_1) =  \begin{bmatrix} a \\ b \end{bmatrix}$:
$$\begin{bmatrix} 1 \\ 0 \end{bmatrix} + \begin{bmatrix} a \\ b \end{bmatrix} = k\begin{bmatrix} \cos(\phi) \\ \sin(\phi)\end{bmatrix}$$
$$\begin{cases} a + 1 = k \cos(\phi) \\
                b = k \sin(\phi) \\
                a^2 + b^2 = 1 \quad \text{(because length is preserved)}
\end{cases}$$
$$\downarrow$$
$$\begin{cases} k = 2\cos(\phi) \\
 a = 2\cos(\phi)^2 - 1 \\
 b = 2\cos(\phi)\sin(\phi)
\end{cases}$$
Same for the y-unit $e_2 = \begin{bmatrix} 0 \\ 1 \end{bmatrix}$ translates to $f(e_2) =  \begin{bmatrix} c \\ d \end{bmatrix}$:
$$\begin{bmatrix} 0 \\ 1 \end{bmatrix} + \begin{bmatrix} c \\ d \end{bmatrix} = k\begin{bmatrix} \cos(\phi) \\ \sin(\phi)\end{bmatrix}$$
$$\begin{cases} c = k \cos(\phi) \\
                d + 1 = k \sin(\phi) \\
                c^2 + d^2 = 1 \quad \text{(again because length is preserved)}
\end{cases}$$
$$\downarrow$$
$$\begin{cases} k = 2\sin(\phi) \\
 c = 2\cos(\phi)\sin(\phi) \\
 d = 2\sin(\phi)^2 - 1
\end{cases}$$
Since we know that $f(v) = f(xe_1 + ye_2) = xf(e_1) + yf(e_2)$, it follows:
$$\begin{align}
f\left(\begin{bmatrix} x \\ y \end{bmatrix}\right) &= \begin{bmatrix} 2\cos(\phi)^2 - 1 & 2\cos(\phi)\sin(\phi) \\ 2\cos(\phi)\sin(\phi) & 2\sin(\phi)^2 - 1\end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} \\
&= \begin{bmatrix} \cos(2\phi) & \sin(2\phi) \\ \sin(2\phi) & -\cos(2\phi)\end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} \\
\end{align}$$
