Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-intersecting line segments while minimizing the cumulative length

I would like to find a better algorithm to solve the following problem:

There are N starting points (purple) and N target points (green) in 2D. I want an algorithm that connects starting points to target points by a line segment (brown) without any of these segments intersecting (red) and while minimizing the cumulative length of all segments.

My first effort in C++ was permuting all possible states, find intersection-free states, and among those the state with minimum total segment length O(n!) . But I think there has to be a better way.

enter image description here

Any idea? Or good keywords for search?

like image 481
masoud Avatar asked Mar 25 '12 19:03

masoud


People also ask

How do you find the intersecting segments?

Define b = q1 - p1 and x = (s,t). If the solution of the linear system A*x = b is in the unit square, then the segments intersect. If the solution is not in the unit square, the segments do not intersect.

How do you find the maximum number of intersections?

Naive Approach: The simplest approach to solve the given problem is to iterate over all segments and for each segment count the number of intersections by checking it with all other segments and then print the maximum among all the count of intersections obtained.


1 Answers

This is Minimum Euclidean Matching in 2D. The link contains a bibliography of what's known about this problem. Given that you want to minimize the total length, the non-intersection constraint is redundant, as the length of any pair of segments that cross can be reduced by uncrossing them.

like image 95
qq3 Avatar answered Sep 19 '22 13:09

qq3