Implementing Bowyer-Watson algorithm for delaunay triangulation

耗尽温柔 提交于 2019-12-23 04:39:29

问题


I am trying to implement the following Bowyer-Watson algorithm to implement Delaunay Triangulation.

function BowyerWatson (pointList)
  // pointList is a set of coordinates defining the points to be triangulated
  triangulation := empty triangle mesh data structure
  add super-triangle to triangulation // must be large enough to completely contain all the points in pointList
  for each point in pointList do // add all the points one at a time to the triangulation
     badTriangles := empty set
     for each triangle in triangulation do // first find all the triangles that are no longer valid due to the insertion
        if point is inside circumcircle of triangle
           add triangle to badTriangles
     polygon := empty set
     for each triangle in badTriangles do // find the boundary of the polygonal hole
        for each edge in triangle do
           if edge is not shared by any other triangles in badTriangles
              add edge to polygon
     for each triangle in badTriangles do // remove them from the data structure
        remove triangle from triangulation
     for each edge in polygon do // re-triangulate the polygonal hole
        newTri := form a triangle from edge to point
        add newTri to triangulation
  for each triangle in triangulation // done inserting points, now clean up
     if triangle contains a vertex from original super-triangle
        remove triangle from triangulation
  return triangulation

The algorithm takes O(N log N) operations to triangulate N points as claimed. But is there any way to calculate it from the above algorithm? I mean which part of the above algorithm takes log N times, which results in (N log N) for n points? special degenerate cases exist where this goes up to O(N2) as written in wikipedia. What is the meaning of this degenerate case?


回答1:


Maybe it is a bit late to answer, but it might be useful to someone else.

A Delaunay triangulation have a circumcircle property, hence no point of the Delaunay triangulation can lie within the circumscribed circle of any triangle. The Bowyer-Watson algorithm add a point that does not verify this property. It can be shown that all triangles which circumscribed circle contain the new point are contiguous.

To obtain the theoretical NlogN you must use the contiguous fact. (I use a connectivity table)

=> You need to search for a first triangle in your triangulation where the circumcirle property is not respected( complexity log(N) )

=> Once you have it, delete contigued triangles (using connectivity table) (independent of total number of nodes)

=> Build new triangles (and update the table) (independent of total number of nodes)

And you need to do it N times, for each nodes. This result in a theoretical Nlog(N) complexity.

The algorithm given on wikipedia looks like a loop of loop of N size. Hence, it should automatically gave you a N^2 complexity.

This complexity should be the worst case scenario were all elements are deleted and no connectivity is available, as said Ripi2. In such case, you would have no choice but to search in all triangles. See https://doi.org/10.1006/jcph.1993.1097 for more informations




回答2:


There are two main steps in the algorithm:

  1. for each triangle in triangulation, if point is inside circumcircle ...
  2. for each triangle in badTriangles, remove and add new tringles ...

The first step is a bad approach. There are better ways to locate a triangle where the new point to add lies on. Search for "walking" from an old triangle towards new point.

The second step can involve all triangles for a degenerated case where all points lie in a common big circle.




回答3:


Anyway, thanks to the initial pseudo-code, very clear, I had fun implementing it with Scratch : https://scratch.mit.edu/projects/351857925

So thank you :-)




回答4:


The algorithm described here is a naive incremental delaunay triangulation. The complexity is clearly O(N^2). "for each point in pointList do // add all the points one at a time to the triangulation" this main loop is O(N) and "for each triangle in triangulation do // first find all the triangles that are no longer valid due to the insertion" this inner loop is O(N).

And this algorithm is O(N^2) in all scenarios. However, there are other algorithms that do give O(N * Log(N)) or better complexity. See "Divide and Conquer" from here: https://en.wikipedia.org/wiki/Delaunay_triangulation



来源:https://stackoverflow.com/questions/40934453/implementing-bowyer-watson-algorithm-for-delaunay-triangulation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!