Fast algorithm for polygon/line intersects

  • MHB
  • Thread starter Joppy
  • Start date
  • Tags
    Algorithm
In summary: All line segments which intersect the vertical sweep line are stored in an event queue sorted by the x coordinate of the intersection with the sweep line. In summary, the conversation discusses different approaches to finding intersections between polygons. One approach is to use a classical sweep-line algorithm where the edges of the polygons are sorted and a horizontal line is swept through them to find intersections. Another approach is to divide the problem into smaller subproblems by considering the distance between polygons. There is also mention of the Bentley-Ottmann Algorithm which finds all intersections of an arbitrary set of line segments.
  • #1
Joppy
MHB
284
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
  • #2
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.
 
  • #3
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:
  • #4
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: 91

FAQ: Fast algorithm for polygon/line intersects

What is a fast algorithm for polygon/line intersects?

A fast algorithm for polygon/line intersects is a method for determining whether a line segment intersects with a polygon in a computationally efficient manner. This is commonly used in computer graphics, mapping, and other applications.

How does a fast algorithm for polygon/line intersects work?

The specific steps of a fast algorithm for polygon/line intersects may vary, but generally it involves breaking down the problem into smaller and simpler calculations, such as determining if a point is inside or outside a polygon, and using these results to determine if the line segment intersects with the polygon.

What are the advantages of using a fast algorithm for polygon/line intersects?

The main advantage of using a fast algorithm for polygon/line intersects is that it greatly reduces the amount of time and processing power needed to determine if a line segment intersects with a polygon. This is especially useful when dealing with large and complex polygons.

Are there different types of fast algorithms for polygon/line intersects?

Yes, there are various types of fast algorithms for polygon/line intersects, each with their own specific steps and optimizations. Some common types include the point-in-polygon algorithm, line intersection algorithm, and the ray-casting algorithm.

Can a fast algorithm for polygon/line intersects handle concave polygons?

Yes, most fast algorithms for polygon/line intersects are designed to handle both convex and concave polygons. However, the complexity and efficiency of the algorithm may vary depending on the shape of the polygon.

Back
Top