Delaunay Triangulation and Tetrahedrilization

73
Delaunay Triangulation and Tetrahedrilization Marc van Kreveld Slides DDM 1

description

Delaunay Triangulation and Tetrahedrilization. Marc van Kreveld Slides DDM. Triangulations and their quality. When going from points on a surface to triangles representing that surface, there are many ways to form the triangles Some ways are better than others. - PowerPoint PPT Presentation

Transcript of Delaunay Triangulation and Tetrahedrilization

Page 1: Delaunay Triangulation and  Tetrahedrilization

1

Delaunay Triangulation and Tetrahedrilization

Marc van KreveldSlides DDM

Page 2: Delaunay Triangulation and  Tetrahedrilization

2

Triangulations and their quality

• When going from points on a surface to triangles representing that surface, there are many ways to form the triangles

• Some ways are better than others

Page 3: Delaunay Triangulation and  Tetrahedrilization

3

Triangulations and their quality

• This is not just true visually, but also when the triangulation is the interpolator for a terrain with elevation measurements

Page 4: Delaunay Triangulation and  Tetrahedrilization

4

Triangulations and their quality

Page 5: Delaunay Triangulation and  Tetrahedrilization

5

Triangulations and their quality

• Triangulations are good if they– do not have long edges– do not have triangles with both short and long edges– do not have triangles with very small angles– do not have triangles with obtuse angles– do not have vertices with high degree– …

Page 6: Delaunay Triangulation and  Tetrahedrilization

6

Voronoi diagrams

• For a set of points (sites), the Voronoi diagram is the subdivision of the plane (space) with faces where exactly one of the sites is closest, among all sites

Page 7: Delaunay Triangulation and  Tetrahedrilization

7

Voronoi diagrams

• Voronoi vertices “often” have degree 3, but it can be much larger

• Voronoi edges can be bounded or unbounded

Voronoi edge

Voronoi vertex

Page 8: Delaunay Triangulation and  Tetrahedrilization

8

Voronoi diagrams

• With n point sites, there are < 2n Voronoi vertices and < 3n Voronoi edges

Voronoi edge

Voronoi vertex

Page 9: Delaunay Triangulation and  Tetrahedrilization

9

Voronoi diagrams

• The average number of edges bounding a Voronoi cell is six (or slightly less), but a single cell could be bounded by up to n – 1 edges

Voronoi edge

Voronoi vertex

Page 10: Delaunay Triangulation and  Tetrahedrilization

10

Voronoi diagrams

• Voronoi diagrams have the empty circle property for every Voronoi vertex and Voronoi edge

Page 11: Delaunay Triangulation and  Tetrahedrilization

11

Voronoi diagrams

• Efficient algorithms exist to construct 2D Voronoi diagrams of n point sites, namely O(n log n) time algorithms (as fast as sorting! [mergesort, quicksort])

Page 12: Delaunay Triangulation and  Tetrahedrilization

12

Voronoi diagrams

• 3D Voronoi diagrams with n point sites can have up to (n2) Voronoi vertices (0D), Voronoi edges (1D), and Voronoi facets (2D) but of course just n cells (3D)

• The descriptive complexity can be anything between linear and quadratic in n

Page 13: Delaunay Triangulation and  Tetrahedrilization

13

Voronoi diagrams

• 3D Voronoi diagrams with n point sites often have linearly many Voronoi vertices (0D), Voronoi edges (1D), and Voronoi facets (2D)

Page 14: Delaunay Triangulation and  Tetrahedrilization

14

Delaunay triangulation

• For a set of points in the plane, suppose we compute its Voronoi diagram and use it to make an embedded planar graph G as follows:– all points are vertices of the graph G– for all points whose Voronoi cells share a Voronoi edge,

we have an edge in G– faces of G are implied by the vertices and edges of G

Page 15: Delaunay Triangulation and  Tetrahedrilization

15

Delaunay triangulation– all points are vertices of the graph G– edges in G correspond to edge-adjacent Voronoi cells– faces of G are implied by the vertices and edges of G

