In the previous sections we have encountered the two formulas $\mathbf{a} \cdot \mathbf{b} = |\mathbf{a}| \, |\mathbf{b}| \cos \theta$ and $|\mathbf{a} \times \mathbf{b}| = |\mathbf{a}| \, |\mathbf{b}| \sin \theta$. These formulas are useful in deriving the following results:
Consider vectors $\mathbf{a}$ and $\mathbf{b}$ as shown in the diagram. Let $\theta$ be the angle between them. We drop a perpendicular from point $A$ to line $OB$ and call the point where they intersect $F$ (for the foot of the perpendicular ).
Considering the right angle triangle $OAF$, $\cos \theta = \frac{OF}{OA}$.
$\displaystyle OF = OA \cos \theta = \frac{OA \cdot OB \cos \theta}{OB} = \frac{\mathbf{a} \cdot \mathbf{b}}{\mathbf{b}} = \mathbf{a} \cdot \hat{\mathbf{b}}$.
We call $OF$ the projection of $\mathbf{a}$ onto $\mathbf{b}$. (Note the order: $\mathbf{b}$ onto $\mathbf{a}$ refers to a different result.)
$\mathbf{a} \cdot \hat{\mathbf{b}}$ can be positive or negative depending on whether $\theta$ is acute or obtuse. If we are interested in just the length, we apply the modulus function to get a positive result which we term the length of projection .
If we are interested in the vector $\overrightarrow{OF}$, called the projection vector of $\mathbf{a}$ onto $\mathbf{b}$, we use the idea we encountered from our earlier discussion on unit vectors. $\overrightarrow{OF}$ is of magnitude $\left (\mathbf{a} \cdot \hat{\mathbf{b}} \right )$ and is parallel to $\mathbf{b}$. Hence $\overrightarrow{OF} = \left (\mathbf{a} \cdot \hat{\mathbf{b}} \right ) \hat{\mathbf{b}}$. Note that we use $\left (\mathbf{a} \cdot \hat{\mathbf{b}} \right)$ and not $\left | \mathbf{a} \cdot \hat{\mathbf{b}} \right |$ since the projection vector $\overrightarrow{OF}$ could be in the same or oppositie direction to $\mathbf{b}$ depending on whether $\theta$ is acute or obtuse.
A similar derivation can be carried out using sine instead of cosine on triangle $OAF$ to obtain the perpendicular distance from point $A$ to line $OB$: $\left | \mathbf{a} \times \hat{\mathbf{b}} \right |$. Alternatively, since the dot product is easier to compute, one can also obtain this distance by finding the length of projection first and then applying Pythagoras Theorem. This avoids the computation of the cross product.
Solution to examples
Find the length of projection of $\overrightarrow{OA}$ onto $\overrightarrow{OB}$.
Length of projection
$\displaystyle = \left | \mathbf{a} \cdot \hat{\mathbf{b}} \right | \\
= \displaystyle \frac{\left | \begin{pmatrix} -1 \\ 2 \\ 3 \end{pmatrix} \cdot \begin{pmatrix} 5 \\ 0 \\ 1 \end{pmatrix} \right |}{\left | \begin{pmatrix} 5 \\ 0 \\ 1 \end{pmatrix} \right |} \\
= \displaystyle \frac{|-5+3|}{\sqrt{26}}$
$= \frac{2}{\sqrt{26}}$
Projection vector of $\overrightarrow{OA}$ onto $\overrightarrow{OB}$
$= \left (\mathbf{a} \cdot \hat{\mathbf{b}} \right) \hat{\mathbf{b}} \\
= \displaystyle \frac{(\mathbf{a} \cdot \mathbf{b}) \mathbf{b}}{|\mathbf{b}|^2} \\
= \frac{-2}{26} \mathbf{b}$
$= -\frac{1}{13} (5\mathbf{i}+\mathbf{k})$
3. Find the perpendicular length from point $B$ to the line $OA$.
We first note the change in order for this question: we want the perpendicular length from $B$ to line $OA$, not from $A$ to line $OB$.
Perpendicular length
$ \displaystyle = \left | \mathbf{b} \times \hat{\mathbf{a}} \right | \\
= \displaystyle \frac{\left | \begin{pmatrix} 5 \\ 0 \\ 1 \end{pmatrix} \cdot \begin{pmatrix} -1 \\ 2 \\ 3 \end{pmatrix} \right |}{\left | \begin{pmatrix} -1 \\ 2 \\ 3 \end{pmatrix} \right |} \\
= \displaystyle \frac{\left | \begin{pmatrix} -2 \\ -16 \\ 10 \end{pmatrix} \right |}{\sqrt{14}} \\
= \frac{6\sqrt{10}}{\sqrt{14}}$
$= \frac{6\sqrt{35}}{7}$