Lehrstuhl fu r Informatik I Algorithmische Geometrie Wintersemester 2013/14 Vorlesung: U bung: Alexander Wolff (E29) Philipp Kindermann (E12) Konvexe Hu lle oder Mischungsverha ltnisse 1. Vorlesung Prof. Dr. Alexander Wolff Lehrstuhl fu r Informatik I
In eigener Sache Eindhoven Würzburg Karlsruhe Stuttgart Freiburg Konstanz Greifswald Berlin Alexander Wolff Email: vorname.nachname @uni-wuerzburg.de Sprechstunde: mittwochs, 13 14 h Büro: Ehem. Mathebau E29 Forschungsgebiete: Graphenzeichnen Alg. Geometrie Alg. für GIS Alg. Graphentheorie
Algorithmische Geometrie Lernziele: Am Ende dieser Veranstaltung können Sie... entscheiden, mit welchen Algorithmen man ein gegebenes grundlegendes geometrisches Problem lösen kann, neue Probleme analysieren und dafür mit den Konzepten der Veranstaltung eigene effiziente Lösungen finden Voraussetzung: Algorithmen & Datenstrukturen Algorithmische Graphentheorie (o.ä.) Anforderungen: 50% der Übungspunkte 50% der Übungspunkte nach Neujahr 0% Plagiate mündliche Prüfung Meine Vision: hands-on interaktiv
Literatur M. de Berg, O. Cheong, M. van Kreveld, M. Overmars: Computational Geometry: Algorithms and Applications Springer, 3. Auflage, 2008 Rolf Klein: Algorithmische Geometrie: Grundlagen, Methoden, Anwendungen. Springer, 2. Auflage, 2005
Werbung Andere Master-Veranstaltungen des LS I in diesem Semester: Vorlesung: Approximationsalgorithmen Joachim Spoerhase, VL: Do 10 12, SE I Seminar: Visualisierung von Graphen AW & Martin Fink, Di 14 16, SE 37
Chapter 1 Mixing Things or: Convex Hull Alexander Wolff Computational Geometry WS 2013
Mixing Things Given... subst. fract. A fract. B s 1 10 % 35 % s 2 20 % 5 % s 3 40 % 25 % can subst. we mix fract. A fract. B q 1 25 % 28 % q 2 15 % 18 % using s 1, s 2, s 3? B.4.3.2.1 s 1 q 2 s 2 q 1.1.2.3.4 Observe: Given a set S R 2 of substances, we can mix a substance q R 2 d using the substances in S q CH(S). d s 3 A
Formally... Given S R 2, how do we define the convex hull CH(S)? Physics approach: take (large enough) elastic rope stretch and let go take area inside (and on) the rope Math approach: define convex define CH(S) = C S : C convex C
Towards Computation CH(S) = def C Problem with math approach: C S : C convex This set is HUGE! Maybe we can do with a little less? Claim: CH(S) = H = H S : H closed halfplane H S : H cl. halfplane, H S 2 H
Computer Science Approach Input: set S of n points in the plane, that is, S R 2 p q pq Output: list of vertices of CH(S) in clockwise order Observation. (p, q) is an edge of CH(S) each point in S lies strictly to the right of the directed line pq or on the line segment pq
Finally, an Algorithm FirstConvexHull(S) E foreach (p, q) S S with p q do valid true foreach r S do if not (r strictly right of pq or r pq) then valid false if valid then E E {(p, q)} from E construct sorted list L of vertices of CH(S) return L r strictly right of pq x r y r 1 x p y p 1 x q y q 1 < 0 Important: Test takes O(1) time!
Running Time Analysis FirstConvexHull(S) E foreach (p, q) S S with p q do (n 2 n) valid true foreach r S do if not (r strictly right of pq or r pq) then valid false Θ(1) Θ(n) Θ(n 3 ) if valid then E E {(p, q)} from E construct sorted list L of vertices of CH(S) return L Lemma. We can compute the convex hull of n pts in the plane in Θ(n 3 ) time. O(n 2 )
Discussion if not (r strictly right of pq or r pq) then valid false q E q E r Test may return wrong answer (floating pt arithmetic!): r right of pq :-( r p not right of rq q not right of pr p p Observation. Algorithm FirstConvexHull is not robust.
New Ideas upper convex hull split computation in two bring pts in lexicographic order proceed incrementally lower convex hull UpperConvexHull(S: set of pts in the plane) p 1, p 2,..., p n sort S lexicographically L p 1, p 2 for i 3 to n do L.append(p i ) while L > 2 and last 3 pts in L do not make right turn do remove second last pt from L return L // compute upper convex hull of {p 1, p 2,..., p i }
Running Time Analysis UpperConvexHull(S: set of pts in the plane) p 1, p 2,..., p n sort S lexicographically O(n log n) L p 1, p 2 for i 3 to n do (n 2) L.append(p i ) (n)? while L > 2 and last 3 pts in L do not make right turn do remove second last pt from L return L Amortized analysis: each pt p 2,..., p n 1 pays 1 $ for its potential removal later on this pays for the total effort of all executions of the while loop Theorem. We can compute the convex hull of n pts in the plane in O(n log n) time in a robust way.
Output-Sensitive Algorithms Jarvis gift-wrapping algorithm O(n h) Chan s exponential search O(n log h)... where h = CH(S) = size of the output