computational geometry csci3250 - bowdoin.edu · triangulation input: p = {p1, p2,…,p n} set of...

39
Computational Geometry csci3250 Laura Toma Bowdoin College

Upload: votuyen

Post on 04-Jun-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Computational Geometry csci3250

!!!!!!

Laura Toma !

Bowdoin College

Page 2: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Today

• Triangulations • Delaunay triangulation

• Properties • How to construct it • Applications

Page 3: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Triangulation

Input: P = {p1, p2,…,pn} set of points in the plane !A triangulation T(P) is a maximal planar subdivision whose vertices are P. ! maximal planar subdivision: no edge can be added without distorting planarity planar : edges can only intersect at endpoints !!!!!!!!!!!!!!!!!Every bounded face must be a triangle. The unbounded face : bounded by convex hull.

Page 4: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

• Many triangulations possibleP = {p1, p2,…,pn} set of points in the plane

• In practice, want triangulations without small angles • small angles cause numerical instability with geometric predicates, etc

Page 5: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Size of a triangulation

• Let k = number of points in P that lie on CH(P). • Any triangulation of P has 2n - 2 -k triangles and 3n - 3 - k edges.

!• Proof: Use Euler’s formula: e - v + f = 2;

P = {p1, p2,…,pn} set of points in the plane

Page 6: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Voronoi Diagram Vor(P)

• Vor(pi): all points in the plane that are closer to pi than to any other site

P = {p1, p2,…,pn} set of points in the plane

v

p1

p2

p3

Page 7: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Voronoi Diagram Vor(P)

• The edges of Vor(P) are (segments of) perpendicular bisectors

P = {p1, p2,…,pn} set of points in the plane

v

p1

p2

p3

Page 8: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Voronoi Diagram Vor(P)

• Every Voronoi vertex is the intersection of 3 Voronoi regions

(if no 4-points co-circular)

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

v

p1

p2

p3

Page 9: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Voronoi Diagram Vor(P)

• Degeneracies • more than 3 points lie on same circle • collinear points

P = {p1, p2,…,pn} set of points in the plane

Page 10: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Voronoi Diagram Vor(P)

• Every Voronoi vertex is the intersection of 3 Voronoi regions • v is equidistant from p1, p2, p3

v

p1

p2

p3

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

Page 11: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Voronoi Diagram Vor(P)

• Every Voronoi vertex is the intersection of 3 Voronoi regions • v is equidistant from p1, p2, p3 • C(v): circle of p1,p2,p3 has center v

v

p1

p2

p3

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

Page 12: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Voronoi Diagram Vor(P)

• Every Voronoi vertex is the intersection of 3 Voronoi regions • v is equidistant from p1, p2, p3 • C(v): circle of p1,p2,p3 has center at v • No other site can be inside C(v) <———— empty circle property

v

p1

p2

p3

• Every Voronoi vertex is the center of a circle that has 3 sites on its boundary and no other sites inside

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

Page 13: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

The dual of Vor(P)

• For every pair of Voronoi regions Vor(u) and Vor(v) that share and edge, draw an edge between u and v

==> Each Voronoi vertex v defines a triangle

v

p1

p2

p3

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

Page 14: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Delaunay triangulation DT

Theorem [Delaunay 1934]:

The straight-line dual of Vor(P) is planar, and is a triangulation.

Proof: not trivial (see p.197 in 4M book)

v

p1

p2

p3

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

Page 15: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Delaunay triangulation DTP = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

Page 16: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Delaunay triangulation DT

By definition, DT(P) is the dual of Vor(P).

Would be nice to have a direct way to characterize DT(P) (without Vor(P)).

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

Page 17: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

v

p1

p2

p3 p1

p2

p3

Delaunay triangulation DT

What we know from Vor(P) • p1p2p3 is a triangle in DT(P) <==> circumcircle of p1p2p3 is empty

!!!!!!!!!

Theorem:

A triangulation T(P) is the DT(P) iff all triangles of T(P) have the empty-circle property.

Proof: “==>” easy

“<==“ requires a bit more work

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

Page 18: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Delaunay triangulation DT

• How to build a triangulation such that all triangles have empty-circle property?

p1

p2

p3

circumcircle of p1p2p3 is empty

Page 19: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

• How to build a triangulation? • Input: a set of points • Output: a partition of CH(P) into triangles

!!!!!!!!

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

Page 20: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

• Many triangulations possible

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

Page 21: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

• Come up with an algorithm to compute a triangulation of P

!!!!!!!!!!!

• Possible ideas: incremental, plane sweep, divide-and-conquer, …

Class work: P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

Page 22: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Flipping edgesedge flips

Page 23: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

How to get a DT? • Compute an arbitrary triangulation T(P) • T ————> DTedge flips

