cs633 lecture 09 voronoi diagram - george mason...

85
1 CS633 Lecture 0 9 Voronoi Diagram Jyh-Ming Lien Department of Computer Science George Mason University Based on Allen Miu’s lecture notes

Upload: others

Post on 25-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

1

CS633 Lecture 09Voronoi Diagram

Jyh-Ming Lien

Department of Computer ScienceGeorge Mason University

Based on Allen Miu’s lecture notes

Page 2: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

2

Independently Rediscovered Many Times

It is a fundamental concept

Descartes Astronomy 1644 “Heavens”Dirichlet Math 1850 Dirichlet tesselationVoronoi Math 1908 Voronoi diagramBoldyrev Geology 1909 area of influen polygonsThiessen Meteorology 1911 Theissen polygonsNiggli Crystallography 1927 domains of actionWigner & Seitz Physics 1933 Wigner-Seitz regionsFrank & Casper Physics 1958 atom domainsBrown Ecology 1965 areas potentially availableMead Ecology 1966 plant polygonsHoofd et al. Anatomy 1985 capillary domainsIcke Astronomy 1987 Voronoi diagram

Kenneth E. Hoff III, Tim Culver, John Keyser, Ming Lin, and Dinesh Manocha, 99

Page 3: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

3

Fun Stuff

• Paul Chew’s Jave applet– http://www.cs.cornell.edu/Info/People/chew/Delaunay.html

• Simon Barber’s flash– http://www.quasimondo.com/archives/voronoi1.html

• FLIGHT404’s Blog– http://www.flight404.com/blog/?p=82

• Scott Snibbe’s Blog– http://www.snibbe.com/scott/bf/index.htm

Soap Bubbles dragonfly's wing

Page 4: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

4

Post Office: What is the area of service?

e

e : Voronoi edge

v

v : Voronoi vertex

pi

pi : site

Page 5: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

5

Definition of Voronoi Diagram

• Let P be a set of n distinct points (sites) in the plane.

• The Voronoi diagram of P is the subdivision of the plane into n cells, one for each site.

• A point q lies in the cell corresponding to a site pi ∈ P iff Euclidean_Distance( q, pi ) < Euclidean_distance( q, pj ), for each pi ∈ P, j ≠ i.

Page 6: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

6

1 site

Page 7: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

7

Two sites

Voronoi Diagram is a linethat extends infinitely in both directions, and thetwo half planes on eitherside.

Page 8: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

8

Collinear sites

Page 9: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

9

Non-collinear sites

A Voronoi vertex is the center of an empty circle touching 3 or more sites.

v

Half lines

A vertex hasdegree ≥ 3

Page 10: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

10

Voronoi Cells and Segments

v

Page 11: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

11

Voronoi Cells and Segments

v

Unbounded CellBounded Cell

Segment

Page 12: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

12

Who wants to be a Millionaire?

vWhich of the following is true for2-D Voronoi diagrams?

Four or more non-collinear sites are…1. sufficient to create a bounded cell2. necessary to create a bounded cell3. 1 and 24. none of above

Page 13: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

13

Who wants to be a Millionaire?

vWhich of the following is true for2-D Voronoi diagrams?

Four or more non-collinear sites are…1. sufficient to create a bounded cell2. necessary to create a bounded cell3. 1 and 24. none of above

Page 14: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

14

Degenerate Case: no bounded cells!

v

Page 15: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

15

Summary of Voronoi Properties A point q lies on a Voronoi edge between sites pi

and pj iff the largest empty circle centered at q touches only pi and pj

– A Voronoi edge is a subset of locus of points equidistant from pi and pj

e

e : Voronoi edge

v

v : Voronoi vertex

pi

pi : site points

Page 16: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

16

Summary of Voronoi Properties A point q is a vertex iff the largest empty circle

centered at q touches at least 3 sites– A Voronoi vertex is an intersection of 3 more

segments, each equidistant from a pair of sites

e

e : Voronoi edge

v

v : Voronoi vertex

pi

pi : site points

Page 17: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

17

Outline

