Delaunay Triangulations Pedagogical Aid

by Shih-Ting Huang


In this project, I created an interactive pedagogical aid of Delaunay Triangulations. The visualization shows how the incremental method works on a set of random points.

Interactive demo page.

Background information and approach

Pseudo-code

Input: a set P of n points in the plane.
Output: a Delaunay triangulation of P.

DelaunayTriangulation(P) {
  Create a helper triangle contains all points.
  for every point p in P {
     Find the triangle abc contains p
     Push edges (p, a), (p, b), (p, c) into the triangulation
     SwapTest(p, a, b)
     SwapTest(p, b, c)
     SwapTest(p, c, a)
  }
  Delete all edges connected to helper points from the triangulation
  return the triangulation
}

SwapTest(p, a, b) {
  if (ab is an edge of helper triangle) return;
  find the opposite vertex d, share same edge ab with p
  if (d in the circle formed by p, a, b) {
     Delete edge (a, b), and push edge(p, d) into the triangulation
     SwapTest(p, a, d)
     SwapTest(p, d, b)
  }

Features of the Implementation

References

  1. Computational Geometry - Algorithms and Applications (textbook)
  2. Delaunay Triangulation (Wikipedia)
  3. p5.js (Javascript library)