查找使用C#多边形的中轴 [英] Find medial axis of a polygon using C#

查看:735
本文介绍了查找使用C#多边形的中轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在负责找出如何找到一个多边形的中心线。我的谷歌搜索使我相信,我需要什么叫中轴。像这样的:

I've been tasked to figure out how to find the centerline of a polygon. My google searches led me to believe that what I need is called the 'Medial Axis'. Like this:

据我读过,我需要什么可以通过使用段的二维Voronoi图构建算法产生。

According to what I've read, what I need can be produced by using a 2D Voronoi diagram construction algorithm for segments.

我发现CodePlex上的Voronoi图算法(FortuneVoronoi)的C#版本和应用我的多边形来后,我结束了这一点:

I've found a C# version of the Voronoi algorithm on codeplex (FortuneVoronoi) and after applying my polygon to it, I end up with this:

绿色是原来的多边形。橙色是的Voronoi顶点和黑线是Voronoi图的边缘。

The green is the original polygon. The orange are the Voronoi vertices and the black lines are the voronoi edges.

我可以看到什么,我需要在那些顶点气质,但我不能确定的要求下一步要过滤掉所有的东西,我不需要。

I can see the makings of what I need in those vertices, but I'm unsure of the next step required to filter out all the stuff I don't need.

我会很感激你能提供任何帮助。

I'd appreciate any help you can offer.

推荐答案

一个简单的解决方案将作为建议的意见:

One simple solution would be as suggested in the comments:


  1. 构建Delaunay三角的多边形顶点。

  2. 标识的Voronoi顶点的多边形内(见
    http://en.wikipedia.org/wiki/Point_in_polygon

  3. 输出的Voronoi边连接两个内部的Voronoi顶点。

如果你有大量的数据的交集可能是相当昂贵的。

If you have huge data the intersections might be quite costly.

然后,你可以做一个类似像问题方法,和该解决方案可以为你工作,以及。我会做它的方式:

Then you could do a similar approach like in the question, and this solution could work for you, as well. The way I would do it:


  1. 生成多边形顶点的Delaunay三角

  2. 插入。未覆盖的边缘德洛奈每个多边形边的中点。递归地做到这一点,直到所有多边形边缘被德劳内覆盖边缘。

  3. 标记全部德劳内边缘对应于一个多边形的边缘。

  4. 提取中轴按步骤3-5。在这个解决方案

  1. Build the Delaunay triangulation of the polygon vertices.
  2. Insert the midpoint of every polygon edge that is not covered by a delaunay edge. Do this recursively until all polygon edges are covered by Delaunay edges.
  3. Mark all Delaunay edges which correspond to a polygon edge.
  4. Extract the medial axis using steps 3.-5. in this solution

PS。请注意,这两个解决方案为中轴的一些的逼近的,它的计算究竟是更昂贵,但作为一个传情......你可以得到这样的结果黑色输入采样点:

PS. Note that both solutions give some approximation of the medial axis, computing it exactly is much more costly but as a teaser... you can get results like this for the black input sample points:

这篇关于查找使用C#多边形的中轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