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 righ-angled 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+5-2)/√(9+1+4)
= 18/√14

also │b│ = √(25+25+1) = √51

You now have 2 sides of a right-angled 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^2-a^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

To determine the distance between the given point P(1,-5,2) and the line, you can use the concept of vector projections.

First, you choose a point B(6,0,1) on the given line. We will use this point to form a right-angled triangle with the vector BP being the hypotenuse.

To find vector BP, subtract the coordinates of B from those of P:
vector BP = P - B = (1-6, -5-0, 2-1) = (-5, -5, 1)

Next, you need to find the projection of vector BP onto vector a, which is the direction vector of the given line.

Vector a is given as (3,1,2).

The scalar projection of vector BP onto vector a is given by:
scalar projection = (vector BP) · (vector a) / ||vector a||

Dot product of vector BP and vector a:
(vector BP) · (vector a) = (-5)(3) + (-5)(1) + (1)(2) = -15 - 5 + 2 = -18

Magnitude of vector a:
||vector a|| = √(3^2 + 1^2 + 2^2) = √(9 + 1 + 4) = √14

Plugging the values into the formula for scalar projection:
scalar projection = -18 / √14

Additionally, you need to find the magnitude of vector BP, which is also the hypotenuse of the triangle:
||vector BP|| = √((-5)^2 + (-5)^2 + 1^2) = √(25 + 25 + 1) = √51

Now, you have two sides of the right-angled triangle: the projection of vector BP onto vector a and the magnitude of vector BP.

To find the remaining side, which represents the distance between point P and the line, you can use the Pythagorean theorem:
distance = √(hypotenuse^2 - side^2)

In this case, the hypotenuse is ||vector BP|| and the side is the projection of vector BP onto vector a.

So, the distance between point P and the line can be calculated as:
distance = √(||vector BP||^2 - (scalar projection)^2)
= √(51 - (-18 / √14)^2)
= √(51 - (18^2 / 14))
= √(51 - 324 / 14)
= √(51 - 23.14)
= √27.86
≈ 5.28

Therefore, the distance between point P(1,-5,2) and the given line is approximately 5.28 units.