Orthogonal projection of point onto line not through origin 
What is the orthogonal projection of the point $(8,3)$ onto the line $y = -2x - 3$? 

Using basic analytical methods, I get the point $(-4/5,-7/5)$, but I want to obtain this point by seeing what happens to the standard basis vectors. But I always end up with the matrix
$$
\begin{bmatrix}-1&-\frac{8}{5}\\-1&\frac{1}{5}\end{bmatrix},
$$
and
$$
\begin{bmatrix}-1&-\frac{8}{5}\\-1&\frac{1}{5}\end{bmatrix}\begin{bmatrix}8\\3\end{bmatrix}
=\begin{bmatrix}-\frac{64}{5}\\-\frac{37}{5}\end{bmatrix}
\neq\begin{bmatrix}-\frac{4}{5}\\-\frac{7}{5}\end{bmatrix}.
$$
Can anyone tell me where I'm going wrong?
 A: Projection onto a line that doesn’t pass through the origin is not a linear transformation, but it is an affine transformation. This means that it can be represented by a matrix, but you need to use a $3\times3$ matrix and homogeneous coordinates. 
There are several ways to build this matrix. Since your approach of computing the projections of the basis vectors does work for a line through the origin, let’s take advantage of that method by adding a couple of translations: first translate so that the line passes through the origin, project onto the translated line, then translate back. Any point on the line will do for these translations, so we’ll use the $y$-intercept $\mathbf t=(0,-3)$ since it can be read directly from the equation of the line. Letting $P_2$ stand for the $2\times2$ matrix of the projection onto the translated line, the projection onto the original line is then (in block form): $$P=\left[\begin{array}{c|c}I_2 & \mathbf t \\ \hline \mathbf 0^T&1 \end{array}\right]\left[\begin{array}{c|c}P_2&0\\\hline\mathbf 0^T&1\end{array}\right]\left[\begin{array}{c|c}I_2&-\mathbf t \\\hline \mathbf 0^T&1\end{array}\right] = \left[\begin{array}{c|c} P_2 & \mathbf t-P_2\mathbf t \\\hline \mathbf 0^T&1\end{array}\right].$$ Here, $I_2$ stands for the $2\times2$ identity matrix. The columns of $P_2$ are the projections of $(1,0)$ and $(0,1)$, respectively, onto the translated line, giving $$P_2=\left[\begin{array}{rr}\frac15&-\frac25\\-\frac25&\frac45\end{array}\right]$$ and $\mathbf t-P_2\mathbf t=\left(-\frac65,-\frac35\right)$  (I’ll leave it to you to work out for yourself and verify these values), so the full projection matrix is $$P=\left[\begin{array}{rrr}\frac15&-\frac25&-\frac65 \\ -\frac25&\frac45&-\frac35 \\ 0&0&1\end{array}\right].$$ To use this matrix, you need to append a $1$ to the coordinates of the point being transformed and then drop that $1$ after you’ve found the product, e.g., $$\left[\begin{array}{rrr}\frac15&-\frac25&-\frac65 \\ -\frac25&\frac45&-\frac35 \\ 0&0&1\end{array}\right]\begin{bmatrix}8\\3\\1\end{bmatrix}=\begin{bmatrix}-\frac45\\-\frac75\\1\end{bmatrix}.$$ Since the last component of the product $P(x,y,1)^T$ is always going to be $1$, you can drop the last row of the matrix instead if you like. You can also verify that the projections of $(1,0)$ and $(0,1)$ computed with this matrix are the same as the values that you were getting “by hand.”  
Observe that $\mathbf t-P_2\mathbf t$ is the orthogonal rejection of $\mathbf t$ from the translated line. In other words, it’s the component of $\mathbf t$ perpendicular to the line, but this is just the perpendicular displacement of the original line from the origin. (That’s why we could take any point on the line for $\mathbf t$). This shift perpendicular to the line is what was missing from your initial attempt.
A: $y = -2x-3$ is denoted by $<(1,-2)>$ named A
The orthogonal projection of point $<(8,3)>$  named $\bar x$ subtract (-3) from the y vector to obtain a new $\bar x$ to give you $<(8,6)>$ is given by 
$ A(A^{T}A)^{-1}A^{T}\bar x$
$(1,-2)\left((1,-2).(1,-2)\right)^{-1}\times\left((1,-2).(8,6)\right) = (1,-2)(\frac{1}{5}\times -4)= \frac{-4}{5}<(1,-2)> = <(\frac{-4}{5},\frac{8}{5})>$ and now add -3 to y vector to get the projected point which will give you
$<(\frac{-4}{5},\frac{-7}{5})>$.
