Voronoi Diagrams and Delaunay Triangulations - cs.jhu.edumisha/Spring16/11.pdfย ยท Preliminaries...

Post on 14-Aug-2019

216 views 0 download

Transcript of Voronoi Diagrams and Delaunay Triangulations - cs.jhu.edumisha/Spring16/11.pdfย ยท Preliminaries...

Voronoi Diagrams

and

Delaunay Triangulations

Oโ€™Rourke, Chapter 5

Outline

โ€ข Preliminaries

โ€ข Voronoi Diagrams / Delaunay Triangulations

โ€ข Lloydโ€™s Algorithm

Preliminaries

Claim:

Given a connected planar graph with ๐‘‰ vertices, ๐ธedges, and ๐น faces*, the graph satisfies:

๐‘‰ โˆ’ ๐ธ + ๐น = 2

*The โ€œexternalโ€ face also counts. (Can think of this as a graph on the sphere.)

Preliminaries

Proof:

1. Show that this is true for trees.

2. Show that this is true by induction.

Preliminaries

Proof (for Trees):

If a graph is a connected tree, it satisfies:

๐‘‰ = ๐ธ + 1.

Since there is only one (external) face:

๐‘‰ โˆ’ ๐ธ + ๐น = (๐ธ + 1) โˆ’ ๐ธ + 1 = 2

Preliminaries

Proof (by Induction):

Suppose that we are given a graph ๐บ. If itโ€™s a tree, we are done.

Otherwise, it has a cycle.

Removing an edge on the cycle

gives a graph ๐บโ€ฒ with: The same vertex set (๐‘‰โ€ฒ = ๐‘‰)

One less edge (๐ธโ€ฒ = ๐ธ โˆ’ 1)

One less face (๐นโ€ฒ = ๐น โˆ’ 1)

By induction:

2 = ๐‘‰โ€ฒ โˆ’ ๐ธโ€ฒ + ๐นโ€ฒ = ๐‘‰ โˆ’ ๐ธ + ๐น

Preliminaries

Note:

Given a planar graph ๐บ, we can get a planar

graph ๐บโ€ฒ with triangle faces: Triangulate the interior polygons

Add a โ€œvirtual pointโ€ outside

and triangulate the

exterior polygon.

Preliminaries

Note:

The new graph has: ๐‘‰โ€ฒ = ๐‘‰ + 1, ๐ธโ€ฒ โ‰ฅ ๐ธ, ๐นโ€ฒ โ‰ฅ ๐น

๐‘‰โ€ฒ โˆ’ ๐ธโ€ฒ + ๐นโ€ฒ = 2

3๐ธโ€ฒ = 2๐นโ€ฒ

Preliminaries

Note:

The new graph has: ๐‘‰โ€ฒ = ๐‘‰ + 1, ๐ธโ€ฒ โ‰ฅ ๐ธ, ๐นโ€ฒ โ‰ฅ ๐น

๐‘‰โ€ฒ โˆ’ ๐ธโ€ฒ + ๐นโ€ฒ = 2

3๐ธโ€ฒ = 2๐นโ€ฒ

This gives:

๐ธโ€ฒ = 3๐‘‰โ€ฒ โˆ’ 6 ๐นโ€ฒ = 2๐‘‰โ€ฒ โˆ’ 4โ‡“ โ‡“

๐ธ โ‰ค 3๐‘‰ โˆ’ 3 ๐น โ‰ค 2๐‘‰ โˆ’ 2

The number of edges/faces of a planar graph is

linear in the number of vertices.

Preliminaries

Definition:

Given a set of points {๐‘1, โ€ฆ , ๐‘๐‘›} โŠ‚ โ„๐‘‘, the nearest-

neighbor graph is the directed graph with an edge

from ๐‘๐‘– to ๐‘๐‘—, whenever:

๐‘๐‘˜ โˆ’ ๐‘๐‘– โ‰ฅ ๐‘๐‘— โˆ’ ๐‘๐‘– โˆ€1 โ‰ค ๐‘˜ โ‰ค ๐‘›.

Naively, the nearest-neighbor

can be computed in ๐‘‚(๐‘›2) time

by testing all possible neighbors.

