Delaunay Triangulation

A triangulation of a finite point set in the plane partitions the convex hull of into triangles. The triangles’ vertices are points of , and no triangle contains another point of . A point set has exponentially many triangulations. Let have points, not all collinear, with of them on the hull boundary. Then every triangulation has triangles and edges.

Triangulations are ranked by their angles. For a triangulation with triangles, let list all of its angles in increasing order. is better than if lexicographically, which means larger at the first position where the two vectors differ. The Delaunay triangulation (DT) is the best one. In particular, it maximizes the smallest angle, so it avoids skinny triangles. Equivalently, no point of lies strictly inside the circumcircle of any of its triangles, which is the empty circle property.

Two triangles that share an edge form a quadrilateral. When it is convex, the shared diagonal can be replaced by the other diagonal, an edge flip. An edge is illegal if flipping it improves the triangulation. This happens exactly when the two angles opposite the edge sum to more than . If a flip improves the triangulation locally, it also improves it globally. The naive algorithm starts from any triangulation and flips illegal edges until none remain. It always terminates but can take a long time. A faster route uses duality: the DT is the dual of the Voronoi diagram, built by connecting every two sites whose Voronoi cells share an edge. This gives the DT in time and is what MATLAB’s delaunay uses. In Python, scipy.spatial.Delaunay computes it with the Qhull library. Under the general position assumption that no four points lie on a common circle, the DT is unique.

In image morphing, one DT is computed on the mean of the two point sets. Its index triples are reused in both images and in every frame.

Intuition

Morphing and many other mesh methods need triangles over a set of points, and some triangulations are much better than others. Long, thin triangles cover pixels that are far from their own corners, and their affine maps react strongly to small errors in the points. The Delaunay triangulation picks the fattest triangles available. Its test is local. Look at two triangles that share an edge, and check whether the other diagonal of their quadrilateral would give larger angles. If yes, flip it. The figure shows a parallelogram with both choices. On the left, the long diagonal gives two skinny triangles, and the circle through one triangle contains the fourth point. On the right, the short diagonal gives fatter triangles, and both circles are empty.

\usepackage{tikz}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\definecolor{mid}{HTML}{8A8A8A}
\begin{tikzpicture}[x=0.75cm,y=0.75cm,>=latex]
\draw[hot,dashed] (2,2.25) circle (3.0104);
\draw[thick] (0,0) -- (4,0) -- (5,2) -- (1,2) -- cycle;
\draw[very thick,hot] (0,0) -- (5,2);
\foreach \p/\l/\a in {(0,0)/P_1/below left,(4,0)/P_2/below right,(5,2)/P_3/right,(1,2)/P_4/above left} \fill \p circle (2pt) node[\a] {$\l$};
\fill[hot] (1,2) circle (2.5pt);
\node[hot,align=center] at (2.5,-2.2) {illegal: $P_4$ inside the circle\\ through $P_1P_2P_3$, smallest angle $21.8^\circ$};
\begin{scope}[shift={(9.5,0)}]
\draw[cold,dashed] (2,0.25) circle (2.0156);
\draw[cold,dashed] (3,1.75) circle (2.0156);
\draw[thick] (0,0) -- (4,0) -- (5,2) -- (1,2) -- cycle;
\draw[very thick,cold] (4,0) -- (1,2);
\foreach \p/\l/\a in {(0,0)/P_1/below left,(4,0)/P_2/below right,(5,2)/P_3/right,(1,2)/P_4/above left} \fill \p circle (2pt) node[\a] {$\l$};
\node[cold,align=center] at (2.5,-2.4) {Delaunay: both circles empty,\\ smallest angle $33.7^\circ$};
\end{scope}
\end{tikzpicture}
\end{document}

Properties

(Empty Circle Test) A triangle with corners , , (counterclockwise) has a point strictly inside its circumcircle exactly when a determinant is positive.

The test is

where the subscripts are the and coordinates of each point. A value of means lies on the circle, the co-circular case. For an edge shared by triangles and , this test on and the opposite-angle test give the same answer. The angle version follows from the inscribed angle theorem. The angles at and sum to more than exactly when is inside the circle through , and . Implementations prefer the determinant, because it uses only multiplications and no trigonometry.

(Why Flipping Terminates) Every flip of an illegal edge makes the angle vector strictly larger, and there are only finitely many triangulations.

So the naive flip algorithm cannot cycle and must stop. When no illegal edge is left, every edge passes the local test, and a triangulation whose edges all pass the local test is the DT. The number of flips can grow like , which is why the lecture says it “could take a long time to terminate.” The initial triangulation can come from the lecture’s method. It goes through pairs of points and keeps the segment between two points if it crosses no segment kept so far. There are about pairs, and each check against the kept edges costs .

