How to find the shortest distance from a line to a solid? The equation $x^2 + y^2 + z^2 - 2x + 6y - 4z + 5 = 0$ describes a sphere. Exactly
how close does the line given by $x = -1+t; y = -3-2t; z = 10+7t$ get to this sphere?
So the sphere is centered at $(1,-3,-2)$ and the radius is $3$. 
I want to find the point where the segment from the center to that point is perpendicular to the line, and then minus the radius to get the answer. So how can I find that point? Or how should I solve this problem in other ways?
 A: Let's just find a vector in the direction of the line, find a vector connecting a point on the line t0 the center, and then make sure they're perpendicular.
Any two points on the line will allow us to find a vector in the direction of the line. With,say, $t=0$ and $t=1$, we get $(-1,-3,10)$ and $(0,-5,17)$, yielding a vector $\vec{v}=(1,-2,7)$
Let $P=(t-1,-2t-3,7t+10)$ be an arbitrary point on the line. The vector between this point and $(1,-3,-2)$ is $\vec{w}=(t-2,-2t,7t+12)$.
Then we want $\vec{v}\cdot\vec{w}=t-2+4t+49t+84=54t+82=0$. So the point at $t=\frac{-41}{27}$ should be the base of a perpendicular dropped from the center to the line.
So this perpendicular has the length of the vector $\vec{w}=(\frac{-95}{27},\frac{82}{27},\frac{37}{27})$, which is $\sqrt{\frac{634}{27}}$
A: Since you have a sphere, the problem is easy, as you propose.
The orthogonal projection of the center of the sphere $p=(1,-3,-2)$ onto the line $x=−1+t;y=−3−2t;z=10+7t$ can be found by translating both point and line so the line passes through $(0,0,0)$, taking the vector orthogonal projection, and translating back:
Let $r=(-1,-3,10)$, the point on the line for $t=0$.  The orthogonal projection of $p-r$ onto the line defined by the vector $s=(1,-2,7)$ (the multipliers of $t$ in the formula for the line) is given by $$\frac{(p-r)\cdot s}{s\cdot s}s.$$  So the closest point on the line is given by $$\frac{(p-r)\cdot s}{s\cdot s}s+r.$$  In your example this is $$\frac{(2,0,-12)\cdot(1,-2,7)}{(1,-2,7)\cdot(1,-2,7)}(1,-2,7)+(-1,-3,10)=\frac{2+0-84}{1+4+49}(1,-2,7)+(-1,-3,10),$$ which I think you can work out with no problem.
Then the distance is from this point to the center of the sphere, minus the radius.