Outline

โ€ข Preliminaries

โ€ข Voronoi Diagrams / Delaunay Triangulations

โ€ข Lloydโ€™s Algorithm

Voronoi Diagrams

Definition:

Given points ๐‘ƒ = ๐‘1, โ€ฆ , ๐‘๐‘› , the Voronoi

region of point ๐‘๐‘–, ๐‘‰(๐‘๐‘–) is the set of points at

least as close to ๐‘๐‘– as to any other point in ๐‘ƒ:

๐‘‰ ๐‘๐‘– = ๐‘ฅ ๐‘๐‘– โˆ’ ๐‘ฅ โ‰ค ๐‘๐‘— โˆ’ ๐‘ฅ โˆ€1 โ‰ค ๐‘— โ‰ค ๐‘›

Voronoi Diagrams

Definition:

The set of points with more than one nearest

neighbor in ๐‘ƒ is the Voronoi Diagram of ๐‘ƒ: The set with two nearest neighbors make up the

edges of the diagram.

The set with three or more nearest neighbors make up

the vertices of the diagram.

The points ๐‘ƒ are called the sites of

the Voronoi diagram.

Voronoi Diagrams

2 Points:

When ๐‘ƒ = ๐‘1, ๐‘2 , the regions are defined by

the perpendicular bisector:

๐‘1

๐‘2๐ป(๐‘2, ๐‘1)

๐ป(๐‘1, ๐‘2)

Voronoi Diagrams

3 Points:

When ๐‘ƒ = ๐‘1, ๐‘2, ๐‘3 , the regions are defined

by the three perpendicular bisectors:

๐‘1

๐‘2

๐‘1

๐‘2

๐‘3

Voronoi Diagrams

3 Points:

When ๐‘ƒ = ๐‘1, ๐‘2, ๐‘3 , the regions are defined

by the three perpendicular bisectors:

๐‘1

๐‘2

๐‘1

๐‘2

๐‘3

The three bisectors intersect at a point

The intersection can be outside the triangle.

The point of intersection is center of the circle

passing through the three points.

Voronoi Diagrams

More Generally:

The Voronoi region associated to point ๐‘๐‘– is

the intersection of the half-spaces defined by

the perpendicular bisectors:

๐‘‰ ๐‘๐‘– =โˆฉ๐‘—โ‰ ๐‘– ๐ป(๐‘๐‘– , ๐‘๐‘—)

๐‘๐‘–

Voronoi Diagrams

More Generally:

The Voronoi region associated to point ๐‘๐‘– is

the intersection of the half-spaces defined by

the perpendicular bisectors:

๐‘‰ ๐‘๐‘– =โˆฉ๐‘—โ‰ ๐‘– ๐ป(๐‘๐‘– , ๐‘๐‘—)

๐‘๐‘–

โ‡’ Voronoi regions are convex polygons.

Voronoi Diagrams

More Generally:

Voronoi Diagrams

More Generally:

Voronoi faces can be unbounded.

Voronoi regions are in 1-to-1 correspondence with points.

Most Voronoi vertices have valence 3.

Voronoi Diagrams

Properties: Each Voronoi region is convex.

๐‘‰ ๐‘๐‘– is unbounded โ‡” ๐‘๐‘– is on the convex hull of ๐‘ƒ.

If ๐‘ฃ is a at the junction of ๐‘‰(๐‘1),โ€ฆ, ๐‘‰(๐‘๐‘˜),with ๐‘˜ โ‰ฅ 3, then ๐‘ฃ is the center of a circle, ๐ถ(๐‘ฃ),with ๐‘1, โ€ฆ , ๐‘๐‘˜ on the boundary.

The interior of ๐ถ(๐‘ฃ) contains

no points.

Delaunay Triangulation

Definition:

The Delaunay triangulation is the straight-line

dual of the Voronoi Diagram.

Note:

The Delaunay edges donโ€™t

have to cross their Voronoi

duals.

Delaunay Triangulation

Properties: The edges of ๐ท(๐‘ƒ) donโ€™t intersect.

๐ท(๐‘ƒ) is a triangulation if no 4 points are co-circular.