(Voronoi Duality) Each Delaunay triangle corresponds to a Voronoi vertex, its circumcenter, and the empty circle property follows.

The Voronoi cell of a site is the set of plane points closer to than to any other site. A Voronoi vertex is equidistant from three sites, so it is the circumcenter of the triangle on those sites. No other site can be closer to that vertex, so the circle through the three sites is empty. Each Voronoi edge separates two sites, and the DT connects exactly those pairs. The figure shows the Voronoi diagram (gray, dashed) and its dual DT (blue) for seven sites.

\usepackage{tikz}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\definecolor{mid}{HTML}{8A8A8A}
\begin{tikzpicture}[x=0.8cm,y=0.8cm,>=latex]
\begin{scope}
\clip (-0.4,-0.6) rectangle (7.8,6.2);
\draw[mid,dashed] (1.624,2.556) -- (-18.288,4.422);
\draw[mid,dashed] (2.870,4.112) -- (-4.923,22.532);
\draw[mid,dashed] (1.624,2.556) -- (2.870,4.112);
\draw[mid,dashed] (1.624,2.556) -- (2.574,1.191);
\draw[mid,dashed] (2.574,1.191) -- (-0.714,-18.537);
\draw[mid,dashed] (4.132,3.832) -- (18.274,17.974);
\draw[mid,dashed] (5.076,1.908) -- (22.441,11.830);
\draw[mid,dashed] (4.132,3.832) -- (4.937,1.979);
\draw[mid,dashed] (5.076,1.908) -- (4.937,1.979);
\draw[mid,dashed] (2.870,4.112) -- (4.132,3.832);
\draw[mid,dashed] (5.076,1.908) -- (11.803,-16.927);
\draw[mid,dashed] (2.574,1.191) -- (4.937,1.979);
\end{scope}
\draw[thick,cold] (1.0,1.0) -- (4.0,0.5);
\draw[thick,cold] (1.0,1.0) -- (3.3,2.6);
\draw[thick,cold] (1.0,1.0) -- (1.3,4.2);
\draw[thick,cold] (4.0,0.5) -- (6.8,1.5);
\draw[thick,cold] (4.0,0.5) -- (3.3,2.6);
\draw[thick,cold] (4.0,0.5) -- (5.6,3.6);
\draw[thick,cold] (6.8,1.5) -- (5.6,3.6);
\draw[thick,cold] (3.3,2.6) -- (5.6,3.6);
\draw[thick,cold] (3.3,2.6) -- (1.3,4.2);
\draw[thick,cold] (3.3,2.6) -- (3.9,5.3);
\draw[thick,cold] (5.6,3.6) -- (3.9,5.3);
\draw[thick,cold] (1.3,4.2) -- (3.9,5.3);
\foreach \p in {(1,1),(4,0.5),(6.8,1.5),(3.3,2.6),(5.6,3.6),(1.3,4.2),(3.9,5.3)} \fill \p circle (2.2pt);
\draw[hot] (2.870,4.112) circle (1.572);
\fill[hot] (2.870,4.112) circle (1.8pt);
\node[hot] at (3.7,6.7) {\small empty circumcircle, centered at a Voronoi vertex};
\end{tikzpicture}
\end{document}

(Fat Triangles for Morphing) Skinny triangles make the per-triangle affine maps sensitive to small clicking errors.

The triangle-to-triangle map of 3.1. Affine Transformations inverts the matrix with columns and . Its determinant is twice the triangle’s area. A thin triangle has a small determinant, so its inverse has large entries. A one-pixel error in a clicked point then changes the warp of that triangle by a lot, and the texture inside it visibly stretches. A thin triangle also needs only a small movement of one corner to fold over, which breaks the morph. The DT avoids thin triangles when the points allow it. Computing it on the mean shape gives triangles that are reasonable in both images when the two shapes are not too different.

(Ties and Co-circular Points) With four or more points on one circle, the DT is not unique.

The four corners of a rectangle lie on one circle, and both diagonals give the same angle vector. Libraries then break the tie in an implementation-defined way. Near-ties also occur on regular grids of points. Recomputing the triangulation for every frame of a morph can therefore switch diagonals between frames and make triangles pop. Computing it once and reusing the index triples avoids this.

Examples

(Easy) Choosing a Diagonal

Four landmarks form the parallelogram , , , , as in the first figure.

(Medium) Sizing a Face-Morph Mesh

A face morph uses landmarks inside a photo. To cover the background, the four image corners and the four edge midpoints are added as fixed points. No landmark lies on the photo border.

See Also