Find the closest distance between two lines segments?

  • Level: Undergrad 
  • Thread starter kolleamm
  • Start date
  • Tags Tags
    Lines
1 reply · 2K views · last reply
kolleamm
Messages
476
Reaction score
44
TL;DR
Find the smallest distance between two line segments
If I have two line segments, how can I find the smallest distance between them? Any one point on each of the segments can be chosen for comparison. (to go a step further, a circle's outer edge and a line segment)

Thanks in advance.
 
The most general approach for continuous lines: Set up the distance as function of the positions along the lines (with two variables), look for zeros in the derivative to look for minima, then check the end points because they might be the actual solution without being a local minimum in your variables.

If you have some knowledge about these line segments (e.g. straight lines) things can get much easier.
 
  • Like
Likes   Reactions: kolleamm