从相交的盒子中找到实心多边形的算法?

发布于 2024-11-25 02:30:11 字数 253 浏览 9 评论 0原文

所以我有一组重叠的二维矩形,我想找到一个代表它们覆盖区域的多边形。多边形也可能有孔,这将由多边形内的多边形表示。

所以我猜测我的输出将是一个树状结构,其中实心多边形的子级是孔,孔的子级是孔内的岛多边形(希望这是有意义的)

多边形只是顶点列表,其中最后一个与第一个相同

这是我正在讨论的图片:

输入和输出

谢谢!

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:

Input and output

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你另情深 2024-12-02 02:30:11

我从来没有尝试这样做,但我的直觉反应是考虑集合,也许找到你的岛屿、不相交集合。

可能有更好的解决方案,但这至少可以为您提供一些研究的东西。

编辑:还有另一个问题,其中一些代码似乎可以解决您的问题:

算法将相邻的矩形合并为多​​边形

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文