The boundary of ๐ท(๐‘ƒ) is the convex hull of ๐‘ƒ.

If ๐‘๐‘— is the nearest neighbor of ๐‘๐‘–then ๐‘๐‘–๐‘๐‘— is a Delaunay edge.

There is a circle through ๐‘๐‘–and ๐‘๐‘— that does not contain

any other points

โ‡” ๐‘๐‘–๐‘๐‘— is a Delaunay edge.

The circumcircle of ๐‘๐‘–, ๐‘๐‘—,

and ๐‘๐‘˜ is empty

โ‡” ฮ”๐‘๐‘–๐‘๐‘—๐‘๐‘˜ is Delaunay triangle.

Delaunay Triangulation

Note:

Assuming that the edges of ๐ท(๐‘ƒ) do not cross, we

get a planar graph.

โ‡’ The number of edges/faces in a Delaunay

Triangulation is linear in the number of vertices.

โ‡’ The number of edges/vertices in a Voronoi

Diagram is linear in the number of faces.

โ‡’ The number of vertices/edges/faces in a Voronoi

Diagram is linear in the number of sites.

Delaunay Triangulation

Properties: The boundary of ๐ท(๐‘ƒ) is the convex hull of ๐‘ƒ.

Proof:

Suppose that ๐‘๐‘–๐‘๐‘— is an edge of the hull of ๐‘ƒ.

Consider circles with center on the

bisector that intersect ๐‘๐‘– and ๐‘๐‘—.

As we move out along the

bisector the circle converges to

the half-space to the right of ๐‘๐‘–๐‘๐‘—.๐‘๐‘–

๐‘๐‘—

Delaunay Triangulation

Properties: The boundary of ๐ท(๐‘ƒ) is the convex hull of ๐‘ƒ.

Proof:

Suppose that ๐‘๐‘–๐‘๐‘— is an edge of the hull of ๐‘ƒ.

โ‡’ There is an (infinite) region on

the bisector that is closer to ๐‘๐‘–and ๐‘๐‘— than to any other points.

โ‡’ There is a Voronoi edge

between ๐‘๐‘– and ๐‘๐‘—.

โ‡’ The dual edge is in ๐ท(๐‘ƒ).๐‘๐‘–

๐‘๐‘—

Delaunay Triangulation

Properties: If ๐‘๐‘— is the nearest neighbor of ๐‘๐‘– then ๐‘๐‘–๐‘๐‘— is a

Delaunay edge.

Proof:

๐‘๐‘— is the nearest neighbor of ๐‘๐‘– iff. the circle around ๐‘๐‘–with radius |๐‘๐‘– โˆ’ ๐‘๐‘—| is empty of other points.

โ‡’ The circle through (๐‘๐‘– + ๐‘๐‘—)/2 with radius

๐‘๐‘– โˆ’ ๐‘๐‘— /2 is empty of other points.

โ‡’ (๐‘๐‘– + ๐‘๐‘—)/2 is on the Voronoi diagram.

โ‡’ (๐‘๐‘– + ๐‘๐‘—)/2 is on a Voronoi edge.

๐‘๐‘–

๐‘๐‘—

Delaunay Triangulation

Properties: If ๐‘๐‘— is the nearest neighbor of ๐‘๐‘– then ๐‘๐‘–๐‘๐‘— is a

Delaunay edge.

Implications:

The nearest neighbor graph is a subset of the Delaunay

triangulation.

We will show that the Delaunay triangulation can be

computed in ๐‘‚(๐‘› log ๐‘› ) time.

โ‡’We can compute the nearest-neighbor graph in

๐‘‚ ๐‘› log ๐‘› .

Delaunay Triangulation

Properties: There is a circle through ๐‘๐‘– and ๐‘๐‘— that does not

contain any other points โ‡” ๐‘๐‘–๐‘๐‘— is a Delaunay edge.

Proof (โ‡):

If ๐‘๐‘–๐‘๐‘— is a Delaunay edge, then the Voronoi regions

๐‘‰(๐‘๐‘–) and ๐‘‰(๐‘๐‘—) intersect at an edge.

Set ๐‘ฃ to be some point on the interior of the edge.