• Definitions and Examples• Properties of Voronoi diagrams• Complexity of Voronoi diagrams• Constructing Voronoi diagrams

– Intuitions– Data Structures– Algorithm

• Running Time Analysis• Duality and degenerate cases

Page 18: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

18

Linear complexity {|v|, |e| = O(n)}

Intuition: Not all bisectors are Voronoi edges!

e

e : Voronoi edge

pi

pi : site points

Page 19: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

19

Linear complexity {|v|, |e| = O(n)}

Claim: For n ≥ 3, |v| ≤ 2n − 5 and |e| ≤ 3n − 6Proof: (Easy Case)

Collinear sites: |v| = 0, |e| = n – 1

Page 20: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

20

Linear complexity {|v|, |e| = O(n)}

Claim: For n ≥ 3, |v| ≤ 2n − 5 and |e| ≤ 3n − 6Proof: (General Case)

• Euler’s Formula: for connected, planar graphs,|v| – |e| + f = 2

Where:

|v| is the number of vertices

|e| is the number of edges

f is the number of faces

Page 21: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

21

Linear complexity {|v|, |e| = O(n)}

Claim: For n ≥ 3, |v| ≤ 2n − 5 and |e| ≤ 3n − 6

Proof: (General Case)• For Voronoi graphs, f = n ⇒ (|v| +1) – |e| + n = 2

epi

p∞

To apply Euler’s Formula, we“planarize” the Voronoi diagram by connecting half lines to an extra vertex.

Page 22: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

22

Linear complexity {|v|, |e| = O(n)}

Page 23: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

23

Outline

• Definitions and Examples• Properties of Voronoi diagrams• Complexity of Voronoi diagrams• Constructing Voronoi diagrams

– Intuitions– Data Structures– Algorithm

• Running Time Analysis• Duality and degenerate cases

Page 24: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

24

Constructing Voronoi Diagrams

Brute force algorithm– a half plane intersection…

Page 25: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

25

Constructing Voronoi Diagrams

Brute force algorithm– a half plane intersection…

Page 26: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

26

Constructing Voronoi Diagrams

Brute force algorithm– a half plane intersection…

Page 27: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

27

Constructing Voronoi Diagrams

Brute force algorithm– a half plane intersection…

Repeat for each site

Running Time: O( n2 log n )

Page 28: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

28

Constructing Voronoi Diagrams

• We should be able to do better– the linear complexity of Voronoi diagram

• Fortune’s Algorithm ‘87– Sweep line algorithm

• Voronoi diagram constructed as horizontal line sweeps the set of sites from top to bottom

• Maintains portion of diagram which cannot change due to sites below sweep line, keeping track of incremental changes for each site (and Voronoi vertex) it “sweeps”

Page 29: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

29

Constructing Voronoi Diagrams

What is the invariant we are looking for?

Maintain a representation of the locus of points q that are closer to some site pi above the sweep line than to

the line itself (and thus to any site below the line).

ev

pi

Sweep Line

Page 30: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

30

Constructing Voronoi DiagramsWhich points are closer to a site above the sweep line

Sweep Line

pi

The set of parabolic arcs form a beach-line that bounds the locus of all such points

Equidistance

Page 31: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

31

Constructing Voronoi DiagramsBreak points trace out Voronoi edges.

Equidistance

Sweep Line

pi

Break point

Beach line

Page 32: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

32

Constructing Voronoi DiagramsArcs flatten out as sweep line moves down.

Sweep Line

pi

Page 33: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

33

Eventually, the middle arc disappears.Constructing Voronoi Diagrams

Sweep Line

pi

q

Page 34: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

34

We have detected a circle that is empty (contains no sites)

Constructing Voronoi Diagrams

Sweep Line

pi

q

Voronoi vertex!

Page 35: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

35

Beach Line properties

• voronoi edge = break point trajectory– Emergence of a new break point(s) (from formation of a new arc or

a fusion of two existing break points) identifies a new edge

• voronoi vertices = collision of break points = disappeared parabolic curve – Decimation of an old arc identifies new vertex

