
# Vector projection¶

This here page follows the discussion in this Khan academy video on projection. Please watch that video for a nice presentation of the mathematics on this page.

For the video and this page, you will need the definitions and mathematics from Vectors and dot products.

## Start¶

Consider two vectors $$\vec{w}$$ and $$\vec{v}$$.

We can scale $$\vec{v}$$ with a scalar $$c$$. By choosing the correct $$c$$ we can create any vector on the infinite length dotted line in the diagram. $$c \vec{v}$$ defines this infinite line.

We’re going to find the projection of $$\vec{w}$$ onto $$\vec{v}$$, written as:

$\mathrm{proj}_\vec{v}\vec{w}$

The projection of $$\vec{w}$$ onto $$\vec{v}$$ is a vector on the line $$c \vec{v}$$. Specifically it is $$c \vec{v}$$ such that the line joining $$\vec{w}$$ and $$c \vec{v}$$ is perpendicular to $$\vec{v}$$.

## Why is it called projection?¶

Imagine a light source, parallel to $$\vec{v}$$, above $$\vec{w}$$. The light would cast rays perpendicular to $$\vec{v}$$.

$$\mathrm{proj}_\vec{v}\vec{w}$$ is the shadow cast by $$\vec{w}$$ on the line defined by $$\vec{v}$$.

## Calculating the projection¶

The vector connecting $$\vec{w}$$ and $$c \vec{v}$$ is $$\vec{w} - c \vec{v}$$.

We want to find $$c$$ such that $$\vec{w} - c \vec{v}$$ is perpendicular to $$\vec{v}$$.

Two perpendicular vectors have vector dot product of zero, so:

$(\vec{w} - c \vec{v}) \cdot \vec{v} = 0$

By distribution over addition of dot products:

$\begin{split}(\vec{w} - c \vec{v}) \cdot \vec{v} = 0 \implies \\ \vec{w} \cdot \vec{v} - c \vec{v} \cdot \vec{v} = 0 \implies \\ \frac{\vec{w} \cdot \vec{v}}{\vec{v} \cdot \vec{v}} = c\end{split}$

Because $$\VL{v} = \sqrt(\vec{v} \cdot \vec{v})$$:

$c = \frac{\vec{w} \cdot \vec{v}}{\VL{v}^2}$

So:

$\mathrm{proj}_\vec{v}\vec{w} = \frac{\vec{w} \cdot \vec{v}}{\VL{v}^2} \vec{v}$

We can also write the projection in terms of the unit vector defined by $$\vec{v}$$:

$\begin{split}\hat{u} \triangleq \frac{\vec{v}}{\VL{v}} \implies \\ \mathrm{proj}_\vec{v}\vec{w} = \frac{\vec{w} \cdot \vec{v}}{\VL{v}} \vec{u}\end{split}$

$$\frac{\vec{w} \cdot \vec{v}}{\VL{v}}$$ is called the scalar projection of $$\vec{w}$$ onto $$\vec{v}$$.