Find the closest distance between two lines segments?

  • I
  • Thread starter kolleamm
  • Start date
  • Tags
    Lines
In summary, to find the smallest distance between two line segments, you can set up a distance function with two variables representing the positions along the lines. Then, look for minima by checking for zeros in the derivative. It is also important to check the end points as they may be the solution without being a local minimum. Knowing more about the line segments, such as their shape, can simplify the process.
  • #1
kolleamm
477
44
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.
 
Physics news on Phys.org
  • #2
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 kolleamm

Related to Find the closest distance between two lines segments?

1. What is the closest distance between two line segments?

The closest distance between two line segments is the shortest distance between any two points on the two line segments. It is also known as the minimum distance or perpendicular distance.

2. How do you calculate the closest distance between two line segments?

The closest distance between two line segments can be calculated using the Pythagorean theorem, which states that the square of the hypotenuse (longest side) of a right triangle is equal to the sum of the squares of the other two sides. In this case, the two sides are the distances between the two line segments.

3. What is the formula for finding the closest distance between two line segments?

The formula for finding the closest distance between two line segments is:
d = ||P1 - P2|| * sin(θ)
Where P1 and P2 are two points on the two line segments, and θ is the angle between the two line segments.

4. Can the closest distance between two line segments be negative?

No, the closest distance between two line segments cannot be negative. It is always a positive value as it represents the shortest distance between the two line segments.

5. Is there a faster way to calculate the closest distance between two line segments?

Yes, there are various algorithms and techniques that can be used to calculate the closest distance between two line segments more efficiently, such as the Gilbert-Johnson-Keerthi (GJK) algorithm and the Separating Axis Theorem (SAT). These algorithms take into account the geometry and orientation of the line segments to find the closest distance without having to calculate all possible distances between points on the line segments.

Similar threads

  • Linear and Abstract Algebra
Replies
13
Views
940
Replies
6
Views
2K
  • General Math
Replies
5
Views
2K
  • Precalculus Mathematics Homework Help
Replies
17
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
2K
Replies
5
Views
1K
  • Special and General Relativity
2
Replies
40
Views
2K
  • General Math
Replies
1
Views
1K
Replies
32
Views
1K
Back
Top