Page 36: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

36

Break

• 10 Minutes

Page 37: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

37

Demo

• A visual implementation of Fortune's Voronoi algorithm– by Allan Odgaard & Benny Kjær Nielsen– Source code is available

– http://www.diku.dk/hjemmesider/studerende/duff/Fortune/

“It is notoriously difficult to obtain a practical implementation of an abstractly described geometric algorithm” – Steven Fortune

Page 38: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

38

Data Structures

• Current state of the Voronoi diagram– Doubly linked list of half-edge, vertex, cell records

• Current state of the sweep line– Keep track of break points

– Keep track of arcs currently on beach line

• Priority event queue

Page 39: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

39

Doubly Linked List (D)• Divide segments into uni-directional half-edges• A chain of counter-clockwise half-edges forms a cell• Define a half-edge’s “twin” to be its opposite half-edge of the same

segment

ev

Cell(pi)

Page 40: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

40

Balanced Binary Tree (T)• Internal nodes represent break points between two arcs

– Also contains a pointer to the D record of the edge being traced

• Leaf nodes represent arcs, each arc is in turn represented by the site that generated it– Also contains a pointer to a potential circle event

pi pj pk pl

< pj, pk>

< pi, pj> < pk, pl>

pi

pjpk

pl

l

Not stored

Page 41: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

41

Event Queue (Q)

• An event is an interesting point encountered by the sweep line as it sweeps from top to bottom– Sweep line makes discrete stops, rather than a continuous

sweep

– Site Events (when the sweep line encounters a new site point)

– Circle Events (when the sweep line encounters the bottom of an empty circle touching 3 or more sites).

• Events are prioritized based on y-coordinate

Page 42: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

42

Site Event

A new arc appears when a new site appears.

l

Page 43: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

43

Site Event

A new arc appears when a new site appears.

l

Page 44: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

44

Site Event

Original arc above the new site is broken into two Number of arcs on beach line is O(n)

l

Page 45: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

45

Circle Event

An arc disappears whenever an empty circle touches three or more sites and is tangent to the sweep line.

Sweep line helps determine that the circle is indeed empty.

Circle Event!Sweep Line

pi

q

Voronoi vertex!

Page 46: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

46

Event Queue Summary

• Site Events are – given as input– represented by the xy-coordinate of the site point

• Circle Events are– computed on the fly (intersection of the two

bisectors in between the three sites)– represented by the xy-coordinate of the lowest point

of an empty circle touching three or more sites– “anticipated”, these newly generated events may be

false and need to be removed later

Page 47: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

47

Algorithm

1. Initialize • Event queue Q ⇐ all site events

• Binary search tree T ⇐ ∅

• Doubly linked list D ⇐ ∅

2. While Q not ∅,• Remove event (e) from Q with largest y-

coordinate• HandleEvent(e, T, D)

Page 48: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

48

Handling Site Events

1. Update T: – Locate the existing arc (if any) that is above the new site– Break the arc by replacing the leaf node with a sub tree

representing the new arc and its break points

2. Update D: – Add two half-edge records in the doubly linked list

3. Update Q: – Check for potential circle event(s), add them to event queue

Page 49: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

49

Locate the existing arc that is above the new site

pi pj pk pl

< pj, pk>

< pi, pj> < pk, pl>

• The x coordinate of the new site is used for the binary search• The x coordinate of each breakpoint along the root to leaf path is computed on the fly

pi

pjpk

pl

lpm

Page 50: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

50

Break the Arc

pi pj pk

< pj, pk>

< pi, pj> < pk, pl>

Corresponding leaf replaced by a new sub-tree

pi

pjpk

pl

lpm

pm pl

< pl, pm>

< pm, pl>

plDifferent arcs can be identified by the same site!

Page 51: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

51

Add a new edge record in the doubly linked list

pi pj pk

< pj, pk>

< pi, pj> < pk, pl>

pm pl

< pl, pm>

< pm, pl>

pl

pi

pjpk

pl

lpm

New Half Edge RecordEndpoints ∅

Pointers to two half-edge records