Page 16: Delaunay Triangulation and  Tetrahedrilization

16

Delaunay triangulation– all points are vertices of the graph G– edges in G correspond to edge-adjacent Voronoi cells– faces of G are implied by the vertices and edges of G

Page 17: Delaunay Triangulation and  Tetrahedrilization

17

Delaunay triangulation

• This graph is called the Delaunay graph• Notice that an edge of the Delaunay graph does not

necessarily intersect the corresponding Voronoi edge

Page 18: Delaunay Triangulation and  Tetrahedrilization

18

Delaunay triangulation

• The Delaunay graph is a triangulation of the original points if and only if all Voronoi vertices have degree 3 there is no circle through more than 3 sites and with no sites inside

Page 19: Delaunay Triangulation and  Tetrahedrilization

19

Delaunay triangulation

• Any (planar) completion of the Delaunay graph to a triangulation is a Delaunay triangulation of the original points

Page 20: Delaunay Triangulation and  Tetrahedrilization

20

Delaunay triangulation

• The empty-circle property for Voronoi diagrams transfers to Delaunay triangulations– for each triangle, its circumcircle

contains no other pointsfrom the set inside

– for each edge, a circleexists through itsendpoints that hasno other points of the set inside

Page 21: Delaunay Triangulation and  Tetrahedrilization

21

Delaunay triangulation

• A Delaunay triangulation of n points has at least n – 2 and at most 2n – 5 triangles (Delaunay triangles)

• A Delaunay triangulation of n points has at least 2n – 3 and at most 3n – 6 edges (Delaunay edges)

• The empty-circle property is “if and only if”: if three points have a circumcircle with no points inside or other points on the boundary, then they make a Delaunay triangle(a similar statement holds for edges)

Page 22: Delaunay Triangulation and  Tetrahedrilization

22

Delaunay triangulation

• When a Delaunay graph is not a triangulation, the non-triangular faces have all vertices on a circle

Page 23: Delaunay Triangulation and  Tetrahedrilization

23

Delaunay triangulation

Page 24: Delaunay Triangulation and  Tetrahedrilization

24

Delaunay triangulation

Page 25: Delaunay Triangulation and  Tetrahedrilization

25

Delaunay triangulation

Page 26: Delaunay Triangulation and  Tetrahedrilization

26

Delaunay triangulation

Page 27: Delaunay Triangulation and  Tetrahedrilization

27

Delaunay triangulation

Page 28: Delaunay Triangulation and  Tetrahedrilization

Delaunay triangulation

• When we know four Delaunay edges that form an empty convex quadrilateral, we will have one of the two diagonals as a Delaunay edge

• The circumcircles of the triangles of one choice will contain the fourth points, but not for the other choice

28

Page 29: Delaunay Triangulation and  Tetrahedrilization

29

Delaunay triangulation

• The Delaunay triangulation maximizes the smallest occurring angle, over all triangulations of the point set

• In other words, any other triangulation will have a smaller (or the same) smallest angle

Page 30: Delaunay Triangulation and  Tetrahedrilization

30

Delaunay triangulation

• The Delaunay triangulation often connects points close together, e.g., every point is connected to its nearest neighbor

• But it does not minimize total edge length

Page 31: Delaunay Triangulation and  Tetrahedrilization

Delaunay triangulation

• In a triangulation, when two triangles form a convex quadrilateral, their shared edge can be replaced by one other edge

• This is called an edge flip

31

flip

Page 32: Delaunay Triangulation and  Tetrahedrilization

Computing the Delaunay triangulation

• Approach: insert points one-by-one, and restore the Delaunay triangulation after every insertion

32

1. Locate the triangle t con-taining the next point p

2. Connect p to t’s vertices3. Restore the Delaunay

triangulation by flipping non-Delaunay edges

pt

Page 33: Delaunay Triangulation and  Tetrahedrilization

Computing the Delaunay triangulation

• Locate: Recall that we store triangulations in some convenient structure (triangle-neighbor structure, half-edge structure)

