My talk about computational geometry in NTU's APEX Club in NTU, Singapore in 2007. The club is for people who are keen on participating in ACM International Collegiate Programming Contests organized by IBM annually.
38. Convex Hulls Subset of S of the plane is convex, if for all pairs p,q in S the line segment pq is completely contained in S. The C onvex Hull CH(S) is the smallest convex set, which contains S. p q pq p q pq
39. Convex hull of a set of points in the plane The convex hull of a set P of points is the unique convex polygon whose vertices are points of P and which contains all points from P. Rubber band experiment
40.
41.
42. Graham-Scan : (1/11) p 1 p 0 p 3 p 4 p 2 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12
43. Graham-Scan :(1/11) p 1 p 0 p 3 p 4 p 2 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12 1.Calculate polar angle 2.Sorted by polar angle
44. Graham-Scan : (2/11) p 2 p 1 p 0 Stack S : p 1 p 0 p 3 p 4 p 2 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12
45. Graham-Scan : (3/11) Stack S : p 1 p 0 p 3 p 4 p 2 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12 p 3 p 1 p 0
46. Graham-Scan : (4/11) p 1 p 0 p 3 p 4 p 2 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12 p 4 p 3 p 1 p 0 Stack S :
47. Graham-Scan (5/11) p 1 p 0 p 3 p 4 p 2 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12 p 5 p 3 p 1 p 0 Stack S :
48. Graham-Scan (6/11) p 1 p 0 p 3 p 4 p 2 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12 p 8 p 7 p 6 p 5 p 3 p 1 p 0 Stack S :
49. Graham-Scan (7/11) p 1 p 0 p 3 p 4 p 2 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12 p 9 p 6 p 5 p 3 p 1 p 0 Stack S :
50. Graham-Scan (8/11) p 1 p 0 p 3 p 4 p 2 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12 p 10 p 3 p 1 p 0 Stack S :
51. Graham-Scan (9/11) p 1 p 0 p 3 p 4 p 2 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12 p 11 p 10 p 3 p 1 p 0 Stack S :
52. Graham-Scan (10/11) p 1 p 0 p 3 p 4 p 2 p 5 p 6 p 7 p 8 p 9 p 10 p 11 p 12 p 12 p 10 p 3 p 1 p 0 Stack S :
53.
54.
55.
56.
57.
58. Sweep Line Algorithm Avoid testing pairs of segments that are far apart . Idea : imagine a vertical sweep line passes through the given set of line segments, from left to right. Sweep line
59. Assumption on Non-degeneracy No segment is vertical. // the sweep line always hits a segment at // a point. If a segment is vertical, imagine we rotate it clockwise by a tiny angle. This means: For each vertical segment, we will consider its lower endpoint before upper point.
60. Sweep Line Status The set of segments intersecting the sweep line. It changes as the sweep line moves, but not continuously . Updates of status happen only at event points . left endpoints right endpoints intersections event points A G C T
61.
62.
63.
64.
65. Data Structure for Event Queue Data structure: balanced binary search tree (e.g., red - black tree). Ordering of event points: by x -coordinates by y -coordinates in case of a tie in x -coordinates. Supports the following operations on a segment s . inserting an event fetching the next event Every event point p is stored with all segments starting at p . // O (log m ) // O (log m ) m = # event points in the queue
66. Data Structure for Sweep-line Status Describes the relationships among the segments intersected by the sweep line. Use a balanced binary search tree T to support the following operations on a segment s . Insert( T , s ) Delete( T , s ) Above( T , s ) // segment immediately above s Below( T , s ) // segment immediately below s e.g , Red - black trees, splay trees ( key comparisons replaced by cross-product comparisons ) . O (log n ) for each operation.
67. An Example L K M N O K L O N M K L N O The bottom-up order of the segments correspond to the left-to-right order of the leaves in the tree T . Each internal node stores the segment from the rightmost leaf in its left subtree.
68.
69. Handling Event Points Status updates (1) – (3) presented earlier. Degeneracy : several segments are involved in one event point (tricky). T: (a) Delete D, E, A, C (b) Insert B , A, C p A B C C A D G E H l D D A G E H C A C G E G C H A B A G C B
73. Terrains Given: A number of sample points p 1 ..., p n Requir ed: A triangulation T of the points resulting in a “realistic” terrain. "Flipping" of an edge: 900 930 20 50 900 930 20 50 Goa l: Maximise the minimum angle in the triangulation
74. Triangulation of Planar Point Sets Given: Set P of n points in the plane (not all collinear ). A triangulation T(P) of P is a planar subdivision of the convex hull of P into triangles with vertices from P . T(P) is a maximal planar subdivision. For a given point set there are only fin itel y many different triangulations.
75. Size of Triangulations Theorem : Let P be a set of n points in the plane, not all collinear and let k denote the number of points in P that lie on the boundary of the convex hull for P . Then any trianglation of P has 2n-2-k triangles and 3n-3-k edges. Proof : Let T be triangulation of P , and let m denote the # of triangles of T . Each triangle has 3 edges, and the unbounded face has k edges . n f = # of faces of t riangulation = m + 1 every edge is incident to exactly 2 faces . Hence, # of edges n e = (3m +k)/2 . Euler ‘s formula : n - n e + n f = 2 . Substituting values of n e and n f , we obtain: m = 2n – 2 – k and n e = 3n – 3 – k .
76. Angle Vector Let T(P) be a triangulation of P ( set of n points ) . Suppose T(P) has m triangles. Consider the 3m angles of triangles of T(P) , sorted by increasing value . A(T) = { a 1 ..., a 3m } is called angle- vector of T . Triangulations can be sorted in lexicographical order according to A(T). A triangulation T(P) is called angle-optimal if A(T(P)) A(T´(P)) for all triangulations T´ of P .
77. Illegal Edge a 1 ‘ a 2 ‘ a 4 ‘ a 3 ‘ a 5 ‘ a 6 ‘ P k P j P i Edge flip The edge p i p j is illegal if ‘ i Note: Let T be a triangulation with an illegal edge e . Let T´ be the triangulation obtained from T by flipping e . Then, A(T´) A(T) . i Consider a quadrilateral: a 1 a 2 a 6 a 5 a 3 a 4 P j P i
78. Legal Triangulation Definition : A triangulation T(P) is called a legal triangulation , if T(P) does not contain any illegal edges. Test for illegality Lemma : Let edge p i p j be incident to triangles p i p j p k and p i p j p l , and let C be the circle thru p i , p j and p k . The edge p i p j is illegal iff the point p l lies in the interior of C . Furthermore, if the points p i , p j , p k , p l form a convex quadri- lateral and do not lie on a common circle, then exactly one of p i p j or p k p l is an illegal edge. P i P k P j P l
79. Test of Illegality Observation: p l lies inside the circle through p i , p j and p k iff p k lies inside the circle through p i , p j , p l . When all four points lie on circle, both p i p j and p k p l are legal. P i P k P j P l P i P k P j P l
80.
81. Thales Theorem Consider the quadrilateral with p l in the interior of the circle that goes through p i , p j , p k . Claim: The minimum angle does not occur at p k ! (likewise: Minimum angle does not occur at p l ) G oal: Show that p i p j is illegal p i p j p l p k p i p j p l p k
82. W.l.o.g. a 4 minimal Thales Theorem: Proof a 1 ‘ > a 4 a 2 ‘ > a 2 p i p j p k p l a 1 a 2 a 3 a 4 p i p j p k p l a 1 a 2 a 3 a 4 a 1 ‘ a 2 ‘ a 3 ‘ a 4 ‘ p i p j p k p l a 1 ‘ a 2 ‘ a 3 ‘ a 4 ‘
83. Circle criterion violated illegal edge Thales Theorem: Proof a 4 ‘ > a 1 a 3 ‘ > a 3 Hence, min{a i ‘} > min{a i } p i p j p k p l a 1 a 2 a 3 a 4 a 1 ‘ a 2 ‘ a 3 ‘ a 4 ‘
84. Circle Criterion Definition: A triangulation fulfills the circle criterion if and only if the circumcircle of each triangle of the triangulation does not contain any other point in its interior .
85. Theorems Theorem: A triangulation T(P) of a set P of points does not contain an illegal edge if and only if nowhere the circle criterion is violated . Theorem: Every triangulation T(P) of a set P of points can be finally transformed into an angle-optimal triangulation in a finite number of steps.
86. Definition of the Delaunay Triangulation A triangulation T(P) is a Delaunay Triangulation of P, denoted as DT(P), if and only if the circumcircle of any triangle of T does not contain any other point of P in its interior (i.e. T fulfills the circle criterion).
87.
88. Algorithm DT(P) (randomized, incremental) Given: Point set P = {p 1 ..., p n } Initially : Compute triangle (x, y, z) , which includes the points p 1 ..., p n . m z (0,3m) y (3m,0) x (-3m,-3m)
89.
90. Inserting a Point p i p j p r 2 cases : p r is inside a triangle p r is on an edge p i p j p k p r p l p i p j p k p r Legalize (p r ,p i p j ,T): if p i p j is illegal then let p i p j p k be the triangle adjacent to p r p i p j along p i p j . flip p i p j , i.e. replace p i p j by p r p k Legalize (p r , p i p k , T) Legalize (p r , p k p j , T)
91.
92. Correctness Lemma : Every new edge created in the algorithm for constructing DT during the intersection of p r is an edge of the Delaunay graph of { p 1 ,...,p r } . pq is a Delaunay edge iff there is a (empty) circle, which contains only p and q on the circumference . Proof idea : Shrink a circle which was empty before addition of p r !
93. Correctness Observation: After insertion of p r , every new edge produced by edge-flips is incident to p r ! Correctness of the algorithm : Consider newly produced edges: p r p r
94. Edge Flips Edge-flips produce only legal edges. Before inserting p r , circle that goes through p i , p j , p k was empty! Edge- flips produce edges that are always in c ident to p r ! p r p i p j p k
95. Data Structure for Point Location t 1 t 2 t 4 t 5 t 3 t 6 t 7 Split t 1 p i p j p i p k t 1 t 2 t 3 t 2 t 3 t 4 t 5 t 4 t 6 t 7 t 1 t 2 t 3 t 1 t 2 t 3 t 1 t 2 t 4 t 5 t 3 flip p i p j flip p i p k
96. Analysis of the Algorithm Lemma : The expected number of triangles created by the incremental algorithm for constructing DT(P) is atmost 9n + 1 .
97. Analysis of the Runtime Theorem : The Delaunay triangulation of a set of P of n points in the plane can be computed in O(n log n) expected time, using O(n) expected storage. Proof : Running time without Point Location : Proportional to the number of created triangles = O(n). Point Location : The time to locate the point p r in the current triangulation is linear in the number of nodes of D that we visit.
98.
99.
100.
101. Geometry and Air Traffic Control » Avoid collisions at all costs. » Start by f inding the two aeroplanes closest to each other, at specific elevations. » During peak times over 5000 planes, per hour, around Frankfurt airspace.