给定点集和 Delaunay 三角剖分,如何导出 Voronoi 图?

发布于 2024-07-04 08:56:57 字数 321 浏览 7 评论 0原文

我正在开发一款游戏,在其中创建一个随机的省份地图(风险或外交)。 为了创建该地图,我首先生成一系列半随机点,然后计算这些点的 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 技术交流群。

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

发布评论

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

评论(4

初心未许 2024-07-11 08:56:57

Voronoi 图只是 Delaunay 三角剖分的对偶图。

  • 因此,Voronoi 图的边缘沿着 Delaunay 三角剖分的边缘的垂直平分线,因此请计算这些线。
  • 然后,通过查找相邻边的交点来计算 Voronoi 图的顶点。
  • 最后,边是您计算的位于相应顶点之间的线的子集。

请注意,确切的代码取决于您用于这两个图的内部表示。

The Voronoi diagram is just the dual graph of the Delaunay triangulation.

  • So, the edges of the Voronoi diagram are along the perpendicular bisectors of the edges of the Delaunay triangulation, so compute those lines.
  • Then, compute the vertices of the Voronoi diagram by finding the intersections of adjacent edges.
  • Finally, the edges are then the subsets of the lines you computed which lie between the corresponding vertices.

Note that the exact code depends on the internal representation you're using for the two diagrams.

攒眉千度 2024-07-11 08:56:57

如果不考虑最佳速度,则以下伪代码将以困难的方式生成 Voronoi 图:

for yloop = 0 to height-1
  for xloop = 0 to width-1

    // Generate maximal value
    closest_distance = width * height

    for point = 0 to number_of_points-1
      // calls function to calc distance
      point_distance = distance(point, xloop, yloop)

      if point_distance < closest_distance
        closest_point = point
      end if
    next

  // place result in array of point types
  points[xloop, yloop] = point

  next
next

假设您有一个“点”类或结构,如果您为它们分配随机颜色,那么当您显示输出。

If optimal speed is not a consideration, the following psuedo code will generate a Voronoi diagram the hard way:

for yloop = 0 to height-1
  for xloop = 0 to width-1

    // Generate maximal value
    closest_distance = width * height

    for point = 0 to number_of_points-1
      // calls function to calc distance
      point_distance = distance(point, xloop, yloop)

      if point_distance < closest_distance
        closest_point = point
      end if
    next

  // place result in array of point types
  points[xloop, yloop] = point

  next
next

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.

筑梦 2024-07-11 08:56:57

首先获取 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:

enter image description here

Next, connect the centers of circumcircles for each neighboring triangle together with lines to get the tesselation:

enter image description here

酒废 2024-07-11 08:56:57

每个 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?

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