Fast algorithm for polygon/line intersects

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

Discussion Overview

The discussion revolves around algorithms for determining intersections between polygons and lines, focusing on computational efficiency. Participants explore various methods, including the sweep-line algorithm and the Bentley-Ottmann Algorithm, while addressing the challenges of filtering intersection points that lie within the boundaries of polygons.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Some participants propose defining polygons as collections of lines characterized by slopes and y-intercepts, leading to a mathematical formulation for finding intersection points.
  • One participant suggests the sweep-line algorithm as a classical approach, which involves sorting edges and sweeping a horizontal line to find intersections.
  • Another approach mentioned is dividing the problem into sub-problems based on the distance between polygons, suggesting that if polygons are far apart, they cannot intersect.
  • There is a question raised about whether the sweep-line method finds all roots or only those that lie within closed polygons, indicating uncertainty about the algorithm's specifics.
  • The Bentley-Ottmann Algorithm is introduced as a method for finding all intersections of arbitrary line segments, with a vertical sweep line approach described.

Areas of Agreement / Disagreement

Participants express varying levels of understanding regarding the algorithms discussed, and there is no consensus on the effectiveness or applicability of the methods presented. Questions remain about the specifics of the algorithms and their outcomes.

Contextual Notes

Participants highlight potential limitations in understanding the algorithms, particularly regarding the filtering of intersection points and the conditions under which intersections are determined.

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: 145

Similar threads

  • · Replies 30 ·
2
Replies
30
Views
7K
  • · 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