Distance of a point to a line

Find the distance from the point $S(2,2,1)$ to the line $x=2+t,y=2+t,z=2+t$.

How can I find the distance of a point in $3D$ to a line?

-

One way of doing it is as follows:

We want to minimize the distance from the point to the line, which is equivalent to minimizing the square of the distance from the point to that line. Considering the square of the distance eliminates some yucky square roots below.

Applying the Pythagorean theorem, the square of the distance from the point $S$ to an arbitrary point on the line is given by the function:

$$f(t) = t^2 + t^2 + (1+t)^2 = 3t^2 + 2t + 1$$

Now to find the minimum distance, we simply take a derivative and set it equal to zero. We know this will give a minimum since, intuitively, the function will not have a maximum.

$$f'(t) = 6t + 2 = 0$$

And so the point on the line when $t = -\frac{1}{3}$ must be closest to $S$. Now you simply need to calculate the distance between $S$ and $(\frac{5}{3}, \frac{5}{3}, \frac{5}{3})$.

-

The equation of a plane perpendicular to the line is $$x+y+z=a.$$ If this plane passes through $(2,2,1)$ then $a=5$. So the plane $x+y+z=5$ intersects the line when

$$3t+6=5$$ so $t=-\frac{1}{3}$ and now you just need the distance between $S$ and $(\frac{5}{3},\frac{5}{3}, \frac{5}{3})$.

-
Why is the equation of a plane perpendicular to the line $x+y+z=a$ ? – evinda Jun 15 '14 at 0:07
Since the direction of the line is $(1,1,1)$ the normal vector of any plane perpendicular to the line is $(1,1,1).$ Thus the equation of the plane is the one written in the solution above. – mfl Jun 15 '14 at 0:09
The equation of a plane through $(x_0,y_0,z_0)$ and perpendicular to $(a,b,c)$ is $a(x-x_0)+b(y-y_0)+c(z-z_0)=0$, so the family of planes $ax+bx+cz=d$ as $d$ varies are all planes with normal $(a,b,c)$. – Rene Schipperus Jun 15 '14 at 0:15
Yes. So the plane perpendicular to $(a,b,c)=(1,1,1)$ and that pass through $(x_0,y_0,z_0)=(2,2,1)$ is $x-2+y-2+z-1=0,$ or equivalently $x+y+z=5.$ – mfl Jun 15 '14 at 0:30

Consider a vector that gives you the direction of the line: $\vec{v}=(1,1,1).$ Consider a point of the line: $P(2,2,2).$ Now, the vectors $\vec{v}=(1,1,1)$ and $\vec{PS}=(0,0,-1)$ determine a paralellogram. The distance from the point to the line is the height of this paralellogram when we consider $\vec{v}=(1,1,1)$ as basis. So the distance is the area divide by the basis. We get the area using the cross product. So

$$d(S,r)=\frac{|\vec{v}\times \vec{PS}|}{|\vec{v}|}=\frac{|(-1,1,0)|}{|(1,1,1)|}=\frac{\sqrt{2}}{\sqrt{3}}.$$

-