Orthogonal projection in this visualization
Orthogonal projection finds the point of a subspace that is closest to a given vector. Here the subspace is a plane or a line through the origin O, and the vector is . Its projection lies in , and the error meets at a right angle. You can move and reshape , compare with any other point of , and see when the shadows of on two axes add up to .
Why does the right angle give the closest point? Take any other point in . The segment from to lies in , so it is perpendicular to . The points , and form a right triangle with the right angle at , and Pythagoras gives
So is farther from than from , unless is itself. It works the other way too. If leaned toward some direction in , moving slightly that way would bring it closer to . In a plane, then, the closest point is the one where is perpendicular to both and . On a line, being perpendicular to is enough.
Finding comes down to these right angles. On a line, is a multiple of , and the condition fixes the multiple:
In a plane, write . The two conditions and become two linear equations for and , called the normal equations:
The readout gives both as coordinates and as a combination of and . Drag and around within the same plane and the coefficients change, but does not. The projection depends only on the subspace, not on the vectors used to describe it.
When and are perpendicular, the two equations come apart. Each coefficient then depends on one axis only, and is simply the sum of the shadows of on the two axes:
On slanted axes this shortcut usually fails. Each shadow is taken as if the other axis were not there, so their sum usually lands away from . When it does, the readout shows missing at least one of the two right angles. Make w ⟂ u replaces with its part perpendicular to , which is one step of the Gram–Schmidt process. The plane is still the same plane, but now its two axes are perpendicular, and the shadows add up to for every .
The diagonal line through gives a familiar example. Projecting onto it replaces every entry of with their mean, and is the sum of squared deviations from that mean. Least-squares regression uses the same kind of projection.
Controls
- The dot on moves it parallel to , and follows. The small ring beyond the dot moves at right angles to , and stays put.
- With Plane chosen, and can only be dragged within their plane. To change the plane, type new coordinates or use the value keys.