Calc. for Reiny
posted by Derek .
this can be done by projections of two vector.
recall that the scalar projection of vector b on vector a is a∙b/│a│
so let's find a point on the give line,
e.g. the point B(6,0,1) (I let t=0)
draw a perpendicular from your given point P(1,5,2) to meet the line at Q
So PQB forms a righangled triangle with │vector BP│ the hypotenuse.
vector BP, lets call it vector b, is (5,5,1) and vector a is (3,1,2), (from your given line)
so the projection of vector b on vector a
= (5,5,1)∙(3,1,2)/│(3,1,2)│
= (15+52)/√(9+1+4)
= 18/√14
also │b│ = √(25+25+1) = √51
You now have 2 sides of a rightangled triangle, with your required distance as the third side.
I will let you finish the arithmetic.
What do you with the triangle? How do you know which side is which, are you finding the hypotenuse, or just a side? This changes the math done. Like a^2+b^2=c^2, but if you are finding a side then it would be c^2a^2=b^2...so can you please explain, thanks.

Since you posted my reply, I will use my letters
I found │vector BP│ to be √51 , the hypotenuse
I found │vector bQ│ to be 18/√14
You want │vector PQ│
so (PQ)^2 + (BQ)^2 = (BP)^2
(PQ)^2 = (BP)^2  (BQ)^2
= 51  324/14
= 390/14
BP = √(390/14)
= 5.278