开发者

Algorithm for finding a solid polygon from intersecting boxes?

开发者 https://www.devze.com 2023-03-21 19:21 出处:网络
So I have a set of 2D rectangles that overlap, and I want to find a polygon that represents the area they cover. It\'s possible for the polygon to have holes also, which would be represented by a poly

So I have a set of 2D rectangles that overlap, and I want to find a polygon that represents the area they cover. It's possible for the polygon to have holes also, which would be represented by a polygon within a polygon.

So I'm guessing my output would be a tree-like structure, where a solid polygon's children are the holes, and the hole's children are island polygons within the holes(hopefully that makes sense)

A polygon would just be a list of vertices, where the last one is the same as the first

Here's a picture o开发者_运维问答f what I'm talking about:

Algorithm for finding a solid polygon from intersecting boxes?

Thanks!


I've never tried to do this but my gut reaction was to consider Sets and perhaps to find your Islands, Disjoint sets.

There probably is a better solution, but that at least might give you something to research.

Edit: there's another question that has some code that seems to solve your problem:

Algorithm to merge adjacent rectangles into polygon

0

精彩评论

暂无评论...
验证码 换一张
取 消