# comp.graphics.algorithms

## Subject: Distance between two line segments in 3D

Found this in an old post to this group in the google archive:

>>>>>

How to find the distance between two line segments in 3D

Define the distance between two segments in 3D as the minimum
Euclidean distance between a point on one and a point on the other.
Let S1 = (a,b) and S2 = (c,d) be two such segments, and let L1 and L2
be the (infinite) lines containing S1 and S2. Here a = (ax,ay,az)
and similarly for the other endpoints. Then the distance between
S1 and S2 is the minimum of

the distance between a and c
the distance between a and d
the distance between b and c
the distance between b and d

the distance between a and L1
the distance between b and L1
the distance between c and L2
the distance between d and L2

the distance between L1 and L2

>>>>>

is this true? I don't see the logic, surely if L1 and L2 intersect
while the segments do not this will produce a totally false result!
Does anyone have a simple methodology for this, as a lot of the info I
can find online starts at too high a level for me to fully understand
it.