Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay...

42
Voronoi diagrams and Delaunay triangulations Lecture 9, CS 4235 12 march 2004 Antoine Vigneron [email protected] National University of Singapore NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.1/42

Transcript of Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay...

Page 1: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Voronoi diagrams and Delaunaytriangulations

Lecture 9, CS 423512 march 2004

Antoine Vigneron

[email protected]

National University of Singapore

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.1/42

Page 2: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Outline

• today: geometry, no algorithm• two problems

• proximity, mesh generation• surprisingly, they are closely related

• geometric notions• Voronoi diagram, Delaunay triangulation• planar graph duality

• references• D. Mount Lecture 16 (except algorithm) and 17• textbook chapter 7 (online!) and 9• demo (J. Snoeyink) at:

http://www.cs.ubc.ca/spider/snoeyink/demos/crust/home.html

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.2/42

Page 3: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Voronoi diagrams

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.3/42

Page 4: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

A Voronoi diagram

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.4/42

Page 5: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Proximity

• what is it?• a dataset S of n points (called sites) in IR2

• let S = s1, s2 . . . sn

• query point q, find closest site to q (=proximity queries)

closestsite

S

q

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.5/42

Page 6: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Problem

• how to address proximity?• draw a diagram• example with |S| = 2:

Closer to s2

s2

Closer to s1

Bisector of s1s2

s1

• this is the Voronoi diagram of S = s1, s2NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.6/42

Page 7: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Example with |S| = 3

• Voronoi diagram of S = s1, s2, s3

s3

v

s2

V(s1)

s1

V(s3)

V(s2)

• v: a Voronoi vertex . Center of the circumcircle oftriangle s1s2s3

• V(si): Voronoi cell of siNUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.7/42

Page 8: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Example

si

V(si)

• V(si) = x ∈ IR2 | ∀j 6= i, |six| < |sjx|

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.8/42

Page 9: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Half–plane h(si, sj)

• we denote

h(si, sj) =

x ∈ IR2

∣|six| < |sjx|

sj

Bisector of s1s2

si

h(si, sj)

(Closer to si )

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.9/42

Page 10: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Voronoi cell

• it follows thatV(si) =

j 6=i

h(si, sj)

si

V(si)

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.10/42

Page 11: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Properties

• the Voronoi diagram of S is not a planar straight linegraph• reason: it has infinite edges• to fix this problem, we can restrict our attention to the

portion of the Voronoi diagram that is within a largebounding box

• all the cells are convex, hence connected• so the Voronoi diagram has n faces, one for each site• it has O(n) edges and vertices

• non trivial; we can use the fact that vertices havedegree at least 3+double counting+Euler’s relation

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.11/42

Page 12: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Algorithmic consequences

• V(si) is an intersection of n half–planes• so it can be computed in O(n log n) time (cf linear

programming)

• we can compute the Voronoi diagram of S in O(n2 log n)time

• we associate it with a point location data structure• so we can answer proximity queries in:

• O(n2 log n) preprocessing time• expected O(n) space usage• expected O(log n) query time

• next lecture: preprocessing time down to expectedΘ(n log n)

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.12/42

Page 13: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Voronoi cell 2

• ∀x ∈ V(si) the disk through si centered at x contains noother site than si

si

V(si)

x

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.13/42

Page 14: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Voronoi edges

• a Voronoi edge is an edge of the Voronoi diagram• a point x on a Voronoi edge is equidistant to two

nearest sites si and sj

• hence the circle centered at x through si and sj

contains no site in its interior

x

a voronoi edge

sjsi

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.14/42

Page 15: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

General position assumption

• general position assumption:• no four sites are cocircular

• a degenerate case: 4 sites lie on the same circle

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.15/42

Page 16: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Voronoi vertices

• a Voronoi vertex v is equidistant to three nearest sitessi, sj and sk

• hence the circle centered at v through si, sj and sk

contains no site in its interior

sjsi

sk

v

• by our general position assumption, each Voronoivertex has degree 3 (= adjacent to three edges)

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.16/42

Page 17: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Voronoi cells

• if V(si) is bounded, then it is a convex polygon• V(si) is unbounded iff si is a vertex of CH(S)

CH(S)

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.17/42

Page 18: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Consequence

• knowing the Voronoi diagram, we can compute theconvex hull in O(n) time

• so computing a Voronoi diagram takes Ω(n log n) time• next lecture: an optimal O(n log n) time randomized

algorithm• there is also a deterministic O(n log n) time algorithm

• plane–sweep algorithm• see Lecture 16 of D. Mount or Lecture 7 in textbook• you do not need to read it for CS4235

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.18/42

Page 19: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Further remarks

• sites need not be points: one can define in the sameway the Voronoi diagram of a set of line segments, orany shape

• we can also use different distance functions• the Voronoi diagram can also be defined in IRd for any d

• but it has size Θ(

ndd/2e)

• so it is only useful when d is small (say, at most 4)• active research line: approximate Voronoi diagrams

with smaller size

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.19/42

Page 20: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Dual of a planar graph

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.20/42

