0

Given two simple polygons P and Q where P is convex but Q not, how fast can one compute the difference $P - Q$ between P and Q if P has n and Q has m vertices?

One can assume that the polygons are given as list of vertices ordered in clockwise direction.

user695652
  • 4,105
  • 7
  • 40
  • 58

1 Answers1

0

"How fast" depends on lots of parameters, so I think, we should start with how to do it,first.

Firstly, I assume polygons lie on the same plane. Start with computing the finite intersection of each line of P with each line of Q. If the intersection exists and intersection point lies on intersecting lines(I mean between start and end, not on them), divide line into two and continue finite line-line intersections iteratively. Then, categorize each line segment(now I can call them as segment because that they are all divided if necessary) by using a point in polygon computation with mid-points of segments..Inner,Outer or OnthePolygon...After categorization construct a new polygon from the lines of P that lies outside of Q and lines of Q that lies inside of the P. Here, your challenge will be dealing with tolerances and lines that are lies on eachother..At first glance, overall algorithm is like this..

This algorithm can be improved by eliminating lines and even polygons by computing their ranges(min and max for each axis). Except from the hardware, programming language or data handling parameters, the speed of this operation is dependent on the input polygons and their orientation.

Semih Ozmen
  • 571
  • 5
  • 20