Finding distances between point and line?

349 Views Asked by At

The problem:

Compute the distance d from y to the line through u and the origin.

$$\vec y = \begin{pmatrix} -1 \\ 5 \\ 7 \end{pmatrix},\ \vec u = \begin{pmatrix} -2 \\ -2 \\ 4 \end{pmatrix}$$

My solution:

So I know the formula

$$ \vec d = \left\lvert \vec y - \frac{\mathrm{\vec y}\!\cdot\!\mathrm{\vec u}} {\left\lVert \vec u \right\rVert} \vec u\right\rvert$$

computes vector $\vec d$ that is the shortest vector between $\vec y$ and $\vec u$. When I use this formula, I get

$$\vec d = \begin{pmatrix} -1 + \frac{20}{\sqrt 6} \\ 5 + \frac{20}{\sqrt 6} \\ 7 - \frac{40}{\sqrt 6} \end{pmatrix}$$

which has a magnitude of about 17.66. This is wrong and I'm not sure why. Any help would be appreciated, thank you in advance :)