lpm

Page 52: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

52

Checking for Potential Circle Events• Scan for 3 consecutive arcs and

determine if breakpoints converge– Triples with new arc in the middle do not

have break points that converge

Page 53: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

53

Checking for Potential Circle Events• Scan for 3 consecutive arcs and

determine if breakpoints converge– Triples with new arc in the middle do not

have break points that converge

Page 54: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

54

Checking for Potential Circle Events• Scan for 3 consecutive arcs and

determine if breakpoints converge– Triples with new arc in the middle do not

have break points that converge

Page 55: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

55

Converging break points may not always yield a circle event

• Appearance of a new site before the circle event makes the potential circle non-empty

l

(The original circle event becomes a false alarm)

Page 56: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

56

Handling Site Events1. Update T:

– Locate the leaf representing the existing arc that is above the new site

• Delete the potential circle event in the event queue– Break the arc by replacing the leaf node with a sub tree

representing the new arc and break points

2. Update D: – Add a new edge record in the doubly linked list

3. Update Q: – Check for potential circle event(s), add them to queue if they

exist• Store in the corresponding leaf of T a pointer to the new circle

event in the queue

Page 57: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

57

Handling Circle Events

1. Update T: • Delete from T the leaf node of the disappearing arc

and its associated circle events in the event queue

2. Update D: • Add vertex to corresponding edge record in doubly

linked list• Create new edge record in doubly linked list

3. Update Q: • Check the new triplets formed by the former

neighboring arcs for potential circle events

Page 58: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

58

A Circle Event

pi pj pk

< pj, pk>

< pi, pj> < pk, pl>

pi

pj

pkpl

lpm

pm pl

< pl, pm>

< pm, pl>

pl

Page 59: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

59

Add vertex to corresponding edge record

pi pj pk

< pj, pk>

< pi, pj> < pk, pl>

pi

pj

pkpl

lpm

pm pl

< pl, pm>

< pm, pl>

pl

Half Edge RecordEndpoints.add(x, y)

Half Edge RecordEndpoints.add(x, y)

Link!

Page 60: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

60

Deleting disappearing arc

pi pj pk

< pj, pk>

< pi, pj>

pi

pj

pkpl

lpm

pm pl

< pm, pl>

Page 61: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

61

Deleting disappearing arc

pi pj pk

< pj, pk>

< pi, pj>

pi

pj

pkpl

lpmpm pl

< pm, pl>

< pk, pm>

Page 62: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

62

Create new edge record

pi pj pk

< pj, pk>

< pi, pj>

pi

pj

pkpl

lpmpm pl

< pm, pl>

< pk, pm>

New Half Edge RecordEndpoints.add(x, y)

A new edge is traced out by the new break point < pk, pm>

Page 63: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

63

Check the new triplets for potential circle events

pi pj pk

< pj, pk>

< pi, pj>

pi

pj

pkpl

lpmpm pl

< pm, pl>

< pk, pm>

Q y…new circle event

Page 64: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

64

Minor Detail

• Algorithm terminates when Q = ∅, but the beach line and its break points continue to trace the Voronoi edges– Terminate these “half-infinite” edges via a

bounding box

Page 65: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

65

Algorithm Termination

pi pj pk

< pj, pk>

< pi, pj>

pi

pj

pkpl

l

pmpm pl

< pm, pl>

< pk, pm>

Q ∅

Page 66: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

66

Algorithm Termination

pi pj

< pj, pm>

< pi, pj>

pi

pj

pkpl

l

pm

pm pl

< pm, pl>

Q ∅

Page 67: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

67

Algorithm Termination

pi pj

< pj, pm>

< pi, pj>

pi

pj

pkpl

l

pm

pm pl

< pm, pl>

Q ∅

Terminate half-lines with a bounding box!

Page 68: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

68

Outline

• Definitions and Examples• Properties of Voronoi diagrams• Complexity of Voronoi diagrams• Constructing Voronoi diagrams

– Intuitions– Data Structures– Algorithm

• Running Time Analysis• Demo• Duality and degenerate cases