• From any access point (triangle, half-edge), walkalong a straight line to thelocation of the p, finding the triangle t containing p

• The details of the walk depend on the mesh structure used

33

p

Page 34: Delaunay Triangulation and  Tetrahedrilization

Computing the Delaunay triangulation

• Connect: Make edges from p to t’s vertices; this replaces t by three new triangles

• Adapt the mesh representationstructure accordingly

Claim: These three new edges are Delaunay

34

p

Page 35: Delaunay Triangulation and  Tetrahedrilization

C

Computing the Delaunay triangulation

• Proof of claim:– Triangle t was Delaunay before the insertion of p,

so there was an empty circle C through its vertices

35

pt

v

Page 36: Delaunay Triangulation and  Tetrahedrilization

C

Computing the Delaunay triangulation

• Proof of claim:– Triangle t was Delaunay before the insertion of p,

so there was an empty circle C through its vertices– Consider the edge between p and

any vertex v of t, there is always acircle through p and v completely inside C (grow a small circle fromv tangent to C at v, until it hits p)

36

pt

v

Page 37: Delaunay Triangulation and  Tetrahedrilization

C

Computing the Delaunay triangulation

• Proof of claim:– Triangle t was Delaunay before the insertion of p,

so there was an empty circle C through its vertices– Consider the edge between p and

any vertex v of t, there is always acircle through p and v completely inside C (grow a small circle fromv tangent to C at v, until it hits p)

– Since v and p have an empty circle,they define a Delaunay edge

37

pt

v

Page 38: Delaunay Triangulation and  Tetrahedrilization

Computing the Delaunay triangulation

• Restore: The three new edges are always Delaunay, but the three new triangles need not be …

38

p

p

Delaunay

maybe not Delaunay

Page 39: Delaunay Triangulation and  Tetrahedrilization

Computing the Delaunay triangulation

• In the picture: triangle qrs had an empty circle C(q,r,s) before the insertion of p, but maybe p lies inside now test p C(q,r,s), and if so, edge-flip qr to ps

39

p

Delaunay

maybe not Delaunay

q

rs

pq

rs

C(q,r,s)

Page 40: Delaunay Triangulation and  Tetrahedrilization

Computing the Delaunay triangulation

• If flipped, the edges pq, pr, and also ps must be Delaunay, but maybe pqs and prs are not Delaunay triangles … recurse on them, using the triangles opposite qs and rs

40

p

Delaunay

maybe not Delaunay

q

rs

pq

rs

Delaunay

maybe not Delaunay

Page 41: Delaunay Triangulation and  Tetrahedrilization

41

Computing the Delaunay triangulation

• Code for recursive flipping (restore algorithm):

TestFlipEdge (p, qr)

Let s p be the third point of the triangle incident to qrif p is inside C(q,r,s){ flip: delete qr and insert ps in the triangulation

TestFlipEdge(p, qs)TestFlipEdge(p, sr)

}

Page 42: Delaunay Triangulation and  Tetrahedrilization

42

Computing the Delaunay triangulation

• Comments:– The edge flip must be done in our triangle-mesh

representation structure (triangle-neighbor, half-edge, …)– With suitable triangle-mesh structure, a flip takes O(1) time

(with an indexed mesh, a flip takes O(n) time)– Every edge flip connects p to an extra vertex on the average, about 3 flips are needed

– The main geometric test is the so-called in-circle test: does a point p lie inside the circle defined by three points q,r,s?

Page 43: Delaunay Triangulation and  Tetrahedrilization

43

The in-circle test

• The in-circle test: does a point p lie inside the circle defined by three points q,r,s? (1) The bad way:– Compute the bisectors of q,r and r,s– Intersect them to get the center c of C(q,r,s)– Compute dist(c,p) and dist(c,q) (the radius of C(q,r,s));

if the former is smaller, then p lies inside C(q,r,s)

Page 44: Delaunay Triangulation and  Tetrahedrilization

44

