围绕另一个多边形重塑一个多边形

发布于 2024-11-29 18:15:02 字数 563 浏览 3 评论 0原文

我不认为这是一个重复的问题——至少我希望不是。

我有两个多边形 A 和 B。B 可能完全在 A 内部,也可能部分与其相交。要求是重绘多边形A,使其环绕多边形B。我很清楚如何处理B完全在A内的情况。我在距离B最近的点处切割A,然后将组成B的点插入到A 的最近点的点列表并再次添加该点。这应该创建 A 围绕 B 的流动。我的库中有很多几何算法来计算距离、方位等,但我看不出它们中有任何一个有帮助。两个多边形都可以是凹的、凸的等。

我的问题B 部分位于 A 内。在这里,我确定了 B 的边缘与 A 的边缘相交的位置,并在 A 中为这些点创建了新的点。然后,我删除完全位于 B 内的所有 A 点,因为我不再需要它们。在这里它崩溃了。我知道 B 中的点需要插入到 A 中。我不知道在哪里插入它们或如何解决它们。

我看过几篇介绍多边形相交和碰撞的文章 - 例如这个 如何相交两个多边形?

我不清楚的是我是否应该将此视为解决我的问题的一种方式,或者这里是否有一些我缺少的更简单的东西

I don't think this is a duplicate question - at least I hope not.

I have two polygons A and B. B may be entirely inside A or may partly intersect with it. The requirement is to redraw polygon A so that it wraps around Polygon B. I am clear how to handle the case where B is entirely within A. I cut A at the nearest point to B and then insert the points that make up B into the point list for A at the nearest point and add that point again. This should create a flow of A around B. I have plenty of geometry algorithms in my library to calculate distances, bearings and so on but I can't see any of them being helpful Both polygons can be concave, convex etc etc.

My problem comes where B is partially within A. Here I get as far as identifying where the edges of B intersect the edges of A and creating new points in A for those. I then remove any A point that are fully within B since I no longer need them. Here it falls apart. I know the points in B that I need to insert into A. What I don't know is where to insert them or how to work that out.

I have looked at several articles that cover polygon intersection and collision - for example this How to intersect two polygons?.

What I am not clear about is whether I should be looking at this as a way of solving my problem or whether there is something simpler here that I am missing

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文