Delaunay triangulation - CSE-IITM

Computational Geometry
Delaunay Triangulation
John Augustine
Delaunay Triangulation
Triangulation of a Planar Point Set
A triangulation of P is planar subdivision of the plane
in which (i) end points of line segments are in P and
(ii) no line segment (connecting points in P ) can be
added without destroying planarity.
→ Bounded faces are triangles — hence triangulation.
→ Convex hull edges always included.
Theorem 1. Let P have n points (not all collinear)
and k points on the convex hull.
• Number of triangular faces m is 2n − 2 − k.
• Number of edges is 3n − 3 − k.
Proof Idea. Total # of faces is m + 1 where 1 is
unbounded and others are triangles. The total number
of edges is 3m+k
(why?) . Results follow by applying
2
Euler’s formula.
Delaunay Triangulation
1
How do we compare the skinniness triangulations?
Define angle-vector A(T ) of a triangulation T as vector
of angles sorted in non-decreasing order.
We use lexicographic comparison on the angle vectors
to compare skinniness of triangulations.
More precisely, let A(T ) = {α1, α2, . . .} and A(T 0) =
{α10 , α20 , . . .}. We say that A(T ) > A(T 0) if for some
i,
∀j < i, αj = αj0 and αi > αi0 .
We say that a triangulation T is angle-optimal if 6 ∃ T 0
such that A(T 0) > A(T ).
Delaunay Triangulation
2
Flipping an Illegal Edge
Let e be a non-boundary edge between two triangles
that form a convex quadrilateral. This edge can be
“flipped” to e0. If this flip locally improves the angle
vector, then we call e illegal.
pl
α2
pi
α1
α4
pl
α3
α5
α6
pj
edge flip
α20
pi
pk
α10
α40
α30
α60
pj
α50
pk
Observation 2. If e is an illegal edge in T and T 0 is
obtained by flipping e, then,
A(T 0) > A(T ).
Delaunay Triangulation
3
How to check if an edge is illegal?
pl
pj
pi
pk
illegal
Lemma 3. In the above figure, if pl is inside circle
through pi, pk , and pj , then the edge (as indicated)
is illegal. (This follows from Thales’ Theorem.)
Theorem 4 (Thales’ Theorem). In Figure ??,
∠arb
s
p
>
∠apb
=
∠aqb
>
∠asb.
q
r
b
`
a
C
Figure 1: Figure for Thales’ Theorem.
Delaunay Triangulation
4
Legal Triangulation
A legal triangulation does not contain any illegal edge.
Recall Observation ??.
⇒ A repeated flipping of illegal edges will terminate
make eventually make the triangulation legal.
Observation 5. Every angle-optimal triangulation is
a legal triangulation.
Is the converse true?
See http://www.cs.technion.ac.il/~barequet/
teaching/cg/misc/DT-deg-pos.pdf for more details.
Delaunay Triangulation
5
Towards Delaunay Graph
Consider a set P of points/sites in the plane. Let
Vor(P ) be its Voronoi diagram. Each site p has a cell
V(p) associated with it.
The dual graph of VorP in which the vertices are the
sites and two sites pi and pj are connected iff their
cells V(pi) and V(pj ) share an edge in Vor(P ).
G
Vor(P)
Delaunay Triangulation
6
Delaunay Graph
A straight line embedding of the dual graph on the
set P of points is called the Delaunay Graph (denoted
DG(P )).
Theorem 6. The Delaunay graph is a plane graph.
Delaunay Triangulation
7
Proof of Theorem ??
Proof. Recall that the perpendicular bisector between
two sites appears in Vor(P ) iff ∃ a circle touching the
sites but not enclosing any other site.
In other words, pipj is in DG(P ) iff ∃ closed disc Cij
with pi and pj on the boundary and no other site is
contained in it.
Let tij be the triangle formed by pi, pj , and center of
(some) Cij .
contained in V(pi )
pi
Ci j
pj
contained in V(p j )
Note that edge of tij between pi and center of Cij is
inside V(pi).
Delaunay Triangulation
8
Suppose there is another edge pk pl also in DG(P ) such
that pipj and pk pl intersect.
(As defined for pipj , define Ckl and tkl for pk pl.)
If pk pl intersected pipj , it must also intersect one other
edge e of tij . Why? (Because pk and pl are outside
Cij and therefore outside tij .
Likewise an edge e0 of tkl must intersect pipj .
Notice that this implies that one of the edges of tij
incident to center of Cij and one of the edges of tkl
incident to center of Ckl must intersect.
But, those edges must be contained within their
respective Voronoi cells, which is a contradiction.
Delaunay Triangulation
9
Delaunay Triangulation
A vertex v ∈ Vor(P ) corresponds to a face in DG(P ).
If v has degree k, then, the corresponding face is a
k-gon. Furthermore, it is a convex k-gon. Why?
f
v
A Delaunay Triangulation is a triangulation obtained
by adding edges to a delaunay graph.
Delaunay Triangulation
10
Let P be a set of points in the plane.
Theorem 7.
1. Three points form a triangle in DG(P ) iff the
circle through those three points does not enclose
any other point in P .
2. Two points form an edge in DG(P ) iff ∃ a circle
through those two points that does not enclose any
other point in P .
Theorem 8. A triangulation T is a Delaunay
triangulation iff the circumcircle of any triangle in
T does not contain any point in its interior.
Theorem 9. A triangulation T is legal iff T is a
Delaunay triangulation.
Delaunay Triangulation
11
Proof of Theorem ??
Proof. Easy to see that any Delaunay triangulation is
legal. So focus on opposite direction.
Assume for contradiction that T is a legal triangulation,
but not a Delaunay triangulation.
From Theorem ??, ∃pi, pj , pk such that circumcircle
C(pi, pj , pk ) contains point pl ∈ P in its interior.
Let e = pipj be the edge chosen so that 4pipj pl does
not intersect 4pipj pk .
pm
C(pi p j pm )
pi
pl
e
pj
pk
C(pi p j pk )
Notice that 4pipj pl cannot be a triangle in T as e
can be flipped to improve angle-optimality. Therefore,
Delaunay Triangulation
12
∃ pm 6= pl such that 4pipj pm is in T . (Note that e
cannot be a boundary edge.)
From Lemma ?? (since T is a legal triangulation), pm
is outside C(pi, pj , pj ).
Let pj pm be the edge such that 4pj pmpl does not
intersect pj pmpi. But, by Thales’ Theorem,
∠pj plpi > ∠pj pmpi,
a contradiction as it allows pj pm to be flipped.
Theorem 10.
1. Any angle optimal triangulation is a Delaunay
triangulation.
2. Any Delaunay triangulation maximizes the minimum
angle.
Delaunay Triangulation
13
A Randomized Incremental Construction
of Delaunay Triangulation
Let P = {p0, p1, . . . , pn} be a set of points in the plane
and let p0 be the highest point in P , whereas, the rest
of the points are randomly permuted.
Enclose P in 4p0p−1p−2, where p−1 and p−2 are
dummy points. 4p0p−1p−2 must be large enough so
that p−1 and p−2 don’t lie in any circle defined by
three points in P .
p−2
p0
p−1
We start with 4p0p−1p−2 as the current triangulation
and incrementally add points taken from a random
permutation {p1, p2, . . . , pn} of the remaining points.
Delaunay Triangulation
14
Two Cases
pr lies in the interior of a triangle
pr falls on an edge
pi
pk
pl
pr
pr
pi
pj
pk
pj
In either case, illegal edges can be introduced, so we
legalize them by testing each potentially illegal edge
and flipping illegal edges.
=⇒
pr
Note that all edges created are incident to the newly
inserted point pr .
Delaunay Triangulation
15
Pseudocode
Algorithm D ELAUNAY T RIANGULATION(P)
Input. A set P of n + 1 points in the plane.
Output. A Delaunay triangulation of P.
1. Let p0 be the lexicographically highest point of P, that is, the rightmost among the points
with largest y-coordinate.
2. Let p−1 and p−2 be two points in R2 sufficiently far away and such that P is contained in
the triangle p0 p−1 p−2 .
3. Initialize T as the triangulation consisting of the single triangle p0 p−1 p−2 .
4. Compute a random permutation p1 , p2 , . . . , pn of P \ {p0 }.
5. for r ← 1 to n
6.
do (∗ Insert pr into T: ∗)
7.
Find a triangle pi p j pk ∈ T containing pr .
8.
if pr lies in the interior of the triangle pi p j pk
9.
then Add edges from pr to the three vertices of pi p j pk , thereby splitting pi p j pk
into three triangles.
10.
L EGALIZE E DGE(pr , pi p j , T)
11.
L EGALIZE E DGE(pr , p j pk , T)
12.
L EGALIZE E DGE(pr , pk pi , T)
13.
else (∗ pr lies on an edge of pi p j pk , say the edge pi p j ∗)
14.
Add edges from pr to pk and to the third vertex pl of the other triangle that
is incident to pi p j , thereby splitting the two triangles incident to pi p j into
four triangles.
15.
L EGALIZE E DGE(pr , pi pl , T)
16.
L EGALIZE E DGE(pr , pl p j , T)
17.
L EGALIZE E DGE(pr , p j pk , T)
18.
L EGALIZE E DGE(pr , pk pi , T)
19. Discard p−1 and p−2 with all their incident edges from T.
20. return T
Delaunay Triangulation
16
In line 7 of the pseudocode in the previous page, we
perform a point location.
We use a DAG D similar to the DAG used in point
location in planar subdivision.
Each node in D corresponds to a 4 that was created
at some point.
Searching for a point pr would entail going down the
DAG D through a sequence of nodes corresponding
to all triangles created before step r (and possibly
destroyed) that contain pr .
Delaunay Triangulation
17
∆1
∆1
∆3
∆2
∆2
∆3
split ∆1
pj
pr
∆1
∆2
∆3
∆1
∆2
∆3
∆2
pi
∆3
flip pi p j
pi
∆5
∆4
∆3
pk
∆4
∆5
flip pi pk
∆1
∆2
∆3
∆4
∆7
∆6
∆4
∆5
∆6
Delaunay Triangulation
∆7
18
L EGALIZE E DGE(pr , pi p j , T)
1. (∗ The point being inserted is pr , and pi p j is the edge of T that may need to be flipped. ∗)
2. if pi p j is illegal
3.
then Let pi p j pk be the triangle adjacent to pr pi p j along pi p j .
4.
(∗ Flip pi p j : ∗) Replace pi p j with pr pk .
5.
L EGALIZE E DGE(pr , pi pk , T)
6.
L EGALIZE E DGE(pr , pk p j , T)
pj
pk
pr
pi
To show correctness, recall that every new edge
added after the insertion of a point pr is incident to
pr .
The part that gets changed is limited to triangles with
two edges incident to pr . Therefore, the correctness of
the algorithm follows from the following lemma.
Delaunay Triangulation
19
Lemma 11. Every new edge created when pr is added
is a Delaunay edge of {p−2, p−1, p0, p1, . . . , pr }.
Proof Sketch.
pl
pj
pr
C
C0
pi
4pj pipl is a Delaunay triangle of {p−2, p−1, p0, p1, . . . , pr−1}
Therefore ∃ a circle C through pj pipl devoid of
points in {p−2, p−1, p0, p1, . . . , pr−1}. Shrink C until
it touches only pr and pl — this can be done — thus
proving that pr pl is a Delaunay Edge.
Delaunay Triangulation
20
Analysis
Lemma 12. Expected number of triangle created by
the algorithm is 9n + 1.
Proof. Recall what happens when we insert pr . First,
one of the following two cases, and subsequently, we
repeatedly legalize edges (until none are left).
pr lies in the interior of a triangle
pr falls on an edge
pi
pk
pl
pr
pr
pi
pj
pk
pj
First, three (or four) triangles are formed.
Subsequently, each edge we “legalize” will add 2
triangles.
Therefore, if k is the number of edges incident to
pr then, ≤ 2(k − 3) + 3 = 2k -3 new triangles are
formed.
Delaunay Triangulation
21
When pr is added, the
k , which is the expected
degree of pr is 6. This follows from
• 6r being the total degree, which in turn follows from
• the bound on the number of edges in the Delaunay
Graph,
• which equals the number of Voronoi edges.
E[# of 4s created in step r] ≤ E[2k − 3]
(1)
= 2 × 6 − 3 = 9. (2)
Using linearity of expectation over all iterations, the
expected number of triangles added is 9n + 1, where
the extra triangle is 4p0p−1p−2.
Delaunay Triangulation
22
Theorem 13. The Randomized Incremental Algorithm
for the Delaunay Triangulation of n points takes
O(n log n) time and O(n) space, both on expectation.
Proof Sketch. Space follows from nodes in D
representing triangles created, which is 9n + 1 on
expectation.
Not counting point location, the creation of each
triangle takes O(1) time, so the total time will be
O(n) + time for point locations (on expectation).
Recall: Searching for a point pr would entail going
down the DAG D through a sequence of nodes
corresponding to all triangles created before step r
(and possibly destroyed) that contain pr .
So each triangle that was created is visited once for
each point in it. In other words, . . .
Let K(∆) ⊆ P be the points inside triangle ∆. Time
Delaunay Triangulation
23
for point locations is
X
K(∆).
∆
Roughly speaking, each triangle created in round r has
O(n/r) points of P in it. Therefore,
X
∆
K(∆) ≤
X
O(n/r)
r
∈ O(n log n),
Delaunay Triangulation
24