Equations of the orthogonal projection on the line $r = y - 2x + 1 = 0$ I'm trying to calculate in the Euclidean affine plane with respect to an orthonormal reference the equations of the orthogonal projection on the line r of equation y - 2x + 1 = 0.
So, let $\phantom{3}r = y-2x+1=0 \phantom{3}$ and $\phantom{3}Q = (x,y)$
We have that the direction of the line perpendicular to $r$ is $L[(1,-2)]$
Then $P_r(Q) = (x,y) + \lambda(1,-2) \phantom{10} \lambda \in \mathbb{R}$
Is it correct?
 A: Let us answer to the generalized form of your question:

How can one find the orthogonal projection of a point $Q=(x_0, y_0)$ onto a line $l: y=mx+b$?

We can find the coordinates of the orthogonal projection by finding the intersection point of the given line and the line perpendicular to the given line and passing through the given point.
As we know, the line perpendicular to the line $y=mx+b$ and passing through the point $Q=(x_0, y_0)$ is of the form$$l_o: y=m_o(x-x_0)+y_0, \qquad m_o=-\frac{1}{m}.$$Now, we can find the intersection point by solving the following system of equations:$$\begin{cases}y=mx+b \\ y=-\frac{1}{m}(x-x_0)+y_0 \end{cases} \quad \Rightarrow \quad \begin{cases}x=\frac{x_0+my_0+mb}{m^2+1} \\ y=\frac{mx_0+m^2y_0+2bm^2+b}{m^2+1} \end{cases}.$$Thus, the orthogonal projection of the point $Q=(x_0, y_0)$ onto the line $l: y=mx+b$ is the point$$P=(x_P, y_P)=\left ( \frac{x_0+my_0+mb}{m^2+1}, \frac{mx_0+m^2y_0+2bm^2+b}{m^2+1}\right ).$$

For the mentioned example in the question, we have $m=2$ and $b=-1$. So the coordinates of the orthogonal projection becomes$$P=(x_P, y_P)=\left ( \frac{x_0+2y_0-2}{5}, \frac{2x_0+4y_0-9}{5}\right ).$$
