25
CS6100: Topics in Design and Analysis of Algorithms Delaunay Triangulation John Augustine CS6100 (Even 2012): Delaunay Triangulation

09_DelaunayTriangulation

Embed Size (px)

DESCRIPTION

09_DelaunayTriangulation

Citation preview

  • CS6100: Topics in Design andAnalysis of Algorithms

    Delaunay Triangulation

    John Augustine

    CS6100 (Even 2012): Delaunay Triangulation

  • Triangulation of a Planar Point Set

    A triangulation of P is planar subdivision of the planein which (i) end points of line segments are in P and(ii) no line segment (connecting points in P ) can beadded 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 isunbounded and others are triangles. The total number

    of edges is 3m+k2 (why?) . Results follow by applying

    Eulers formula.

    CS6100 (Even 2012): Delaunay Triangulation 1

  • How do we compare the skinniness triangulations?

    Define angle-vector A(T ) of a triangulation T as vectorof angles sorted in non-decreasing order.

    We use lexicographic comparison on the angle vectorsto compare skinniness of triangulations.

    More precisely, let A(T ) = {1, 2, . . .} and A(T ) ={1, 2, . . .}. We say that A(T ) > A(T ) if for somei,

    j < i, j = j and i > i.

    We say that a triangulation T is angle-optimal if 6 T such that A(T ) > A(T ).

    CS6100 (Even 2012): Delaunay Triangulation 2

  • Flipping an Illegal Edge

    Let e be a non-boundary edge between two trianglesthat form a convex quadrilateral. This edge can beflipped to e. If this flip locally improves the anglevector, then we call e illegal.

    1

    4

    3 5

    2 6

    pi

    p j

    pk

    pl

    pi 41

    35

    2

    6

    p j

    pk

    pl

    edge flip

    Observation 2. If e is an illegal edge in T and T isobtained by flipping e, then,

    A(T ) > A(T ).

    CS6100 (Even 2012): Delaunay Triangulation 3

  • How to check if an edge is illegal?

    pi

    p j

    pk

    pl

    illegal

    Lemma 3. In the above figure, if pl is inside circlethrough pi, pk, and pj, then the edge (as indicated)is illegal. (This follows from Thales Theorem.)Theorem 4 (Thales Theorem). In Figure 1,

    arb > apb = aqb > asb.

    ` C

    p

    q

    r

    s

    a

    b

    Figure 1: Figure for Thales Theorem.

    CS6100 (Even 2012): Delaunay Triangulation 4

  • Legal Triangulation

    A legal triangulation does not contain any illegal edge.

    Recall Observation 2.

    A repeated flipping of illegal edges will terminatemake eventually make the triangulation legal.

    Observation 5. Every angle-optimal triangulation isa legal triangulation.

    Is the converse true?

    See http://www.cs.technion.ac.il/~barequet/teaching/cg/misc/DT-deg-pos.pdf for more details.

    CS6100 (Even 2012): Delaunay Triangulation 5

  • Towards Delaunay Graph

    Consider a set P of points/sites in the plane. LetVor(P ) be its Voronoi diagram. Each site p has a cellV(p) associated with it.The dual graph of VorP in which the vertices are thesites and two sites pi and pj are connected iff theircells V(pi) and V(pj) share an edge in Vor(P ).

    Vor(P)

    G

    CS6100 (Even 2012): Delaunay Triangulation 6

  • Delaunay Graph

    A straight line embedding of the dual graph on theset P of points is called the Delaunay Graph (denotedDG(P )).

    Theorem 6. The Delaunay graph is a plane graph.

    CS6100 (Even 2012): Delaunay Triangulation 7

  • Proof of Theorem 6

    Proof. Recall that the perpendicular bisector betweentwo sites appears in Vor(P ) iff a circle touching thesites but not enclosing any other site.

    In other words, pipj is in DG(P ) iff closed disc Cijwith pi and pj on the boundary and no other site iscontained in it.

    Let tij be the triangle formed by pi, pj, and center of(some) Cij.

    Ci j

    pi

    p j

    contained in V(pi)

    contained in V(p j)

    Note that edge of tij between pi and center of Cij isinside V(pi).CS6100 (Even 2012): Delaunay Triangulation 8

  • Suppose there is another edge pkpl also in DG(P ) suchthat pipj and pkpl intersect.

    (As defined for pipj, define Ckl and tkl for pkpl.)

    If pkpl 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 e of tkl must intersect pipj.

    Notice that this implies that one of the edges of tijincident to center of Cij and one of the edges of tklincident to center of Ckl must intersect.

    But, those edges must be contained within their

    respective Voronoi cells, which is a contradiction.

    CS6100 (Even 2012): 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?

    vf

    A Delaunay Triangulation is a triangulation obtainedby adding edges to a delaunay graph.

    CS6100 (Even 2012): 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 thecircle through those three points does not encloseany other point in P .

    2. Two points form an edge in DG(P ) iff a circlethrough those two points that does not enclose anyother point in P .

    Theorem 8. A triangulation T is a Delaunaytriangulation iff the circumcircle of any triangle inT does not contain any point in its interior.

    Theorem 9. A triangulation T is legal iff T is aDelaunay triangulation.

    CS6100 (Even 2012): Delaunay Triangulation 11

  • Proof of Theorem 9

    Proof. Easy to see that any Delaunay triangulation islegal. So focus on opposite direction.

    Assume for contradiction that T is a legal triangulation,but not a Delaunay triangulation.

    From Theorem 7, pi, pj, pk such that circumcircleC(pi, pj, pk) contains point pl P in its interior.Let e = pipj be the edge chosen so that 4pipjpl doesnot intersect 4pipjpk.

    pi

    p jpk

    pl

    C(pip j pk)

    pm C(pip j pm)

    e

    Notice that 4pipjpl cannot be a triangle in T as ecan be flipped to improve angle-optimality. Therefore,

    CS6100 (Even 2012): Delaunay Triangulation 12

  • pm 6= pl such that 4pipjpm is in T . (Note that ecannot be a boundary edge.)

    From Lemma 3 (since T is a legal triangulation), pmis outside C(pi, pj, pj).

    Let pjpm be the edge such that 4pjpmpl does notintersect pjpmpi. But, by Thales Theorem,

    pjplpi > pjpmpi,

    a contradiction as it allows pjpm to be flipped.

    Theorem 10.

    1. Any angle optimal triangulation is a Delaunaytriangulation.

    2. Any Delaunay triangulation maximizes the minimumangle.

    CS6100 (Even 2012): Delaunay Triangulation 13

  • A Randomized Incremental Constructionof Delaunay Triangulation

    Let P = {p0, p1, . . . , pn} be a set of points in the planeand let p0 be the highest point in P , whereas, the restof the points are randomly permuted.

    Enclose P in 4p0p1p2, where p1 and p2 aredummy points. 4p0p1p2 must be large enough sothat p1 and p2 dont lie in any circle defined bythree points in P .

    p1

    p0

    p2

    We start with 4p0p1p2 as the current triangulationand incrementally add points taken from a randompermutation {p1, p2, . . . , pn} of the remaining points.

    CS6100 (Even 2012): Delaunay Triangulation 14

  • Two Cases

    pr

    pi

    pk

    p j

    pr

    p j

    pi

    pkpl

    pr lies in the interior of a triangle pr falls on an edge

    In either case, illegal edges can be introduced, so welegalize them by testing each potentially illegal edgeand flipping illegal edges.

    =

    pr

    Note that all edges created are incident to the newlyinserted point pr.

    CS6100 (Even 2012): Delaunay Triangulation 15

  • Pseudocode

    Algorithm DELAUNAYTRIANGULATION(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 p1 and p2 be two points in R2 sufficiently far away and such that P is contained in

    the triangle p0p1p2.3. Initialize T as the triangulation consisting of the single triangle p0p1p2.4. Compute a random permutation p1, p2, . . . , pn of P\{p0}.5. for r 1 to n6. do ( Insert pr into T: )7. Find a triangle pip jpk T containing pr.8. if pr lies in the interior of the triangle pip jpk9. then Add edges from pr to the three vertices of pip jpk, thereby splitting pip jpk

    into three triangles.10. LEGALIZEEDGE(pr, pip j,T)11. LEGALIZEEDGE(pr, p jpk,T)12. LEGALIZEEDGE(pr, pkpi,T)13. else ( pr lies on an edge of pip jpk, say the edge pip j )14. Add edges from pr to pk and to the third vertex pl of the other triangle that

    is incident to pip j, thereby splitting the two triangles incident to pip j intofour triangles.

    15. LEGALIZEEDGE(pr, pipl,T)16. LEGALIZEEDGE(pr, pl p j,T)17. LEGALIZEEDGE(pr, p jpk,T)18. LEGALIZEEDGE(pr, pkpi,T)19. Discard p1 and p2 with all their incident edges from T.20. return T

    36

    CS6100 (Even 2012): Delaunay Triangulation 16

  • In line 7 of the pseudocode in the previous page, weperform a point location.

    We use a DAG D similar to the DAG used in pointlocation in planar subdivision.

    Each node in D corresponds to a 4 that was createdat some point.

    Searching for a point pr would entail going down theDAG D through a sequence of nodes correspondingto all triangles created before step r (and possiblydestroyed) that contain pr.

    CS6100 (Even 2012): Delaunay Triangulation 17

  • 1 2 3

    4

    3

    5

    4 5

    11

    2

    2

    3

    3

    1 2 3

    4

    4 5

    6

    7

    76

    split 1

    flip pip j

    flip pipk

    pr 1 2 3

    2

    3pi

    p j

    pipk

    CS6100 (Even 2012): Delaunay Triangulation 18

  • LEGALIZEEDGE(pr, pip j,T)1. ( The point being inserted is pr, and pip j is the edge of T that may need to be flipped. )2. if pip j is illegal3. then Let pip jpk be the triangle adjacent to prpip j along pip j.4. ( Flip pip j: ) Replace pip j with prpk.5. LEGALIZEEDGE(pr, pipk,T)6. LEGALIZEEDGE(pr, pkp j,T)

    37

    pr pi

    p j pk

    To show correctness, recall that every new edge

    added after the insertion of a point pr is incident topr.

    The part that gets changed is limited to triangles withtwo edges incident to pr. Therefore, the correctness ofthe algorithm follows from the following lemma.

    CS6100 (Even 2012): Delaunay Triangulation 19

  • Lemma 11. Every new edge created when pr is addedis a Delaunay edge of {p2, p1, p0, p1, . . . , pr}.

    Proof Sketch.

    pi

    p j pl

    pr

    CC

    4pjpipl is a Delaunay triangle of {p2, p1, p0, p1, . . . , pr1}.Therefore a circle C through pjpipl devoid ofpoints in {p2, p1, p0, p1, . . . , pr1}. Shrink C untilit touches only pr and pl this can be done thusproving that prpl is a Delaunay Edge.

    CS6100 (Even 2012): Delaunay Triangulation 20

  • Analysis

    Lemma 12. Expected number of triangle created bythe algorithm is 9n+ 1.

    Proof. Recall what happens when we insert pr. First,one of the following two cases, and subsequently, werepeatedly legalize edges (until none are left).

    pr

    pi

    pk

    p j

    pr

    p j

    pi

    pkpl

    pr lies in the interior of a triangle pr falls on an edge

    First, three (or four) triangles are formed.Subsequently, each edge we legalize will add 2triangles.

    Therefore, if k is the number of edges incident to

    pr then, 2(k 3) + 3 = 2k -3 new triangles areformed.

    CS6100 (Even 2012): 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 4p0p1p2.

    CS6100 (Even 2012): Delaunay Triangulation 22

  • Theorem 13.The Randomized Incremental Algorithmfor the Delaunay Triangulation of n points takesO(n log n) time and O(n) space, both on expectation.

    Proof Sketch. Space follows from nodes in Drepresenting triangles created, which is 9n + 1 onexpectation.

    Not counting point location, the creation of eachtriangle 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 goingdown the DAG D through a sequence of nodescorresponding to all triangles created before step r(and possibly destroyed) that contain pr.

    So each triangle that was created is visited once foreach point in it. In other words, . . .

    Let K() P be the points inside triangle . TimeCS6100 (Even 2012): Delaunay Triangulation 23

  • for point locations is

    K().

    Roughly speaking, each triangle created in round r hasO(n/r) points of P in it. Therefore,

    K() r

    O(n/r)

    O(n log n),

    CS6100 (Even 2012): Delaunay Triangulation 24