The in-circle test

• The in-circle test: does a point p lie inside the circle defined by three points q,r,s? (2) The good way:– Compute the plane through (qx, qy, qx

2 + qy2), (rx, ry, rx

2 + ry2),

and (sx, sy, sx2 + sy

2)

– Test whether the point (px, py, px2 + py

2) lies above or below this plane: below p is inside; above p is outside

Page 45: Delaunay Triangulation and  Tetrahedrilization

45

The in-circle test

• The in-circle test: does a point p lie inside the circle defined by three points q,r,s? (2) The good way:– Compute the plane through (qx, qy, qx

2 + qy2), (rx, ry, rx

2 + ry2),

and (sx, sy, sx2 + sy

2)

– Test whether the point (px, py, px2 + py

2) lies above or below this plane

• This is equivalent to computing the sign of the 4x4 determinant: |q x q y

r x r yq x2 +  q y2 1r x 2 +  r y 2 1

s x syp x py

s x2 +  s y2 1p x2 +  p y2 1| negative

inside

Page 46: Delaunay Triangulation and  Tetrahedrilization

46

The whole algorithm

• Initialization: we want to make sure that the next point p is always in some triangle of the current triangulation start with a suitable bounding box

(triangulated)

Page 47: Delaunay Triangulation and  Tetrahedrilization

47

The whole algorithm

• The four extra vertices need special treatment when they are involved in an in-circle test (because they do not count for the empty-circle property)

Page 48: Delaunay Triangulation and  Tetrahedrilization

The whole algorithm

1. Initialize a triangulation T with a bounding box2. For each point pi

i. Locate the triangle t of T containing pi by traversing the triangle-mesh structure from some access point

ii. Connect pi to the vertices of tiii. (Restore) For each edge e of t, TestFlipEdge(p, e)

48

Page 49: Delaunay Triangulation and  Tetrahedrilization

49

Efficiency of the algorithm

• Locate: if the points are distributed “reasonably”, a line typically intersects O(n) triangles(certainly true if the points lie in a regular square grid pattern)

• Worst-case O(n) time

some fixed starting point

Page 50: Delaunay Triangulation and  Tetrahedrilization

50

Efficiency of the algorithm

• Connect: obviously O(1) time in the triangle-neighbor structure and half-edge structure

• Restore: typically 3 flips are needed: the average degree of a vertex in a triangulation is 6, connect leads to a starting degree of 3 for pi, and every flip increases the degree of pi by 1 typically O(1) time, but worst-case O(n) time

Page 51: Delaunay Triangulation and  Tetrahedrilization

51

Efficiency of the algorithm

• Initialization O(n) time• Insertion of the i-th point takes worst-case O(i) time

but typically O(i) time

• Worst-case O(n2) time algorithm• Typically O(nn) time algorithm

Note: worst-case O(n log n) time algorithms exist; these are more complicated

Page 52: Delaunay Triangulation and  Tetrahedrilization

Delaunay tetrahedrilization

• Global approach the same• The in-circle test becomes an in-sphere test

(solved with a 5x5 determinant)• The edge-flip becomes a bi-stellar flip: 2 3 tetrahedra

52

Page 53: Delaunay Triangulation and  Tetrahedrilization

53

Delaunay tetrahedrilization

Page 54: Delaunay Triangulation and  Tetrahedrilization

54

Terrains and 2D/3D Delaunay

• Note the difference:– A polyhedral terrain (triangular mesh representing elevation)

obtained by computing the Delaunay triangulation of the (x,y) points and using the triangles in 3D

– A 3D Delaunay tetrahedrilization of the (x,y,z) points

• A triangle in the first case does not necessarily occur as a triangular facet in the second case (the 2D circle can be small when the 3D ball is huge)

Page 55: Delaunay Triangulation and  Tetrahedrilization

55

Constrained Delaunay triangulation

• Variation on the Delaunay triangulation where certain edges must be included (even if they are not Delaunay)

• Endpoints of such constraining edges are also vertices of the constrained Delaunay triangulation