Page 21: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Example

G

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.21/42

Page 22: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Example

G

G∗

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.22/42

Page 23: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Definition

• let G be a graph• dual graph G∗

• each face f of G corresponds to a vertex f ∗ of G∗

• (f∗, g∗) is an edge of G∗ iff f and g are adjacent in G

• property: the dual of a planar graph is planar too• What is the dual of a Voronoi diagram?

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.23/42

Page 24: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Delaunay triangulation

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.24/42

Page 25: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Triangulation of a set of points

• we are given a set S of n points in IR2

• we want to find a planar map with set of vertices S,where CH(S) is partitioned into triangles

• this is called a triangulation of S

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.25/42

Page 26: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

The Delaunay triangulation

DT (S)

• the Delaunay triangulation of the same set• looks nicer• has many interesting properties

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.26/42

Page 27: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Definition

DT (S)

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.27/42

Page 28: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Definition

• let S be a set of n points in IR2

• S is in general position: no 4 points are cocircular• the Delaunay triangulation DT (S) of S is the embedding

of the dual graph of the Voronoi diagram of S where• the vertices are the sites: ∀i, V(si)

∗ = si

• the edges of DT (S) are straight line segments

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.28/42

Page 29: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Remarks

• DT (S): is it well defined?• we need to prove that

• edges do not intersect (= it is a PSLG)• left as an exercise

• faces are triangles• the number of edges in a face of DT (S) is the

degree of the corresponding Voronoi vertex• general position assumption implies that Voronoi

vertices have degree 3

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.29/42

Page 30: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Convex hull

• the convex hull of S is the complement of theunbounded face of DT (S)

CH(S)

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.30/42

Page 31: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Circumcircle property

• the circumcircle of any triangle in DT (S) is empty(contains no site in its interior)

DT (S)

v

s1

s3

s2

• proof: let s1s2s3 be a triangle in DT (S), let v be thecorresponding Voronoi vertex. Property of Voronoivertices: the circle centered at v through s1s2s3 is empty

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.31/42

Page 32: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Empty circle property

• sisj is an edge of DT (S) iff there is an empty circlethrough si and sj

DT (S)

si

sj

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.32/42

Page 33: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Proof (Empty circle property)

DT (S)

si

sj

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.33/42

Page 34: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Closest pair property

• the closest two sites sisj are connected by an edge ofDT (S)

DT (S)

si

sj

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.34/42

Page 35: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Proof (closest pair property)

si sj

empty

empty

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.35/42

Page 36: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Euclidean minimum spanning tree

• Euclidean graph• set of vertices= S• for all i 6= j there is an edge between si and sj with

weight |sisj |

• Euclidean Minimum Spanning Tree: minimum spanningtree of the euclidean graph

• Property: the EMST is a subgraph of DT (S)

• Corollary: it can be computed in O(n log n) time• see D. Mount’s notes pages 75–76

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.36/42

Page 37: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Angle sequence

• let T be a triangulation of S

• angle sequence Θ(T ): sequence of all the angles of thetriangle of T in non–decreasing order

• example

π/4

π/4π/2 π/3

π/3

π/3

• Θ(T ) = (π/4, π/4, π/3, π/3, π/3, π/2)

• comparison: let T and T ′ be two triangulations of S

• we compare Θ(T ) and Θ(T ′) using lexicographic order• example: (1, 1, 3, 4, 5) < (1, 2, 4, 4, 4)

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.37/42

Page 38: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Optimality of DT (S)

• Theorem: the angle sequence of DT (S) is maximalamong all triangulations of S

• in other words: the Delaunay triangulation maximizesthe minimum angle

• intuition: avoids skinny trianglesDT (P )

skinny triangle

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.38/42

Page 39: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Proof

• idea:• flip edges to ensure the circumcircle property• it decreases the angle sequence

edge flip

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.39/42

Page 40: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Degenerate cases

• several possible Delaunay triangulations• equally good in terms of angle sequence

• example:

• two possibilities

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.40/42

Page 41: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Applications

• generating good mesheshttp://www.cs.berkeley.edu/˜jrs/mesh/• skinny triangles are bad in numerical analysis

• statistics: natural neighbor interpolation• textbook example: height interpolation• shape reconstruction• . . .

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.41/42

Page 42: Voronoi diagrams and Delaunay triangulationstantc/ioi_training/CG/l9cs4235.pdf · the Delaunay triangulation DT (S) of S is the embedding of the dual graph of the Voronoi diagram

Conclusion

• next lecture: an O(n log n) time RIC of the Delaunaytriangulation

• from the Delaunay triangulation, we can obtain theVoronoi diagram in O(n) time (how?)

• the converse is also true, so these two problems areequivalent in an algorithmic point of view

• there are O(n log n) time deterministic algorithms• divide and conquer• plane sweep (D. Mount lecture 16)• reduction to 3D convex hull (D. Mount lecture 28)• not presented in CS 4235• in practice, RIC is used

NUS – CS4235 – Lecture 9: Voronoi diagrams and Delaunay triangulations – p.42/42