2D 细节层次 (LOD) 算法

发布于 2024-10-08 09:54:10 字数 182 浏览 4 评论 0原文

我一直在网上寻找一种算法,使您能够创建 2D 多边形的细节级别 (LOD) 表示,但无法找到任何合适的参考。也许我使用了错误的搜索词,但所有搜索结果都是针对 3D LOD 算法的,我猜这不能(?)真正应用于 2D。

我确信,在 3D 图形出现之前,许多人都会研究 2D LOD 算法。有任何线索或指示我可以在哪里获得更多信息吗?谢谢!

I have been scouting around the net for an algorithm that enables you to create level of detail (LOD) representations of 2D polygons, but am unable to find ANY decent reference. Maybe I am using the wrong search terms, but all search results are for 3D LOD algorithms, which, I guess, cannot(?) really be applied in 2D.

I am sure that before the onslaught of 3D graphics, many people would have worked on 2D LOD algorithms. Any clues or pointers to where I can get more information? Thanks!

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

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

发布评论

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

评论(2

天赋异禀 2024-10-15 09:54:10

除了明显最愚蠢的算法(即从多边形中取出第 N 个顶点(将顶点数量减少 N))之外,这里还有一个受某些 3D 算法启发的想法。

通常,在 3D 中,需要删除对整体体积贡献较小的面。为此,我们尝试简化模型的“最平坦”区域。

现在在 2D 中,您可以将其翻译为“简化它们之间具有最小角度的线段。第一个简单的实现可以是:

  1. 计算多边形线段 Si 和 Si+1 之间的所有角度
  2. 取低于给定阈值的所有角度(或取 M 个最小角度)
  3. 简化我们在 2 中确定的线段(将 [Pi, Pi+1] 和 [Pi+1, Pi+2] 替换为 [Pi, Pi+2])
  4. 从 1. 开始重复,直到我们得到已经充分减少了我们的多边形

当然,这不是最佳的,但它应该是质量和速度之间的一个很好的权衡,而不是角度,您可以采用两个线段的中点(Pi + 1)和线段之间的最小距离。可能简化的线段([Pi,Pi+2])

编辑:

如果我不需要太多性能,我会尝试另一种算法:

  1. 将原始多边形顶点视为Catmull-Rom样条线的控制点
  2. 以所需的数量对该样条线进行细分最后

,我在该链接上为您找到了一些源代码: http:// Motiondraw.com/md/as_samples/t/LineGeneralization/demo.html,以及相关算法:http://www.geom.unimelb.edu.au/gisweb/LGmodule/LGSimplification.htm

Aside from the obvious dumbest algorithm which would be to take every Nth vertex from the polygon (reducing the number of vertices by N), here is an idea inspired by some 3D algorithms.

Usually, in 3D, what is required is to remove the faces that contribute less to the overall volume. To do this, we try to simplify the "flattest" areas of the model.

Now in 2D, you could translate this to "simplify the segments that have the smallest angle between them. A first naïve implementation could be:

  1. Compute all angles between the segments Si and Si+1 of the polygon
  2. Take all the angles below a given threshold (or take the M smallest angles)
  3. Simplify the segments we identified in 2. (replace [Pi, Pi+1] and [Pi+1, Pi+2] by [Pi, Pi+2])
  4. Repeat from 1. until we have sufficiently reduced our polygon

Of course, this is not optimal but it should be a good trade of between quality and speed. Instead of the angle, you could take the minimal distance between the middle point of two segments (Pi+1) and the potentially simplified segment ([Pi, Pi+2])

Edit:

Another algorithm I would try if I did not need too much performance:

  1. Consider the original polygon vertices as the control points of a Catmull-Rom spline
  2. Tesselate this spline at the desired number of points

Finally, I found some source code for you on that link: http://motiondraw.com/md/as_samples/t/LineGeneralization/demo.html, as well as the associated algorithms: http://www.geom.unimelb.edu.au/gisweb/LGmodule/LGSimplification.htm

慈悲佛祖 2024-10-15 09:54:10

搜索 Douglas-Peucker 算法 用于简化折线,但可以扩展以支持多边形。这是我用过的。如果您需要的话,还有拓扑稳定的扩展。

Search for Douglas-Peucker algorithm which is used to simplify polylines, but may be extended to support polygons. It is what I have used. There are also topologically stable extensions if you need that.

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