Remember that in general, given a linear space and a subspace with the orthogonal projection of a vector over is given by where is an orthonormal base of ( Such a base exists by Gram-Schmidt)

So in our case let this vector belongs to the line L and its norm is 1, thus ( since the dimension of the line is 1) it forms an orthonormal base of L.

Thus: from there: and note that this can be re-written as (with column vectors):