Find the closest distance between two lines segments?

  • Context: Undergrad 
  • Thread starter Thread starter kolleamm
  • Start date Start date
  • Tags Tags
    Lines
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 2K views
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.
 
Physics news on Phys.org
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