Find the closest distance between two lines segments?

  • I
  • Thread starter kolleamm
  • Start date
  • #1
kolleamm
454
43
TL;DR Summary
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.
 

Answers and Replies

  • #2
36,245
13,298
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.
 

Suggested for: Find the closest distance between two lines segments?

  • Last Post
Replies
2
Views
678
Replies
2
Views
3K
  • Last Post
Replies
8
Views
2K
Replies
3
Views
497
  • Last Post
Replies
17
Views
633
Replies
4
Views
585
  • Last Post
Replies
26
Views
782
Replies
4
Views
510
  • Last Post
Replies
6
Views
588
Replies
13
Views
512
Top