# Math Help - 3D Engine Geometry Shortest distance from a point to a line in 3D

1. ## 3D Engine Geometry Shortest distance from a point to a line in 3D

My notes for this topic are not very clear and certain steps of how to do this type of calculation have been skipped. I was hoping someone could do this sum out for me so I could use it as an example it would really be appreciated.

s = starting point v = any q =direction from any point

d =
._____________________
.| ........................ 2
.| .........2 [(q -s).v]
.| (q -s) - _________
.|................ .....2
V................|v|

Find the distance between the point q = [0,2,2] and the line defined by: p(t)= [ 0,0,0,] + t[1,0,0]

2. Originally Posted by aoibha
My notes for this topic are not very clear and certain steps of how to do this type of calculation have been skipped. I was hoping someone could do this sum out for me so I could use it as an example it would really be appreciated.

s = starting point v = any q =direction from any point

d =
._____________________
.| ........................ 2
.| .........2 [(q -s).v]
.| (q -s) - _________
.|................ .....2
V................|v|

Find the distance between the point q = [0,2,2] and the line defined by: p(t)= [ 0,0,0,] + t[1,0,0]
That is an ingenious (but not easy to read!) way to write the formula

$d=\sqrt{|q-s|^2 - \displaystyle\frac{\bigl((q-s).v\bigr)^2}{|v|^2}}.$

The line "s = starting point v = any q =direction from any point" seems to be completely garbled and misleading. I think that what it ought to say is this: you are given a point q, and a line whose equation is p(t) = s + tv. Here, s is a point on the line (the "starting point") and v is the direction vector of the line.

So to find the distance from the point [0,2,2] to the line p(t)= [0,0,0,] + t[1,0,0], you should take q = [0,2,2], s = [0,0,0], v = [1,0,0], and plug those vectors into the formula.