๐‘ฃ โˆ’ ๐‘๐‘– = ๐‘ฃ โˆ’ ๐‘๐‘— = ๐‘Ÿ and ๐‘ฃ โˆ’ ๐‘๐‘˜ > ๐‘Ÿ โˆ€๐‘˜ โ‰  ๐‘–, ๐‘—.

The circle at ๐‘ฃ with radius ๐‘Ÿ is empty of other points.

Delaunay Triangulation

Properties: There is a circle through ๐‘๐‘– and ๐‘๐‘— that does not

contain any other points โ‡” ๐‘๐‘–๐‘๐‘— is a Delaunay edge.

Proof (โ‡’):

If there is a circle through ๐‘๐‘– and ๐‘๐‘—, empty of other

points, with center ๐‘ฅ, then ๐‘ฅ โˆˆ ๐‘‰ ๐‘๐‘– โˆฉ ๐‘‰ ๐‘๐‘— .

Since no other point is in or on the circle

there is a neighborhood of centers

around ๐‘ฅ on the bisector with circles

through ๐‘๐‘– and ๐‘๐‘— empty of other points.

๐‘ฅ is on a Voronoi edge.

๐‘ฅ

๐‘๐‘–

๐‘๐‘—

Delaunay Triangulation

Properties: The edges of ๐ท(๐‘ƒ) donโ€™t intersect.

Proof:

Given an edge ๐‘๐‘–๐‘๐‘— in ๐ท(๐‘ƒ), there is a circle with ๐‘๐‘–and ๐‘๐‘— on its boundary and empty of other points.

Let be ๐‘๐‘˜๐‘๐‘™ be an edge in ๐ท(๐‘) that intersect ๐‘๐‘–๐‘๐‘—:

๐‘๐‘˜ and ๐‘๐‘™ cannot be in the circle.

โ‡’ ๐‘๐‘˜ and ๐‘๐‘™ are not in the triangle ฮ”๐‘๐‘–๐‘—๐‘๐‘–๐‘๐‘—โ‡’ ๐‘๐‘˜๐‘๐‘™ intersects either ๐‘๐‘–๐‘—๐‘๐‘– or ๐‘๐‘–๐‘—๐‘๐‘—.

โ‡’ ๐‘๐‘–๐‘๐‘— intersects either ๐‘๐‘˜๐‘™๐‘๐‘˜ or ๐‘๐‘˜๐‘™๐‘๐‘™.

โ‡’ One of ๐‘๐‘–๐‘—๐‘๐‘– or ๐‘๐‘–๐‘—๐‘๐‘— one of ๐‘๐‘˜๐‘™๐‘๐‘˜ or ๐‘๐‘˜๐‘™๐‘๐‘™.

๐‘๐‘–๐‘—

๐‘๐‘–

๐‘๐‘—

๐‘๐‘˜ ๐‘๐‘™๐‘๐‘˜๐‘™

Delaunay Triangulation

Properties: The edges of ๐ท(๐‘ƒ) donโ€™t intersect.

Proof:

Given an edge ๐‘๐‘–๐‘๐‘— in ๐ท(๐‘ƒ), there is a circle with ๐‘๐‘–and ๐‘๐‘— on its boundary and empty of other points.

Let be ๐‘๐‘˜๐‘๐‘™ be an edge in ๐ท(๐‘) that intersect ๐‘๐‘–๐‘๐‘—:

๐‘๐‘˜ and ๐‘๐‘™ cannot be in the circle.

โ‡’ ๐‘๐‘˜ and ๐‘๐‘™ are not in the triangle ฮ”๐‘๐‘–๐‘—๐‘๐‘–๐‘๐‘—โ‡’ ๐‘๐‘˜๐‘๐‘™ intersects either ๐‘๐‘–๐‘—๐‘๐‘– or ๐‘๐‘–๐‘—๐‘๐‘—.

โ‡’ ๐‘๐‘–๐‘๐‘— intersects either ๐‘๐‘˜๐‘™๐‘๐‘˜ or ๐‘๐‘˜๐‘™๐‘๐‘™.

