# Linear transformation for projection of a point on a line

This is what my textbook wants me to do:

The matrix of the linear transformation $P_L$ that projects $\mathbb{R}^2$ on de straight line $l \leftrightarrow y = mx$ is:

\begin{pmatrix} \frac{1}{1+m^2} & \frac{m}{1+m^2} \\ \frac{m}{1+m^2} & \frac{m^2}{1+m^2} \\ \end{pmatrix}

And I get this picture, which probably is their to inspire me:

Now, I tried to tackle this with the perpendicular line between A and C, but I got nowhere:

\begin{align*} A &= (x_A, y_A) \\ &\Downarrow \\ AC \leftrightarrow y - y_A &= \frac{-1}{m}(x - x_A) \\ &\Downarrow \\ C &\leftrightarrow \begin{cases} y = \frac{-x}{m} + \frac{x_A}{m} + y_A \\ y = mx \\ \end{cases} \end{align*}

But that's were I am stuck, I can't get it to the form

\begin{align*} \begin{bmatrix} x_C \\ y_C \end{bmatrix} &= \begin{bmatrix} \frac{1}{1+m^2} & \frac{m}{1+m^2} \\ \frac{m}{1+m^2} & \frac{m^2}{1+m^2} \\ \end{bmatrix} \begin{bmatrix} x_A \\ y_A \end{bmatrix} \end{align*}

I am probably not doing it right. All tips are greatly appreciated.

-

If you substitute your second equation into your first, you find $$mx=-\frac{x}{m}+\frac{x_A}{m}+y_A,$$ so $$\frac{1+m^2}{m}x=\frac{x_A}{m}+y_A,$$ and so $$x=\frac{1}{1+m^2}x_A+\frac{m}{1+m^2}y_A,\tag{\star}$$ which corresponds to what your first row should be.
Once you've found that, use $(\star)$ to substitute into your second equation, and you readily see that $$y=\frac{m}{1+m^2}x_A+\frac{m^2}{1+m^2}y_A,$$ which corresponds to the second row.