a

c

b

d

a

c

b

d

a

c

b

d

edge flipsFlipping edges and empty circles

C(abc) contains d b outside C(acd)flip ab to cd

WHY?

Page 24: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

a

c

b

d

Lemma: d inside C(abc) <==> b outside C(abd)

• Why? !• basic geometry of angles (Thales theorem)

a

c

b

a > b > c

Page 25: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

a

c

b

d

Note condition is symmetrical: d inside C(abc) <==> c inside C(abs)

• Why? !• basic geometry of angles (Thales theorem)

a

c

b

a > b > c

Page 26: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Notation: • edge ab is illegal iff d is inside C(abc)

(a legal edge also called a locally Delaunay edge) • edge ab is legal iff not illegal (d on or outside C(abc))

a

c

b

d

a

c

b

d

a

c

b

d

edge flipsFlipping edges and empty circles

ab illegal cd legalflip

Page 27: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Theorem, revisited:

A triangulation where all edges are locally Delaunay (legal) is the DT.

(locally Delaunay ==> globally Delaunay)

a

c

b

da

c

b

d

Flipping edges and empty circles

ab illegal cd legalflip ab to cd

Page 28: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

DT via edge flipping!• construct an arbitrary triangulation T • mark all edges in T and put them in S • while S not empty

• pop edge ab from S and un-mark it • if ab not legal:

• flip edge and update T • for each new edge ac, ad, bc, bc: if

not marked, push it on S and mark it

a

c

b

d

Delaunay triangulation

Does this ever terminate?.. If it terminates, T is DT (by theorem)

Page 29: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

a1

a2

a3a4 a5a6

d

a b

cEdge flipping and angles

angle vector before A(T) = [a1, a2, a3, a4, a5, a6] after A(T’) = [b1, b2, b3, b4, b5, b6] !Claim: For each new angle, there is an old angle that’s <= to it. Proof: b1 = a1+a4 > a1 b2 > a5 (b outside C(acd)) b3 > … similar b4 = a3 + a5 > a3 b5 > … similar b6 > a3 (b outside C(acd))

b1

c

b

d

b2 b3

b4b5b6a

Page 30: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Edge flipping and angles

Flipping an illegal edge to a legal edge increases minimum angle.

Proof: Follows because each angle in T’ is larger than an angle in T.

!DT maximizes minimum angle.

Proof: DT has only legal edges. Any other flip would cause the min angel to decrease.

a1

a2

a3a4 a5a6

d

a b

c

b1

c

b

d

b2 b3

b4b5b6a

Page 31: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

More generally..

A triangulation T.

consider all angles in each of its m triangles => 3m angles

sort angles increasingly: a1 ≦ a2 ≦ a3 ≦…… ≦ a3m

A(T) = [a1, a2, a3, ……,a3m]

!We say A(T) > A(T’) if A(T) > A(T’) lexicographically.

[2,5,6] > [1,2,3]

[1,2,3] > [1,1,9]

!Of all possible triangulations, DT maximizes the angle vector.

That is, for all T’, A(DT) > A(T’).

Proof: An edge flip increases the angle vector.

a1

a2

a3a4 a5a6

d

a b

c

b1

c

b

d

b2 b3

b4b5b6a

Page 32: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

DT Applications

• DT used because it is angle-optimal. • Small angles

• Numerical instability, Interpolation errors • Issues with geometric predicates (leftOf, tangents, derivatives)

Page 33: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Computing DT: RIC

RIC (Randomized Incremental Construction)!• Start with a large triangle T that contains P. • Compute a random permutation of the points in P • For each point p in P do:

//insert p in T • find triangle abc of T that contains p • splitting into 3 triangles: abp, bcp, cap and update T • LegalizeEdge(p, ab, T) • LegalizeEdge(p, bc, T) • LegalizeEdge(p, ca, T)

• discard the initial triangle T and its edges • return T

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

a

p

c

b

Page 34: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

Computing DT: RIC

LegalizeEdge(p, uv, T)!

//the point being inserted is p, and edge uv may need to be flipped • if uv is illegal

• let uvq be the triangle adjacent to uv, on the other side of p • flip uv and update T • LegalizeEdge(p, uq, T) • LegalizeEdge(p, qv, T)

P = {p1, p2,…,pn} set of points in the plane no 4 points co-circular

a

p

c

b

Page 35: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

a

p

c

b

Page 36: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

a

p

c

b

Page 37: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

a

p

c

b

q

Page 38: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

a

p

c

b

q

Page 39: Computational Geometry csci3250 - bowdoin.edu · Triangulation Input: P = {p1, p2,…,p n} set of points in the plane ! A triangulation T(P) is a maximal planar subdivision whose

a

p

c

b

q