Scalar & vector projection

Resolving a vector into its x and y components is easy, especially if the vector is already written in RR^2 component form. However, sometimes we want to project the vector onto a different axis—we can use another vector to describe this axis. When I talk about the scalar projection and the vector projection of vec a on vec b, I mean this:

Notice the subscript notation: the value of vec a_b is the vector projection of vec a on vec b, and its magnitude is the scalar projection. To calculate the scalar projection, we can use one of our new friends, the dot product:

|vec a_b| = vec a * hat b = |vec a|cos theta.

If we know theta, then this is easy. However, sometimes we either don’t know it or we would rather avoid rounding off trig ratios. In those cases, we should use the middle part of the equation above. And if we don’t know hat b, we can get it by normalizing vec b:

|vec a_b| = (vec a * vec b)/|vec b|.

What about the vector projection? That’s easy—we just get the scalar projection and point it in the direction of hat b:

vec a_b = |vec a_b| hat b = (vec a * hat b) hat b = (|vec a|cos theta)hat b.

Once again, we can normalize vec b at the same time if we want:

vec a_b = ((vec a * vec b)/|vec b|)(vec b/|vec b|) = (vec a * vec b)/|vec b|^2 vec b.

The special cases of the x and y axes still work with all of this. Say I want to project vec u onto the x axis:

vec u * hat i = [u_1,u_2] * [1,0] = u_1.

Example

A race starts at the origin and goes in a straight line until the end in the direction of vec u = [2,3]. A runner started on the path but ended up straying to the point defined by vec(OP) = [6,7] in kilometres. If she goes back to the path via the shortest route, how far along the race will she be?

If she takes the shortest route, that means her direction of travel will intersect with the path at 90º. To find her progress along the actual race, we want to project her current position onto the path:

vec(OP)_u = vec(OP) * hat u = (vec(OP) * vec u)/|vec u|.

Substituting for the known values give us

vec(OP)_u = ([6,7] * [2,3])/sqrt(2^2+3^2) = (6*2+7*3)/sqrt(13) = 33/sqrt(13) ~~ 9.15,

therefore she will be about 9.15 km into the race.