Page 56: Delaunay Triangulation and  Tetrahedrilization

56

Constrained Delaunay triangulation

• Useful when known linear features must be included in the triangulation– some polygon boundary– lake boundaries in a terrain with elevation values known

Page 57: Delaunay Triangulation and  Tetrahedrilization

57

Constrained Delaunay triangulation

• Input: set of points and set of edges (constraints)

Page 58: Delaunay Triangulation and  Tetrahedrilization

58

Constrained Delaunay triangulation

• Input: set of points and set of edges (constraints)

constrained Delaunay triangulation

Page 59: Delaunay Triangulation and  Tetrahedrilization

59

Constrained Delaunay triangulation

• Input: set of points and set of edges (constraints)

normal Delaunay triangulation

Page 60: Delaunay Triangulation and  Tetrahedrilization

60

Constrained Delaunay triangulation

• Relaxed empty-circle property: three points define a circle in the constrained Delaunay graph if and only if their circumcircle has no other points (including constraint endpoints) inside or on the boundary, with the possible exception of points on the other side of constraints that cut the circle fully

Page 61: Delaunay Triangulation and  Tetrahedrilization

61

Constrained Delaunay triangulation

• To compute the constrained Delaunay triangulation, first compute the normal Delaunay triangulation of the points and constraint endpoints

• Then insert the constraints one by one, removing the intersected edges/triangles, and re-triangulating the holes

Page 62: Delaunay Triangulation and  Tetrahedrilization

62

Constrained Delaunay triangulation

Build Delaunay triangulation

Page 63: Delaunay Triangulation and  Tetrahedrilization

63

Constrained Delaunay triangulation

Insert constraining edge by removing intersected edges and triangles

Page 64: Delaunay Triangulation and  Tetrahedrilization

64

Constrained Delaunay triangulation

Note: all other edges and triangles remain in the CDT, because the empty circle of the DT will also be an empty circle with the constraint added

Page 65: Delaunay Triangulation and  Tetrahedrilization

65

Constrained Delaunay triangulation

Triangulate the cavity by shrinking a circle through the constraint endpoints until it reaches a vertex

Page 66: Delaunay Triangulation and  Tetrahedrilization

66

Constrained Delaunay triangulation

Make two new edges to this vertex from the other points defining the circle, and recurse

Page 67: Delaunay Triangulation and  Tetrahedrilization

67

Constrained Delaunay triangulation

Page 68: Delaunay Triangulation and  Tetrahedrilization

68

Constrained Delaunay triangulation

• A constrained Delaunay triangulation can be constructed in O(n log n) time in the worst case(for n points and constraints)

• The given algorithm takes O(n3) time in the worst case but one expects much better performance

Page 69: Delaunay Triangulation and  Tetrahedrilization

69

Constrained Delaunay in 3D

• Constrained Delaunay tetrahedrilizations do not always exist

• We would need to subdivide constraining facets using extra vertices and edges

Page 70: Delaunay Triangulation and  Tetrahedrilization

70

Steiner points in triangulations

• The Delaunay triangulation of the given points may not give sufficiently well-shaped triangles add extra points (Steiner points)

• Useful for point sets with or without constraints

Page 71: Delaunay Triangulation and  Tetrahedrilization

71

Steiner points in triangulations

• Steiner points can lower the maximum vertex degree and improve the smallest occurring angle

• Steiner points placed on a constraint can break it into several shorter constraints

Page 72: Delaunay Triangulation and  Tetrahedrilization

72

Steiner points in triangulations

• A common example is triangulating a simple polygon with Steiner points on the edges and inside

Page 73: Delaunay Triangulation and  Tetrahedrilization

73

Questions1. Prove that edge ps (slide 38/39) is always Delaunay, using the

empty circles known from the situation before p was inserted2. Why is the running time of inserting all constraints

incrementally into a constrained Delaunay triangulation at most cubic in the number of points and constraints?

3. Why do we expect much better performance than cubic when inserting all constraints?