How would you find the linear transformation that takes each (x,y) point and projects onto the line y=x?
How do you want points to travel to the line y = x? I could easily think of a way to do this using rotation matrices. But then a point would not travel to the closest point on y = x from its original location. It would travel to the nearest point on y = x that is on the circle with radius equal to its own distance from the origin. In other words, they would travel around on a circle until they reached y = x. But if you use the term "projection", I think you mean that each point goes straight towards the nearest point on y = x, right?
I would interpret "projection" as meaning "orthogonal projection". That is, to project onto the line y= x, draw the line throught perpendicular to the line y= x. The projection is at the intersection of those two lines.
Of course, any line perpendicular to y= x is of the form y= -x+ A. Taking , , We have so that . The line perpendicular to y= x is . That intersects the line y= x when or so that .
The point is projected onto the line y= x at the point .
That is
You could also write this as the matrix multiplication