Scalar & vector projection

Resolving a vector into its x and y components is easy, especially if the vector is already written in R2\displaystyle \mathbb{R}^{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\displaystyle \vec{a} on b\displaystyle \vec{b}, I mean this:

Geometric interpretation of scalar projection (left) and vector projection (right)

Notice the subscript notation: the value of ab\displaystyle \vec{a}_{b} is the vector projection of a\displaystyle \vec{a} on b\displaystyle \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:

ab=ab^=acosθ\displaystyle \left \lvert \vec{a}_{b} \right \rvert = \vec{a} \cdot \hat{b} = \left \lvert \vec{a} \right \rvert \cos{\theta}.

If we know θ\displaystyle \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 b^\displaystyle \hat{b}, we can get it by normalizing b\displaystyle \vec{b}:

ab=abb\displaystyle \left \lvert \vec{a}_{b} \right \rvert = \frac{\vec{a} \cdot \vec{b}}{\left \lvert \vec{b} \right \rvert}.

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

ab=abb^=(ab^)b^=(acosθ)b^\displaystyle \vec{a}_{b} = \left \lvert \vec{a}_{b} \right \rvert \hat{b} = \left ( \vec{a} \cdot \hat{b} \right ) \hat{b} = \left ( \left \lvert \vec{a} \right \rvert \cos{\theta} \right ) \hat{b}.

Once again, we can normalize b\displaystyle \vec{b} at the same time if we want:

ab=(abb)(bb)=abb2b\displaystyle \vec{a}_{b} = \left ( \frac{\vec{a} \cdot \vec{b}}{\left \lvert \vec{b} \right \rvert} \right ) \left ( \frac{\vec{b}}{\left \lvert \vec{b} \right \rvert} \right ) = \frac{\vec{a} \cdot \vec{b}}{\left \lvert \vec{b} \right \rvert^{2}} \vec{b}.

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

ui^=[u1,u2][1,0]=u1\displaystyle \vec{u} \cdot \hat{i} = \left [ u_{1} , u_{2} \right ] \cdot \left [ 1 , 0 \right ] = u_{1}.


A race starts at the origin and goes in a straight line until the end in the direction of u=[2,3]\displaystyle \vec{u} = \left [ 2 , 3 \right ]. A runner started on the path but ended up straying to the point defined by OP=[6,7]\displaystyle \overrightharpoon{O P} = \left [ 6 , 7 \right ] 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^=OPuu\displaystyle \overrightharpoon{O P}_{u} = \overrightharpoon{O P} \cdot \hat{u} = \frac{\overrightharpoon{O P} \cdot \vec{u}}{\left \lvert \vec{u} \right \rvert}.

Substituting for the known values give us

OPu=[6,7][2,3]22+32=62+7313=33139.15\displaystyle \overrightharpoon{O P}_{u} = \frac{\left [ 6 , 7 \right ] \cdot \left [ 2 , 3 \right ]}{\sqrt{2^{2} + 3^{2}}} = \frac{6 \cdot 2 + 7 \cdot 3}{\sqrt{13}} = \frac{33}{\sqrt{13}} \approx 9.15,

therefore she will be about 9.15 km into the race.