Projecting One Vector onto Another
Picture a canoe crossing a river. The current doesn't care where you're trying to go — it just
pushes, at some angle, with some strength. Part of that push carries you straight
downstream; the rest shoves you uselessly sideways, towards one bank or the
other. If you only care about how much the current speeds up (or slows down) your trip downstream,
you don't need the whole push — you need exactly the sliver of it that points downstream, with the
sideways part thrown away.
That sliver has a name: the projection of one vector onto another. It answers a
question that comes up everywhere forces and directions meet: "how much of this vector actually
acts along that direction?"
The shadow picture
Shine a light straight down onto a line and a vector casts a shadow on it — as if
the sun's rays fall perpendicular to the line and every point of the vector's tip drops straight
down onto it. That shadow is the projection of \vec{v} onto
\vec{u}: the part of \vec{v} that lies along
\vec{u}'s direction, with the perpendicular part discarded entirely.
The length of the shadow (with a sign — negative if it falls backwards) is
\vec{v}\cdot\hat{u}, the dot product with the
unit vector
in \vec{u}'s direction. Written without needing a unit vector first,
the full projection vector is built straight from the dot product:
\operatorname{proj}_{\vec{u}}\vec{v} = \frac{\vec{u}\cdot\vec{v}}{\vec{u}\cdot\vec{u}}\,\vec{u}.
Read it in two pieces. The fraction
\dfrac{\vec{u}\cdot\vec{v}}{\vec{u}\cdot\vec{u}} is just a
number — how many copies of \vec{u} you need to reach the
shadow's tip. Multiplying that number back onto \vec{u} turns it into a
vector that actually points along \vec{u}'s direction.
Worked example 1 — a plain numeric projection
Project \vec{v} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} onto
\vec{u} = \begin{bmatrix} 3 \\ 4 \end{bmatrix}. First the dot products:
\vec{u}\cdot\vec{v} = 3(6)+4(8) = 18+32 = 50, \qquad \vec{u}\cdot\vec{u} = 3^2+4^2 = 25.
So the scaling number is \tfrac{50}{25} = 2, and the projection is
\operatorname{proj}_{\vec{u}}\vec{v} = 2\begin{bmatrix} 3 \\ 4 \end{bmatrix} = \begin{bmatrix} 6 \\ 8 \end{bmatrix} = \vec{v}.
The shadow lands exactly on \vec{v} itself — which makes sense, because
\vec{v} is already pointing exactly along \vec{u}'s
direction (it's just twice as long). When two vectors already point the same way, projecting one
onto the other changes nothing about its direction.
Try a case where the vectors don't line up: project
\vec{v} = \begin{bmatrix} 1 \\ 7 \end{bmatrix} onto the same
\vec{u} = \begin{bmatrix} 3 \\ 4 \end{bmatrix}. This time
\vec{u}\cdot\vec{v} = 3+28=31, so the projection is
\tfrac{31}{25}\begin{bmatrix} 3\\4 \end{bmatrix} \approx \begin{bmatrix} 3.72 \\ 4.96 \end{bmatrix}.
Subtract that from \vec{v} and what's left,
\begin{bmatrix} -2.72 \\ 2.04 \end{bmatrix}, is the perpendicular
leftover — and if you dot it with \vec{u} you'll get (up to rounding)
exactly zero. Every vector splits, without exception, into "the shadow along
\vec{u}" plus "the bit perpendicular to \vec{u},"
and the two pieces always add back up to the original vector.
Worked example 2 — the river current, with real numbers
Back to the canoe. Suppose the current pushes with vector
\vec{c} = \begin{bmatrix} 3 \\ 4 \end{bmatrix} km/h (partly downstream,
partly sideways), and "downstream" is the direction
\vec{d} = \begin{bmatrix} 1 \\ 0 \end{bmatrix}. How fast does the
current actually carry you downstream?
\operatorname{proj}_{\vec{d}}\vec{c} = \frac{\vec{d}\cdot\vec{c}}{\vec{d}\cdot\vec{d}}\vec{d} = \frac{3}{1}\begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 3 \\ 0 \end{bmatrix}.
Exactly 3 km/h downstream — the sideways 4
km/h is real (it will drift you toward a riverbank), but it contributes nothing to your downstream
progress. Projection is precisely the tool that separates "the part that matters for this
direction" from "everything else."
Casting the shadow
Drag \vec{v}. The bold segment on the line through
\vec{u} is the projection, and the dashed line dropping from
\vec{v}'s tip meets that line at a right angle — projection always
drops perpendicularly, exactly like the sunlight picture. When
\vec{v} is itself
perpendicular
to \vec{u}, the shadow shrinks all the way to nothing — there's no
"along \vec{u}" component left at all.
Worked example 3 — a force on a ramp
Here's the classic physics use of this idea, well before it's ever called "projection" in a
physics class. A crate sits on a frictionless ramp, and gravity pulls straight down with force
\vec{g} = \begin{bmatrix} 0 \\ -10 \end{bmatrix} (in some convenient
units). The ramp's surface points along
\vec{r} = \begin{bmatrix} 4 \\ -3 \end{bmatrix}. How much of gravity's
pull actually acts along the ramp — the part that slides the crate down its surface?
\operatorname{proj}_{\vec{r}}\vec{g} = \frac{\vec{r}\cdot\vec{g}}{\vec{r}\cdot\vec{r}}\vec{r} = \frac{(4)(0)+(-3)(-10)}{16+9}\begin{bmatrix} 4 \\ -3 \end{bmatrix} = \frac{30}{25}\begin{bmatrix} 4 \\ -3 \end{bmatrix} = 1.2\begin{bmatrix} 4 \\ -3 \end{bmatrix}.
Whatever is left over — \vec{g} minus that projection — presses the
crate into the ramp instead of sliding it. Splitting a force this way, into "along the
surface" and "into the surface," is exactly what a physics teacher means by
resolving forces on an
inclined plane — usually taught with triangles and trigonometry, but it's this same
dot-product machinery underneath the whole time.
The workhorse of applied maths
Projection is how you find the "closest point" on a line or plane to a given target — which is
exactly the question behind least-squares fitting, the engine of
linear regression.
It splits any vector into "the part along \vec{u}" plus "the leftover
perpendicular part," and that split — signal plus residual — turns up everywhere from graphics
to statistics. It closes out Stage A: with addition, scaling, length, the dot product and
projection, you have the full vocabulary of vectors.
There's an even bigger payoff waiting just past this page. Chain projections together — project
onto one direction, then project what's left onto a second orthogonal direction, then a third —
and you can rebuild any vector as a sum of independent, non-overlapping pieces. That
process is called Gram-Schmidt, and it's how a computer takes a messy set of
directions and straightens them into a clean orthogonal basis, ready for the "no leakage between
directions" convenience that comes with
orthogonal
axes. Every one of those straightening steps is nothing more than the shadow formula above,
applied once per direction.
Trap one: the denominator. In
\operatorname{proj}_{\vec{u}}\vec{v} = \dfrac{\vec{u}\cdot\vec{v}}{\vec{u}\cdot\vec{u}}\vec{u},
the bottom is \vec{u}\cdot\vec{u} = |\vec{u}|^2 — the length
squared — not the plain length |\vec{u}|. It's an extremely
common slip to write |\vec{u}| on the bottom and get an answer that's
the wrong size by a whole factor of |\vec{u}|. If you ever want the bare
length instead, that's a different (but related) quantity — see the next trap.
Trap two: vector or scalar? \operatorname{proj}_{\vec{u}}\vec{v}
is a full vector — it points along \vec{u}'s
direction and has both a size and a direction. The related quantity
\text{comp}_{\vec{u}}\vec{v} = \dfrac{\vec{u}\cdot\vec{v}}{|\vec{u}|} is
the scalar component — just a signed number (the shadow's length, negative if it
falls backwards), with no direction attached. A question that asks for "the projection" wants a
vector with both components; a question that asks for "the component along \vec{u}"
wants a single signed number. Mixing the two up is one of the most common marks lost on this
topic.
Every time a video game or a 3D movie shows you a scene on a flat screen, it is running this exact
idea again and again. A 3D world is full of points described by vectors; to draw them on a flat
2D screen, the graphics engine projects each point's position onto the screen's own "horizontal"
and "vertical" directions — one projection for how far right the point should appear, another for
how far up. Do that for millions of points, sixty times a second, and you get a moving picture.
The dot product you just used to slide a crate down a ramp is, underneath, the very same
arithmetic that draws a spaceship on your screen.
It also explains why a physics teacher's instruction to "resolve the force into components" on an
inclined plane always feels a little like a magic trick with triangles and
\sin/\cos — it's projection, just taught
before anyone mentions the word. Once you know the dot-product formula, the triangle trick and the
vector formula are provably the same calculation, just wearing different clothes.