โ‡’ One of ๐‘๐‘–๐‘—๐‘๐‘– or ๐‘๐‘–๐‘—๐‘๐‘— one of ๐‘๐‘˜๐‘™๐‘๐‘˜ or ๐‘๐‘˜๐‘™๐‘๐‘™.

๐‘๐‘–๐‘—

๐‘๐‘–

๐‘๐‘—

๐‘๐‘˜ ๐‘๐‘™๐‘๐‘˜๐‘™

But ๐‘๐‘–๐‘—๐‘๐‘– is in the Voronoi region of ๐‘๐‘– and ๐‘๐‘˜๐‘™๐‘๐‘˜ is

in the Voronoi region of ๐‘๐‘˜, so they cannot intersect.

Outline

โ€ข Preliminaries

โ€ข Voronoi Diagrams / Delaunay Triangulations Naive Algorithm

Fortuneโ€™s Algorithm

โ€ข Lloydโ€™s Algorithm

Naive Algorithm

Delaunay( {๐‘1, โ€ฆ , ๐‘๐‘›} ) for ๐‘– โˆˆ 1, ๐‘›

ยปfor ๐‘— โˆˆ 1, ๐‘–โ€“ for ๐‘˜ โˆˆ [1, ๐‘—)โ€ข (๐‘, ๐‘Ÿ) โ† Circumcircle( ๐‘๐‘– , ๐‘๐‘— , ๐‘๐‘˜ )

โ€ข isTriangle โ† trueโ€ข for ๐‘™ โˆˆ [1, ๐‘˜)

โ€ข if( ๐‘๐‘™ โˆ’ ๐‘ < ๐‘Ÿ ) isTriangle โ† falseโ€ข if( isTriangle ) Output( ๐‘๐‘– , ๐‘๐‘— , ๐‘๐‘˜ )

Complexity: ๐‘‚(๐‘›4)

Voronoi Diagrams and Cones

Key Idea:

We can think of generating Voronoi regions

by expanding circles centered at points of ๐‘ƒ.

When multiple circles overlap a point, track

the one that is closer.

Voronoi Diagrams and Cones

Key Idea:

We can visualize the Voronoi regions by

drawing right cones over the points, with axes

along the positive ๐‘ง-axis.

Circles with radius ๐‘Ÿ are the projections of the

intersections of the plane ๐‘ง = ๐‘Ÿ plane with the

cones, onto the ๐‘ฅ๐‘ฆ-plane.

๐‘ฅ

๐‘ง

๐‘Ÿ๐‘Ÿ๐‘Ÿ

Voronoi Diagrams and Cones

Key Idea:

To track the closer circle, we can render the

cones with an orthographic camera looking

up the ๐‘ง-axis.

๐‘ฅ

๐‘ง

๐‘Ÿ

Voronoi Diagrams and Cones

Key Idea:

To track the closer circle, we can render the

cones with an orthographic camera looking

up the ๐‘ง-axis.

Visualization

Fortuneโ€™s Algorithm

Approach:

Sweep a line and maintain the solution for all

points behind the line.

Fortuneโ€™s Algorithm

Why This Shouldnโ€™t Work:

The Voronoi region behind the line can

depend on points that are in front of the line!

(Looking up the ๐‘ง-axis, we see

the cone before the apex.)

Key Idea:

We can finalize points

behind the line that are

closer to a site than to

the line.

Fortuneโ€™s Algorithm

Given a site ๐‘ โˆˆ ๐‘ƒ and the

line with height ๐‘ฆ0, we can

finalize the points satisfying:

(๐‘ฅ, ๐‘ฆ) ๐‘ฆ โˆ’ ๐‘ฆ02 > ๐‘ โˆ’ (๐‘ฅ, ๐‘ฆ) 2

Points on the boundary satisfy:

๐‘ฆ โˆ’ ๐‘ฆ02 = ๐‘ โˆ’ (๐‘ฅ, ๐‘ฆ) 2

Setting ๐‘ง = ๐‘ โˆ’ (๐‘ฅ, ๐‘ฆ) , this gives:

๐‘ง = ๐‘ฆ โˆ’ ๐‘ฆ0

๐‘

๐‘ฆ = ๐‘ฆ0

Fortuneโ€™s Algorithm

Formally:

