How to intersect multiple polygons?

孤街浪徒 提交于 2019-12-10 22:47:58

问题


I am looking for an algorithm with the following input and output:

Input: A set of polygons in a plane. E.g. P1...Pn and S. (P1...Pn might be concave, S is convex.)

Output: The area of theset of polygons in this plane that equals the difference of S and the union of P1...Pn.

I found algorithms to intersect or merge TWO polygons. But since each of those operations might produce several polygons I createt tons of polygons if I did it naively.

So: How to handle the intersection of multiple polygons?

It would be ok, if all polygons are connected together since only the area is what I am after. My thought was to use directed polygons to simulate holes but then I again have the problem to find out if I have a "minimal representation" as n could blow up. [Do you understand what I am talking about? It's quite strange...)


回答1:


You could throw all edges together into a sweep line algorithm. It may not be optimal (?) but at least you will get the minimal representation you are looking for.




回答2:


One solution is to convert each polygon into a bunch of triangles. Once you do that it is fairly easy to find union/intersection/difference between a set of areas since you can perform the same functions trivially on a triangle (result on two triangles may include up to 6 triangles).




回答3:


The most straightforward approach would be decomposing your concave polygons into convex ones. Then intersecting two convex polygons is almost trivial.



来源:https://stackoverflow.com/questions/9399711/how-to-intersect-multiple-polygons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!