# Distance between point and line

Using the formula from this page: http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html how can you find the individual x,y, and z distances? I'm trying to figure it out but can't wrap my head around it.

-

You can find the individual distances using the given formula. The individual distances between any point $(x,y,z)$ on the line and the given point is $|x_0-x|,|y_0-y|$ and $|z_0-z|$. But we know that any point in the line is given by $(x_1+(x_2-x_1)t , y_1+(y_2-y_1)t, z_1+(z_2-z_1)t)$. From the given result we see that the distance is minimum at the point corresponding to ( taking $r=(x,y,z)$ ) $t^*=(r_1-r_0).(r_2-r_1)/|r_2-r_1|$. So, the individual distances are $|x_0-x^*|,|y_0-y^*|$ and $|z_0-z^*|$ where $x^*=x_1+(x_2-x_1)t^*, y^*=y_1+(y_2-y_1)t^*$ and $z^*=z_1+(z_2-z_1)t^*$.
Also there is another way of doing it. You can find the straight line passing through the given point $(x_0,y_0,z_0)$ and perpendicular to the given straight line. After that solve those two lines to find the point of intersection $(x_3,y_3,z_3)$. Then the individual distances are $|x_0-x_3|,|y_0-y_3|$ and $|z_0-z_3|$