从相交的盒子中找到实心多边形的算法?
所以我有一组重叠的二维矩形,我想找到一个代表它们覆盖区域的多边形。多边形也可能有孔,这将由多边形内的多边形表示。
所以我猜测我的输出将是一个树状结构,其中实心多边形的子级是孔,孔的子级是孔内的岛多边形(希望这是有意义的)
多边形只是顶点列表,其中最后一个与第一个相同
这是我正在讨论的图片:
谢谢!
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 of what I'm talking about:
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从来没有尝试这样做,但我的直觉反应是考虑集合,也许找到你的岛屿、不相交集合。
可能有更好的解决方案,但这至少可以为您提供一些研究的东西。
编辑:还有另一个问题,其中一些代码似乎可以解决您的问题:
算法将相邻的矩形合并为多边形
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