140 likes | 279 Views
Lecture 1: Introduction. History: Proof-based, a l gorithmic, axiomatic geometry, computational geometry today P roblem fields A n example: Computing the convex hull: the “naive approach” Graham ‘ s Scan Lower bound D esign, a nalysis, and i mplementation of geometrical algorithms.
E N D
Lecture 1: Introduction • History: Proof-based, algorithmic, axiomatic geometry, computational geometry today • Problem fields • An example: Computing the convex hull: • the “naive approach” • Graham‘s Scan • Lower bound • Design, analysis, and implementation of • geometrical algorithms Computational GeometryProf.Dr.Th.Ottmann
p p pq pq q q 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 Convex HullCH(S) is the smallest convex set, which contains S. Computational GeometryProf.Dr.Th.Ottmann
Rubber band experiment 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. Computational GeometryProf.Dr.Th.Ottmann
Polygons A polygon P is a closed, connected sequence of line segments. A polygon is simple, if it does not intersect itself. A simple polygon is convex, if the enclosed area is convex. Computational GeometryProf.Dr.Th.Ottmann
q p Computing the convex hull Right rule: The line segment pq is part of the CH(P) iff all points of P-{p,q} lie to the right of the line through p and q Computational GeometryProf.Dr.Th.Ottmann
E= • for all (p, q) from PxP with p q • valid = true • for all r in P with r p and rq • if r lies to the left of the directed line from p to q • valid = false • if valid then for E = E { pq } • Construct CH(P) as a list of nodes fromE • Run time: O(n³) Naive procedure Input: A set Pof points in the plane Output: Convex Hull CH(P) Computational GeometryProf.Dr.Th.Ottmann
2. Rounding errors due to computer arithmetic (floats). Degenerate cases • Linear dependency: more • points are on a line . Solution: extended definition by cases Solution: symbolic computation, interval arithmetic Computational GeometryProf.Dr.Th.Ottmann
Incremental approach: Given: Upper hull for p1,...,pi-1 Compute: Upper hull for p1,...,pi An incremental algorithm Upper Hull Partitioning of the problem: Lower Hull z X s X X Computational GeometryProf.Dr.Th.Ottmann
Computation of UH (Graham Scan) Computational GeometryProf.Dr.Th.Ottmann
Input/output:see " naive procedure " Fast computation of the convex hull Sort Paccording to x-Coordinates LU={p1, p2 } fori = 3 to n LU = LU { pi } while LU contains more than 2 points and the last 3 points in LU do not make a right turn do delete the middle of last 3 points LL={pn, pn-1 } fori = n-2 to 1 LL = LL { pi } whileLL contains more than 2 points and the last 3 points in LL do not make a right turn do delete the middle of last 3 points delete first and last point in LL CH(P) = LU LL Computational GeometryProf.Dr.Th.Ottmann
Runtime Theorem: The fast algorithm for computing the convex hull (Graham Scan) can be carried out in time O(n log n). Proof: (for UH only) Sorting n points in lexicographic order takes time O(n log n). Execution of the for-loop takes time O(n). Total number of deletions carried out in all executions of the while loop takes time O(n). Total runtime for computing UH is O(n log n) Computational GeometryProf.Dr.Th.Ottmann
Correctness • Proof: for Upper Hull by induction: • {p1, p2 } is a correct UH for a set of 2 points. • (2) Assume: { p1,...,pi } is a correct UH for i points and consider pi+1 pi+1 V pi By induction a too high point may lie only in the slab V. This, however, contradicts the lexicographical order of points! Computational GeometryProf.Dr.Th.Ottmann
Lower bound Reduction of the sorting problem to the computation of the convex hull. 1.x1, ... ,xn (x1, x1²), ... ,(xn,,xn²)O(n) 2. Construct the convex hull for these points 3. Output the points in (counter-)clockwise order x1 x2 ... xn Computational GeometryProf.Dr.Th.Ottmann
1. Design the algorithm and ignore all special cases. 2. Handle all special cases and degeneracies. 3. Implementation: Computing geometrical objects: best possibleDecisions (e.g. comparison operations): suppose exact (correct) results Support: Libraries:LEDA, CGAL Visualizations:VEGA Design, Analysis & Implementation Computational GeometryProf.Dr.Th.Ottmann