# Scalar & vector projection

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

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

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

$\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 $\displaystyle \hat{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 $\displaystyle \vec{b}$ at the same time if we want:

$\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 $\displaystyle \vec{u}$ onto the x axis:

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

## Example

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

$\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

$\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.