给定点集和 Delaunay 三角剖分,如何导出 Voronoi 图?
我正在开发一款游戏,在其中创建一个随机的省份地图(风险或外交)。 为了创建该地图,我首先生成一系列半随机点,然后计算这些点的 Delaunay 三角剖分。
完成此操作后,我现在希望创建一个点的 Voronoi 图,作为省边界的起点。 此时我的数据(无双关语)由原始的一系列点和 Delaunay 三角形的集合组成。
我在网上看到了很多实现此目的的方法,但其中大多数都与 Delaunay 的派生方式有关。 我很想找到一些不需要集成到 Delaunay 中,但可以单独基于数据工作的东西。 如果做不到这一点,我正在寻找相对几何新手可以理解的东西,而不是最佳速度。 谢谢!
I'm working on a game where I create a random map of provinces (a la Risk or Diplomacy). To create that map, I'm first generating a series of semi-random points, then figuring the Delaunay triangulations of those points.
With that done, I am now looking to create a Voronoi diagram of the points to serve as a starting point for the province borders. My data at this point (no pun intended) consists of the original series of points and a collection of the Delaunay triangles.
I've seen a number of ways to do this on the web, but most of them are tied up with how the Delaunay was derived. I'd love to find something that doesn't need to be integrated to the Delaunay, but can work based off the data alone. Failing that, I'm looking for something comprehensible to a relative geometry newbie, as opposed to optimal speed. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Voronoi 图只是 Delaunay 三角剖分的对偶图。
请注意,确切的代码取决于您用于这两个图的内部表示。
The Voronoi diagram is just the dual graph of the Delaunay triangulation.
Note that the exact code depends on the internal representation you're using for the two diagrams.
如果不考虑最佳速度,则以下伪代码将以困难的方式生成 Voronoi 图:
假设您有一个“点”类或结构,如果您为它们分配随机颜色,那么当您显示输出。
If optimal speed is not a consideration, the following psuedo code will generate a Voronoi diagram the hard way:
Assuming you have a 'point' class or structure, if you assign them random colours, then you'll see the familiar voronoi pattern when you display the output.
首先获取 Delaunay 三角剖分。 每个三角形外接圆的中心是 Voronoi 曲面细分的顶点(点)。 然后简单地连接相邻三角形的所有外接圆的中心即可导出镶嵌。 从维基百科来看,如下所示。
首先,获取所有外接圆中心(来自所有三角形) - 即红点:
接下来,用直线将每个相邻三角形的外接圆中心连接起来获取镶嵌:
Start by obtaining the Delaunay triangulation first. The center of each triangle's circumcircle is a vertex (point) for the Voronoi tesselation. Then simply connect the centers of all the circumcircles of the neighboring triangles to derive the tesselation. From Wikipedia, this is shown as follows.
First, get all the circumcircle centers (from all the triangles) - i.e., the red points:
Next, connect the centers of circumcircles for each neighboring triangle together with lines to get the tesselation:
每个 Delaunay 三角形都包含 Voronoi 图的一个点。
您可以通过查找每个三角形的三个垂直平分线的交点来计算该点。
您的 Voronoi 图将连接这组点,每个点与其最近的三个邻居。 (每个邻居共享德劳内三角形的一条边)
您打算如何处理边缘情况?
Each of your Delaunay triangles contains a single point of the Voronoi diagram.
You can compute this point by finding the intersection of the three perpendicular bisectors for each triangle.
Your Voronoi diagram will connect this set of points, each with it's nearest three neighbors. (each neighbor shares a side of the Delaunay triangle)
How do you plan on approaching the edge cases?