1

I have multiple convex polygons that intersect. I want to find the areas, where many of them intersect. In an image, one could think of it as a "peak". I am searching for the local peaks.

I have the software to intersect two polygons. Now I am thinking about how to compute the peaks, without computing all possible intersections (exponential time!).

Does somebody have a hint?

yar
  • 1,855
  • 13
  • 26

1 Answers1

1

Given k convex polygons. Let us assume we have the boundary of all polygons given in the form of n line segments. Each line segment has a reference to the polygon it belongs to and its interior side. Let us sort the vertices of the line segments by their x-coordinate. Now we start a line sweep from left to right.

During the sweep at most O(k) times a polygon starts and ends, as all polygons are convex. At such a start event we look through the sweep line status and determine how many other polygons surround us. Which takes O(n) time.

For n segments the line sweep gives you all intersections in O(n log n + k^2) time adding the handling of the start events we obtain O(n log n + k^2 + kn) time. Using the references of the line segments it should be possible to assign to every area (line segment) the number of currently covering polygons.

gue
  • 1,868
  • 1
  • 16
  • 21
  • Thank you for the fast answer! – yar Feb 16 '17 at 15:40
  • If I understand you right, then the following example will not work: Two rhomb-shaped polygons intersect in the middle, but their left and right parts do not intersect. The sweep line goes from left to right, so that at every start of a polygon we count 1 polygon and at the end, we count 0 polygons. This way we miss the intersection, right? – yar Feb 16 '17 at 17:26
  • @yar the main advantage of the sweepline approach is that we find these intersections. As we already know how many polygons are nested before such an intersection we only have to increase or decrease the number assigned to the respective segments, depending on the type of intersection. As we know where the relative interior of the segments lies we can locally deside what to do. – gue Feb 16 '17 at 17:34
  • Does it make sense to extend this approach to 3D convex polyhedra or is there a better approach for that? – yar Feb 16 '17 at 20:04
  • This approach is, lets say, relatively straight forward in the 2D case and common practice in CG. I could imagine that one can extend it to 3D. However, it will be much more complicated. We would use a sweep plane and every intersection with the polyhedra would again yield convex polygons in the sweep plane. Still, to catch an edge of one polyhedra that intersects a face of another will be one challenge and one may have to resort to ray shooting or other approaches in any case. – gue Feb 17 '17 at 07:11
  • Yes, sweep in 3D is typically verry painstaking. Unfortunately the 3D problem is the one I need to solve. The polyhedrons are verry sinple, but there are lots of them. I think I'll open a new question for that. If nobody has another ide, I'll try the space sweep. – yar Feb 17 '17 at 12:32