Scalar & vector projection

Resolving a vector into its x and y components is easy, especially if the vector is already written in 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 a on b, I mean this:

a|ab|baabb
Geometric interpretation of scalar projection (left) and vector projection (right)

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

|ab|=ab^=|a|cosθ.

If we know θ, 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 b^, we can get it by normalizing b:

|ab|=ab|b|.

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

ab=|ab|b^=(ab^)b^=(|a|cosθ)b^.

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

ab=ab|b|b|b|=ab|b|2b.

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

ui^=[u1,u2][1,0]=u1.

Example

A race starts at the origin and goes in a straight line until the end in the direction of u=[2,3]. A runner started on the path but ended up straying to the point defined by 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:

OPu=OPu^=OPu|u|.

Substituting for the known values give us

OPu=[6,7][2,3]22+32=62+7313=33139.15,

therefore she will be about 9.15 km into the race.