โ‡’We can describe the

points on the boundary as

the ๐‘ฅ๐‘ฆ-coordinates of the points in 3D with:

1. ๐‘ง = ๐‘ โˆ’ (๐‘ฅ, ๐‘ฆ)

2. ๐‘ง = ๐‘ฆ โˆ’ ๐‘ฆ0

Sweep the cones

with a plane parallel

to the ๐‘ฅ-axis making a 45โˆ˜

angle with the ๐‘ฅ๐‘ฆ-plane.

Points on the right cone,

centered at ๐‘,centered around the positive ๐‘ง-axis

Points on the plane,

making a 45โˆ˜ angle with the ๐‘ฅ๐‘ฆ-plane,

passing through the line ๐‘ฆ = ๐‘ฆ0 and ๐‘ง = 0

๐‘

๐‘ฆ = ๐‘ฆ0

Fortuneโ€™s Algorithm

Fortuneโ€™s Algorithm

Sweep with a plane ๐œ‹๐‘ฆ, parallel to the ๐‘ฅ-axis,

making a 45โˆ˜ angle with the ๐‘ฅ๐‘ฆ-plane.

โ€œRenderโ€ the cones and the plane with an

orthographic camera looking up the ๐‘ง-axis.

At each point, we see: The part of ๐œ‹๐‘ฆ that is in front of the line (since it is

below the ๐‘ฅ๐‘ฆ-plane and hence below the cones).

The part of the cones that are behind the line and

below ๐œ‹๐‘ฆ.

Fortuneโ€™s Algorithm

As ๐‘ฆ advances, the algorithm maintains a set

of parabolic fronts (the projection of the

intersections of ๐œ‹๐‘ฆwith the cones).

At any point, the

Voronoi diagram is

finalized behind the

parabolic fronts.

Fortuneโ€™s Algorithm

As ๐‘ฆ advances, the algorithm maintains a set

of parabolic fronts (the projection of the

intersections of ๐œ‹๐‘ฆwith the cones).

At any point, the

Voronoi diagram is

finalized behind the

parabolic fronts.Implementation:

โ€ข The fronts are maintained in order.

โ€ข As ๐‘ฆ intersects a site, its front is inserted.

โ€ข Complexity ๐‘‚(๐‘› log ๐‘›).

Outline

โ€ข Preliminaries

โ€ข Voronoi Diagrams / Delaunay Triangulations

โ€ข Lloydโ€™s Algorithm

Lloydโ€™s Algorithm

Challenge:

Solve for the position of points ๐‘ƒ = {๐‘1, โ€ฆ , ๐‘๐‘›}inside the unit square minimizing:

๐ธ ๐‘ƒ = 0,1 2๐‘‘2(๐‘ž, ๐‘ƒ) ๐‘‘๐‘ž

where ๐‘‘ ๐‘ž, ๐‘ƒ = min๐‘–|๐‘๐‘– โˆ’ ๐‘ž|.

Lloydโ€™s Algorithm

Approach:

1. Initialize the points to random positions.

2. Compute the Voronoi Diagram of the

points, clipped to the unit square.

3. Set the positions of the points to the

centers of mass of the corresponding

Voronoi cells.

4. Go to step 2.

Lloydโ€™s Algorithm

Lloydโ€™s Algorithm

2. Compute the Voronoi Diagram of the

points, clipped to the unit square.

Since:

0,1 2๐‘‘2(๐‘ž, ๐‘ƒ) ๐‘‘๐‘ž =

๐น๐‘–โˆˆ๐‘‰ ๐‘ƒ

๐น๐‘–

๐‘๐‘– โˆ’ ๐‘ž2๐‘‘๐‘ž

this provides the assignment of points in

0,1 2 to points in ๐‘ƒ that minimize the energy.

Lloydโ€™s Algorithm

3. Set the positions of the points to the

centers of mass of the corresponding

Voronoi cells.

Since:

arg min๐‘โˆˆ 0,1 2

๐น

๐‘ โˆ’ ๐‘ž 2๐‘‘๐‘ž = ๐ถ(๐น)

with ๐ถ(๐น) the center of mass of face ๐น, repositioning to the center reduces the

energy.