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?
 A: 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})$.
A: 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})$.
A: 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}}.$$ 
