# Distance between point and line in $\mathbb{R}^{3}$

Find the shortest distance from the point $P=(5,4,-6)$ to the line

$$(x,y,z)=(-7t,-2t,t)$$

So, I'm trying to find the shortest distance and here is my setup:

$$(x,y,z)=(0,0,0) + t(-7,-2,1)$$

Line equation: $-7x - 2y + z = 0$.

Using my point given I have $$\frac{-7(5) - 2(4) + (-6)}{\sqrt{(-7)^2 + (-2)^2 + 1^2} }$$

I get $6.395$ units.

What am I doing wrong here?

• This could help. But you can indeed do that by calculus. You need to minimize the function $f(t)=\|\vec{PX_t}\|^2$ where $X_t=(-7t,-2t,t)$. That's a quadratic, so it should be ok. – Julien Mar 11 '13 at 0:06
• en.wikipedia.org/wiki/Distance_from_a_point_to_a_line – Lepidopterist Mar 11 '13 at 1:11
• By using the dot product of the vectors $(5,4,-6)$ and $(−7,−2,1)$, you (almost) managed to find the length of the segment from $O$ to $Q$, where $Q$ is the point closest to $P$ among all the points on your line. You wanted the length of the segment from $Q$ to $P$ instead. Your second mistake was in the evaluation of your formula; I get $-6.668$. You can finish the problem with this knowledge, but I prefer to use a different vector method (and I've posted it as an answer). – David K May 21 '14 at 19:26

Let the line be defined by $\mathcal{L} := \{ (-7t,-2t,t) : t \in \mathbb{R} \}$. The distance between $\mathcal{L}$ and $P$ is

$$\text{dist} (\mathcal{L},P) := \displaystyle\min_{t \in \mathbb{R}}\sqrt{ (7 t + 5)^2 + (2 t + 4)^2 + (t + 6)^2}$$

Let $t^* := \arg\min \sqrt{ (7 t + 5)^2 + (2 t + 4)^2 + (t + 6)^2}$ be the minimizer. Note that

$$t^* = \displaystyle\arg\min \{ (7 t + 5)^2 + (2 t + 4)^2 + (t + 6)^2\} = -\frac{3}{2}$$

and, therefore, we have that $\text{dist} (\mathcal{L},P) = \sqrt{ (7 t^* + 5)^2 + (2 t^* + 4)^2 + (t^* + 6)^2}$.

The shortest distance between a point $P$ and a line $\ell$ will lie on a line $\ell '$ that is perpendicular to that line. Thus, you are looking to a line that lies in a plane $M$ that is perpendicular to $\ell$ and contains $P$. If you find $M$, you can more easily find $\ell '$. If you find $\ell '$, you can find the intersection of $\ell$ and $\ell '$, and then find the distance from this intersection to the original point $P$.

Does that help?

• That was a little confusing but I get what you're saying. Although how would I find the equation of the plane in this case? – Dimitri Mar 11 '13 at 0:40

The line in question happens to pass through the origin, $O = (0,0,0)$, which is convenient. Let's write your parametric equation of the line as follows: $O + tV$, where $V = (−7,−2,1)$, Essentially, then, you are trying to find the length of $PQ$ where $Q$ is a point on the line generated by $O + tV$ and where $\triangle OPQ$ is a right triangle with hypotenuse $OP$.

Now, $PQ = OP\, \sin \theta$ where $\theta$ is the angle between $OP$ and $OQ$. But $OQ$ is parallel to the vector $V$, and $OP$ is parallel to (and the same length as) the vector $W = (5,4,−6)$. That is, you need to find $||W|| \sin \theta$. And by a general property of the cross-product, we know that $$||V \times W|| = ||V|| \;||W|| \sin \theta.$$

The answer, therefore, is $$|PQ| = ||W|| \sin \theta = \frac{||V \times W||}{||V||}.$$

According to @meh

Let's get plane $\pi$ with normal $N=(-7,-2,1)$, and $P$ lies on it: $$-7x-2y+1z+D=0;\\ -7\cdot5-2\cdot4+1\cdot(-6)+D=0\Longrightarrow D = 49.$$ And let $Q$ is intersection of $\pi$ and line: $$-7\cdot(-7t)-2\cdot(-2t)+t+49=0\Longrightarrow t=-\frac{49}{54};$$ $PQ$ is shortest distance.