The projection of one vector onto another has two components: the *scalar projection*, which measures the length of the projection, and the *vector projection*, which provides the actual vector.
## Scalar Projection
From trigonometry, the cosine of the angle $\theta$ can be expressed by as the ration of the length of the adjacent to the length of the hypothenuse. In the context of vectors, the hypothenuse corresponds to the [[Vector Length]] of $\vert s \vert$.
$ \cos(\theta) =
\frac{\text{adjacent}}{\text{hypotenuse}} =
\frac{\text{adjacent}}{\lvert s \rvert} \quad \implies \quad \text{adjacent} =\lvert s \rvert * \cos(\theta)
$
![[vector-projection.png|center|250]]
By writing out the [[Cosine Rule]], we see that we only have to divide both sides by $\vert r \vert$ to get an equation in terms of the length of the adjacent.
$
\begin{align}
r \cdot s &= \lvert r \rvert \lvert s \rvert * \cos(\theta) \\[8pt] \frac{r \cdot s}{\lvert r \rvert} &= \underbrace{\lvert s \rvert * \cos(\theta)}_{\text{length of adjacent}}
\end{align}
$
**Remarks:**
- We are projecting the hypothenuse $s$ onto the adjacent $r$ to obtain the length of the adjacent.
- When $r,s$ are orthogonal, $\cos(\theta)=0$, so the projection length is zero.
- When $r$ is of unit length $\lvert r \rvert =1$, then the scalar projection simplified to $r \cdot s$.
## Vector Projection
To determine the actual vector (not just its length), we normalize vector $r$ to unit length, and then scale it by the scalar projection.
$
\text{Vector projection}=
\frac{r \cdot s}{\lvert r \rvert} * \frac{r}{\lvert r \rvert} \quad = \quad
\frac{r \cdot s}{\lvert r \rvert^2} * r \quad = \quad \frac{r \cdot s}{r \cdot r} * r $