Page 69: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

69

Handling Site Events

1. Locate the leaf representing the existing arc that is above the new site

– Delete the potential circle event in the event queue

2. Break the arc by replacing the leaf node with a sub tree representing the new arc and break points

3. Add a new edge record in the link list4. Check for potential circle event(s), add

them to queue if they exist– Store in the corresponding leaf of T a pointer to

the new circle event in the queue

Running Time

O(log n)

O(1)

O(1)

O(1)

Page 70: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

70

Handling Circle Events

1. Delete from T the leaf node of the disappearing arc and its associated circle events in the event queue

2. Add vertex record in doubly link list

3. Create new edge record in doubly link list

4. Check the new triplets formed by the former neighboring arcs for potential circle events

Running Time

O(log n)

O(1)

O(1)

O(1)

Page 71: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

71

Total Running Time

• Each new site can generate at most two new arcs ⇒ beach line can have at most 2n – 1 arcs⇒ at most O(n) site and circle events in the queue

• Site/Circle Event Handler O(log n)

⇒ O(n log n) total running time

Page 72: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

72

Is Fortune’s Algorithm Optimal?• We can sort numbers using any algorithm that

constructs a Voronoi diagram!

-5 1 3 6 7

NumberLine

Page 73: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

73

Outline

• Definitions and Examples• Properties of Voronoi diagrams• Complexity of Voronoi diagrams• Constructing Voronoi diagrams

– Intuitions– Data Structures– Algorithm

• Running Time Analysis• Duality and degenerate cases

Page 74: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

74

Voronoi Diagram/Convex Hull Duality

Sites sharing a half-infinite edge are convex hull vertices

ev

pi

Page 75: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

75

Degenerate Cases

• Events in Q share the same y-coordinate– Can additionally sort them using x-

coordinate

• Circle event involving more than 3 sites– Current algorithm produces multiple degree

3 Voronoi vertices joined by zero-length edges

– Can be fixed in post processing

Page 76: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

76

Degenerate Cases

• Site points are collinear (break points neither converge or diverge)– Bounding box takes care of this

• One of the sites coincides with the lowest point of the circle event– Do nothing

Page 77: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

77

Site coincides with circle event:

1. New site detected2. Break one of the arcs an infinitesimal distance

away from the arc’s end point

Page 78: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

78

Site coincides with circle event

Page 79: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

79

Summary of Fortune’s algorithm

• Optimal• Sweep line algorithm

– Site events

– Circle events

Images from http://www.cescg.org/CESCG99/RCuk/

Page 80: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

80

Other Ways Computing Voronoi Diagram

• Divide-and-conquer

http://www.personal.kent.edu/~rmuhamma/Compgeometry/MyCG/Voronoi/DivConqVor/divConqVor.htm

Page 81: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

81

Other Ways Computing Voronoi Diagram

• Lifting: three dimensional convex hull– We will learn about this in Chapter 9

• Incremental– We will learn about this in Chapter 9, too

Page 82: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

82

Other Ways Computing Voronoi Diagram

• Using Graphics hardware (GPU)

Perspective, 3/4 view Parallel, top view

Kenneth E. Hoff III, Tim Culver, John Keyser, Ming Lin, and Dinesh Manocha, 99

Page 83: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

83

Kenneth E. Hoff III, Tim Culver, John Keyser, Ming Lin, and Dinesh Manocha, 99

Ordinary

• Point sites• Nearest Euclidean distance

Generalized• Higher-order site geometry• Varying distance metrics

Weighted Distances

Higher-orderSites

2.0

0.5

Page 84: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

84

Summary

• Voronoi diagram is a useful planar subdivision of a discrete point set

• Voronoi diagrams have linear complexity and can be constructed in O(n log n) time

Page 85: CS633 Lecture 09 Voronoi Diagram - George Mason Universityjmlien/teaching/09_fall_cs633/uploads/Main/lecture09.pdfDescartes Astronomy 1644 “Heavens” Dirichlet Math 1850 Dirichlet

85

Homework Assignment

• 7.10, 7.11