Fast algorithm for polygon/line intersects

  • Context: MHB 
  • Thread starter Thread starter Joppy
  • Start date Start date
  • Tags Tags
    Algorithm
Click For Summary
SUMMARY

The discussion focuses on efficient algorithms for determining intersections between polygons defined as collections of line segments. The sweep-line algorithm is highlighted as a classical method, which involves sorting edges by their highest y-coordinates and sweeping a horizontal line from top to bottom to identify intersections. Additionally, the Bentley-Ottmann Algorithm is mentioned as a robust solution for finding all intersections among arbitrary line segments. The conversation emphasizes the need for faster methods, especially when dealing with a large number of polygons.

PREREQUISITES
  • Understanding of polygon representation as line segments
  • Familiarity with the sweep-line algorithm
  • Knowledge of the Bentley-Ottmann Algorithm
  • Basic concepts of computational geometry
NEXT STEPS
  • Research the implementation details of the sweep-line algorithm
  • Explore the Bentley-Ottmann Algorithm for line segment intersection
  • Study techniques for dividing polygons into subproblems to optimize intersection checks
  • Investigate other computational geometry algorithms for polygon intersection
USEFUL FOR

Mathematicians, computer scientists, and software developers working in fields such as computer graphics, geographic information systems (GIS), and any professionals involved in computational geometry or polygon intersection problems.

Joppy
MHB
Messages
282
Reaction score
22
If we define our polygons as a collection of lines, then each polygon has slopes $\vec{m}$ and y-intercepts $\vec{c}$. For a single line in the plane $y = ax + b$ amounts to finding $x = \dfrac{b - \vec{c}}{\vec{m} - a}$, which is fine. But then we need to sift through the solution vector $x$ and remove any points not on the polygon. This is a trivial operation but costly when the number of polygons is large. What is a faster way to do this?
 
Technology news on Phys.org
Joppy said:
If we define our polygons as a collection of lines, then each polygon has slopes $\vec{m}$ and y-intercepts $\vec{c}$. For a single line in the plane $y = ax + b$ amounts to finding $x = \dfrac{b - \vec{c}}{\vec{m} - a}$, which is fine. But then we need to sift through the solution vector $x$ and remove any points not on the polygon. This is a trivial operation but costly when the number of polygons is large. What is a faster way to do this?

Hey Joppy,

Here's an article that outlines algorithms for polygon intersections.

A classical approach is a so called sweep-line algorithm.
We sort the edges on the highest y-coordinate, and we sweep a horizontal line through them from top to bottom.
The sweep iterates through new edges coming in range, and through intersections of the edges on the corresponding active list.

Another unmentioned approach is to divide into sub problems.
That is, if 2 polygons have a distance to each other that is greater than their size, they won't have intersections.
 
I like Serena said:
Hey Joppy,

Here's an article that outlines algorithms for polygon intersections.

A classical approach is a so called sweep-line algorithm.
We sort the edges on the highest y-coordinate, and we sweep a horizontal line through them from top to bottom.
The sweep iterates through new edges coming in range, and through intersections of the edges on the corresponding active list.

Another unmentioned approach is to divide into sub problems.
That is, if 2 polygons have a distance to each other that is greater than their size, they won't have intersections.

Thanks! I think google is broken, I searched for some time and didn't find anything even remotely on these lines (pun intended).

edit: Hmm wait a minute.. Maybe I'm not understanding the routine highlighted there, but is this method just finding all the roots, or is it finding only those roots lying on say a closed polygon?
 
Last edited:
Joppy said:
Thanks! I think google is broken, I searched for some time and didn't find anything even remotely on these lines (pun intended).

edit: Hmm wait a minute.. Maybe I'm not understanding the routine highlighted there, but is this method just finding all the roots, or is it finding only those roots lying on say a closed polygon?

The Bentley-Ottmann Algorithm finds all intersections of an arbitrary set of line segments.
View attachment 7992
In this example the sweep is with a vertical line from left to right over arbitrary line segments.
 

Attachments

  • 1348015188_9174.png
    1348015188_9174.png
    10.2 KB · Views: 142

Similar threads

  • · Replies 30 ·
2
Replies
30
Views
6K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 25 ·
Replies
25
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K