Download presentation
Presentation is loading. Please wait.
Published byMagdalene Nichols Modified over 9 years ago
1
An Introduction to Computational Geometry Joseph S. B. Mitchell Stony Brook University
2
Mini-Course Info Joe Mitchell (Math 1-109) Joe Mitchell (Math 1-109) jsbm@ams.sunysb.edu (631-632-8366) jsbm@ams.sunysb.edu (631-632-8366)jsbm@ams.sunysb.edu http://www.ams.sunysb.edu/~jsbm/nasa/tutorial.html http://www.ams.sunysb.edu/~jsbm/nasa/tutorial.html http://www.ams.sunysb.edu/~jsbm/nasa/tutorial.html Recommended Texts: Recommended Texts: Computational Geometry, by Mark de Berg, Marc van Kreveld, Mark Overmars and Otfried Schwartzkopf (2 nd edition)Computational Geometry, by Mark de Berg, Marc van Kreveld, Mark Overmars and Otfried Schwartzkopf (2 nd edition) Computational Geometry in C, by Joe O’Rourke (2 nd Edition)Computational Geometry in C, by Joe O’Rourke (2 nd Edition) Surveys/Reference books: Surveys/Reference books: CRC Handbook of Discrete and Computational Geometry, editted by Goodman and O’Rourke (2 nd edition)CRC Handbook of Discrete and Computational Geometry, editted by Goodman and O’Rourke (2 nd edition) Handbook of Computational Geometry, editted by Sack and UrrutiaHandbook of Computational Geometry, editted by Sack and Urrutia
3
Sessions and Topics Session 1: Session 1: IntroductionIntroduction Convex Hulls in 2D, 3DConvex Hulls in 2D, 3D A variety of algorithmsA variety of algorithms Session 2: Session 2: Searching for intersections: Plane sweepSearching for intersections: Plane sweep Halfspace intersections, low-dimensional linear programming (LP)Halfspace intersections, low-dimensional linear programming (LP) Range SearchRange Search 3
4
Sessions and Topics Session 3: Session 3: TriangulationTriangulation Proximity: Voronoi/Delaunay diagramsProximity: Voronoi/Delaunay diagrams Point location searchPoint location search Session 4: Session 4: ArrangementsArrangements Duality and applicationsDuality and applications Visibility graphs, shortest pathsVisibility graphs, shortest paths 4
5
Sessions and Topics Session 5: Session 5: Spatial partitioning, optimization, load balancingSpatial partitioning, optimization, load balancing Binary Space PartitionsBinary Space Partitions Clustering trajectoriesClustering trajectories Session 6: Session 6: GeoSect: Overview and algorithmsGeoSect: Overview and algorithms 3D partitioning3D partitioning Flow-respecting partitioningFlow-respecting partitioning 5
6
Outline Triangulation Triangulation Proximity: Voronoi/Delaunay Proximity: Voronoi/Delaunay Point location search Point location search 6
7
Input: Set S of n points Input: Set S of n points Input: Other shapes Input: Other shapes 3D: Surfaces and solids (tetrahedralization) 3D: Surfaces and solids (tetrahedralization) Triangulation 7 Triangulation applet for simple polygonsapplet Planar Straight-Line Graph (PSLG) Simple polygon Polygon with holes
8
Triangulation Theory in 2D Thm: A simple polygon has a triangulation. Thm: A simple polygon has a triangulation. Lem: An n-gon with n 4 has a diagonal.Lem: An n-gon with n 4 has a diagonal. Thm: Any triangulation of a simple n-gon has n-3 diagonals, n-2 triangles. Thm: Any triangulation of a simple n-gon has n-3 diagonals, n-2 triangles. Thm: The “dual” graph is a tree. Thm: The “dual” graph is a tree. Thm: An n-gon with n 4 has 2 “ears”. Thm: An n-gon with n 4 has 2 “ears”. Thm: The triangulation graph can be 3-colored. Thm: The triangulation graph can be 3-colored. 8 Proofs: Induction on n. Also with holes But, NOT true in 3D!
9
Triangulating a Simple Polygon Simple “ear-clipping” methods: O(n 2 ) Simple “ear-clipping” methods: O(n 2 ) Cases with simple O(n) algorithms: Cases with simple O(n) algorithms: Convex polygons (trivial!)Convex polygons (trivial!) Monotone polygons, monotone mountainsMonotone polygons, monotone mountains General case (even with holes!): General case (even with holes!): Sweep algorithm to decompose intoSweep algorithm to decompose into monotone mountains O(n log n)O(n log n) Best theoretical results: Best theoretical results: Simple polygons: O(n) [Chazelle’90]Simple polygons: O(n) [Chazelle’90] Polygons with h holes: O(n+h log 1+ h), (n+h log h) [BC]Polygons with h holes: O(n+h log 1+ h), (n+h log h) [BC] Good practical method: FIST [Held], based on clever methods of ear clipping (worst-case O(n 2 ) ) Good practical method: FIST [Held], based on clever methods of ear clipping (worst-case O(n 2 ) ) 9 Not practical! fan
10
FIST: Fast Industrial-Strength Triangulation http://www.cosy.sbg.ac.at/~held/projects/triang/triang.html Constrained Delaunay Simple polygon FIST Works nicely also for highly degenerate and “crazy” polygons 3D cycles Based on ear clipping
11
Ear-Clipping Triangulation Ear-clipping applet Ear-clipping applet Input: Simple polygon P v i-1 v i+1 pq is a diagonal, cutting off a single triangle (the “ear”) Naive: O(n 3 ) Smarter: Keep track of “ear tip status” of each v i (initialize: O(n 2 ) ) Each ear clip requires O(1) ear tip tests ( @ O(n) per test ) Thus, O(n 2 ) total, worst-case vivi
12
Ear clipping is easy! Ear clipping is easy! Testing if v i-1 v i+1 is a diagonal takes only O(1) timeTesting if v i-1 v i+1 is a diagonal takes only O(1) time Triangulating a Monotone Mountain in O(n) 12 v i-1 v i+1 vivi monotone Just traverse vertices from top to bottom. Test/clip ears. If an ear is clipped, re-test the earity of the upper endpoint (v i-1 ) of the diagonal just clipped. v i is ear tip iff Left(v i+1, v i, v i-1 )
13
Triangulation in O(n log n) (1) Plane sweep to get horizontal trapezoidalization (1) Plane sweep to get horizontal trapezoidalization 13 L SLS: left-to-right ordering of segments crossed by L (balanced binary tree) Events: L hits a vertex Time: O(n log n) Fire bullets left/right from each vertex
14
Triangulation in O(n log n) (2) Join top vertex to bottom vertex in each trapezoid (2) Join top vertex to bottom vertex in each trapezoid 14 Lemma: Resulting pieces are monotone mountains
15
Triangulation in O(n log n) (3) Triangulate each monotone mountain (3) Triangulate each monotone mountain 15 Triangulate each, in time O(n i ), for total time O(n) Summary: O(n log n) to triangulate n points or a planar straight-line graph (PSLG)
16
Triangulation Sweep gives O(n log n) for triangulating PSLGs Sweep gives O(n log n) for triangulating PSLGs Best theoretical results: Best theoretical results: Simple polygons: O(n) [Chazelle’90]Simple polygons: O(n) [Chazelle’90] Polygons with h holes: O(n+h log 1+ h), (n+h log h) [BC]Polygons with h holes: O(n+h log 1+ h), (n+h log h) [BC] Good practical method: FIST [Held], based on clever methods of ear clipping (worst-case O(n 2 ) ) Good practical method: FIST [Held], based on clever methods of ear clipping (worst-case O(n 2 ) ) 3D decompositions (into tetrahedra, etc) are much harder! 3D decompositions (into tetrahedra, etc) are much harder! NP-complete to decide if it is even possible (without adding Steiner points); may need (r 2 ) Steiner pointsNP-complete to decide if it is even possible (without adding Steiner points); may need (r 2 ) Steiner points Huge field of quality mesh generation Huge field of quality mesh generation Important special class of triangulations: Delaunay (next!) Important special class of triangulations: Delaunay (next!) 16 See J. Shewchuk webpagewebpage r= # reflex edges
17
Outline Triangulation Triangulation Proximity: Voronoi/Delaunay Proximity: Voronoi/Delaunay Point location search Point location search 17
18
Voronoi Diagrams Georgy Voronoi 1868-1908
19
Historical Origins and Diagrams in Nature 19 René Descartes 1596-1650 1644: Gravitational Influence of stars Dragonfly wing Honeycomb Constrained soap bubbles Giraffe pigmentation Ack: Streinu&Brock
20
Post Office Problem Post offices Query point Starbucks
21
Voronoi Diagram Partition the plane according to the equivalence classes: V(Q) = { (x,y) : the closest sites of S to (x,y) is exactly the set Q S } |Q| = 1 Voronoi cells (2-faces)|Q| = 1 Voronoi cells (2-faces) |Q| = 2 Voronoi edges (1-faces)|Q| = 2 Voronoi edges (1-faces) |Q| 3 Voronoi vertices (0-faces)|Q| 3 Voronoi vertices (0-faces) 21 Q cocircular
22
Example 22 Voronoi cell of p p p
23
Join p i to p j iff there is an “empty circle” through p i and p j Equivalent definition: “Dual” of the Voronoi diagram Equivalent definition: “Dual” of the Voronoi diagram Applet [Chew] Applet [Chew] Applet Delaunay Diagram 23 pipi pjpj A witness to the Delaunayhood of (p i, p j ) If no 4 points cocircular (degenerate), then Delaunay diagram is a (very special) triangulation.
24
Voronoi and Delaunay Properties The planar dual of Voronoi, drawn with nodes at the sites, edges straight segments, has no crossing edges [Delaunay]. It is the Delaunay diagram, D(S) (defined by empty circle property). The planar dual of Voronoi, drawn with nodes at the sites, edges straight segments, has no crossing edges [Delaunay]. It is the Delaunay diagram, D(S) (defined by empty circle property). Combinatorial size: 2n-5 Voronoi/Delaunay edges; 3n-6 Voronoi vertices (Delaunay faces) O(n) Combinatorial size: 2n-5 Voronoi/Delaunay edges; 3n-6 Voronoi vertices (Delaunay faces) O(n) A Voronoi cell is unbounded iff its site is on the boundary of CH(S) A Voronoi cell is unbounded iff its site is on the boundary of CH(S) CH(S) = boundary of unbounded face of D(S) CH(S) = boundary of unbounded face of D(S) Delaunay triangulation lexico-maximizes the angle vector among all triangulations Delaunay triangulation lexico-maximizes the angle vector among all triangulations In particular, maximizes the min angleIn particular, maximizes the min angle 24
25
Voronoi and Delaunay Properties In any partition of S, S=B R, into blue/red points, any blue-red pair that is shortest B-R bridge is a Delaunay edge. In any partition of S, S=B R, into blue/red points, any blue-red pair that is shortest B-R bridge is a Delaunay edge. D(S) is connectedD(S) is connected MST D(S) (MST=“min spanning tree”)MST D(S) (MST=“min spanning tree”) NNG D(S) (NNG=“nearest neighbor graph”)NNG D(S) (NNG=“nearest neighbor graph”) Voronoi/Delaunay can be built in time O(n log n) Voronoi/Delaunay can be built in time O(n log n) Divide and conquerDivide and conquer SweepSweep Randomized incrementalRandomized incremental VoroGlide applet VoroGlide appletapplet 25
26
Delaunay: Edge Flip Algorithm Assume: No 4 co-circular points, for simplicity. Assume: No 4 co-circular points, for simplicity. Start with any triangulation Start with any triangulation Keep a list (stack) of “illegal” edges: Keep a list (stack) of “illegal” edges: ab is illegal if InCircle(a,c,b,d)ab is illegal if InCircle(a,c,b,d) iff the smallest of the 6 angles goes up if flipiff the smallest of the 6 angles goes up if flip Flip any illegal edge; update legality status of neighboring edges Flip any illegal edge; update legality status of neighboring edges Continue until no illegal edges Continue until no illegal edges Theorem: A triangulation is Delaunay iff there are no illegal edges (i.e., it is “locally Delaunay”) Theorem: A triangulation is Delaunay iff there are no illegal edges (i.e., it is “locally Delaunay”) Only O(n 2 ) flips needed. Only O(n 2 ) flips needed. 26 Lawson Edge Swap “Legalize” [BKOS] a b c d Locally non-Delauany
27
Connection to Convex Hulls in 3D Delaunay diagram lower convex hull of the lifted sites, (x i, y i, x i 2 +y i 2 ), on the parabaloid of revolution, z=x 2 + y 2 Delaunay diagram lower convex hull of the lifted sites, (x i, y i, x i 2 +y i 2 ), on the parabaloid of revolution, z=x 2 + y 2 Upper hull “furthest site Delaunay” Upper hull “furthest site Delaunay” 3D CH applet 3D CH appletapplet 27
28
Voronoi and Delaunay Algorithms: Algorithms: Divide and conquer (first O(n log n))Divide and conquer (first O(n log n)) SweepSweep Randomized incrementalRandomized incremental Any algorithm that computes CH in R 3, e.g., QHullAny algorithm that computes CH in R 3, e.g., QHull 28 Qhull websitewebsite
29
29 Fortune’s Sweep Algorithm Ack: Guibas&Stolfi Applet
30
30 Parabolic Front Ack: Guibas&Stolfi Applet
31
31 Site Events a)b)c) Ack: Guibas&Stolfi Applet
32
32 Circle Events Ack: Guibas&Stolfi Applet
33
33 Scheduling Circle Events Ack: Guibas&Stolfi Applet
34
Incremental Construction Add sites one by one, modifying the Delaunay (Voronoi) as we go: Add sites one by one, modifying the Delaunay (Voronoi) as we go: Join v i to 3 corners of triangle containing itJoin v i to 3 corners of triangle containing it Do edge flips to restore local DelaunayhoodDo edge flips to restore local Delaunayhood If added in random order, simple “Backwards analysis” shows expected time O(n log n) [Guibas, Knuth, Sharir] If added in random order, simple “Backwards analysis” shows expected time O(n log n) [Guibas, Knuth, Sharir] Applet (Shows Voronoi and Delaunay and empty circles) Applet (Shows Voronoi and Delaunay and empty circles) Applet 34
35
Example CS691G Computational Geometry - UMass Amherst 35
36
Voronoi Extensions Numerous ! [see Okabe, Boots, Sugihara, Chiu] Numerous ! [see Okabe, Boots, Sugihara, Chiu] Different metrics Different metrics Higher dimensions: Higher dimensions: Delaunay in R d lower CH in R d+1Delaunay in R d lower CH in R d+1 O( n log n + n (d+1)/2 )O( n log n + n (d+1)/2 ) Order-k Order-k Other sites: Voronoi of polygons, “medial axis” Other sites: Voronoi of polygons, “medial axis” Additive/multiplicative weights; power diagram Additive/multiplicative weights; power diagram -shapes: a powerful shape representation -shapes: a powerful shape representation 36 GeoMagicGeoMagic, biogeometry at Dukebiogeometry at Duke
37
37 VRONI: Fast, robust Voronoi of polygonal domains Incremental algorithm
38
38
39
39 Computing offsets with a Voronoi diagram
40
Alpha Shapes, Hulls 40 “Erase” with a ball of radius to get -shape. Straighten edges to get -hull
41
41
42
Applet -Shapes Theorem: For each Delaunay edge, e=(p i,p j ), there exists min (e)>0 and max (e)>0 such that e -shape of S iff min (e) max (e). Theorem: For each Delaunay edge, e=(p i,p j ), there exists min (e)>0 and max (e)>0 such that e -shape of S iff min (e) max (e). Thus, every alpha-hull edge is in the Delaunay, and every Delaunay edge is in some alpha-shape. Thus, every alpha-hull edge is in the Delaunay, and every Delaunay edge is in some alpha-shape.
44
Application of Triangulation: Guarding a Polygon Sensor placement, “guarding” Sensor placement, “guarding” Determine a small set of “guards” that see all of a given polygon P Determine a small set of “guards” that see all of a given polygon P
45
Art Gallery Theorem For a simple n-gon, guards are always sufficient and sometimes necessary. For a simple n-gon, guards are always sufficient and sometimes necessary. Fisk proof that n/3 guards Fisk proof that n/3 guards are enough (even can use vertex guards) TriangulateTriangulate 3-color the triangulation3-color the triangulation Put guards at vertices of the smallest color classPut guards at vertices of the smallest color class 45 Chvatal comb: n/3 guards are necessary [Klee; Chvatal; Fisk]
46
Vertex Guarding a Simple Polygon Vertex guarding applet Vertex guarding applet Vertex guarding applet Vertex guarding applet
47
Outline Triangulation Triangulation Proximity: Voronoi/Delaunay Proximity: Voronoi/Delaunay Point location search Point location search 47
48
Point Location Point-in-polygon test: Is point q inside simple polygon P ? Point-in-polygon test: Is point q inside simple polygon P ? P n-gon q Naïve: O(n) per test CG: O(log n) 5 crossings q inside
49
Point Location More generally: Search for which face of a planar map contains query point q More generally: Search for which face of a planar map contains query point q Example: Map of Manhattan Applet Example: Map of Manhattan AppletApplet 49 Trapezoid under the mouse is highlighted q
50
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 50 One Method: Partition the Plane into Slabs Query time : O(log n) binary search in x and then binary search in y direction. Storage space O(n 2 ) n/2
51
An Optimal Method: Kirkpatrick Hierarchical Triangulation Begin with full triangulation Begin with full triangulation Remove a “large” set of low-degree ( 9) vertices that are independent Remove a “large” set of low-degree ( 9) vertices that are independent (such a set always exists in a planar graph, by Euler) Retriangulate the resulting “holes” Retriangulate the resulting “holes” Repeat until only the big outer triangle remains Repeat until only the big outer triangle remains Build DAG for searching Build DAG for searching (no two adjacent) O(n) “large” : Cn only O(log n) iterations
52
Kirkpatrick Example Full triangulation, T 0 Triangles in T 0
53
53 T1T1 T2T2
54
54 T3T3 T4T4 T5T5 Final DAG hierarchy and search path for query point p
55
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 55 Better: Partitioning into Trapezoids Assumption : Segments are in “general position“ Observation : Every vertical edge has one point in common with a segment end. R
56
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 56 Observations R f f is convex f is bounded Every non - vertical side of f is part of a segment of S or an edge of R
57
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 57 Trapezoidal Decomposition Lemma : Each face in a trapezoidal map of a set S of line segments in general position has 1 or 2 vertical sides and exactly two non-vertical sides
58
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 58 Left Edge of a Trapezoid R For every trapezoid Δ T(S), except the left most one, the left vertical edge of Δ is defined by a segment endpoint p, denoted by leftp(Δ).
59
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 59 The 5 Cases: Left Edges of a Trapezoid a)top( ) bottom( ) leftp( ) b) leftp( ) top( ) d) leftp( ) top( ) c) leftp( ) top( ) bottom( ) e) It is left edge of R. This case occurs for a single trapezoid of T(S) only, namely the unique leftmost trapezoid of T(S)
60
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 60 Size of the Trapezoidal Map Theorem: The trapezoidal map T(S) of a set of n line segments in general position contains at most 6n + 4 vertices and at most 3n + 1 trapezoids. Proof (1):A vertex of T(S) is either - a vertex of R or 4 - an endpoint of a segment in S or 2n - a point where the vertical extension starting in an endpoint abuts on another segment or on the boundary R. 2 * (2n) 6n + 4
61
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 61 Size of the Trapezoidal Map Theorem: The trapezoidal map T(S) of a set of n line segments in general position contains at most 6n + 4 vertices and at most 3n + 1 trapezoids. Proof (2):Each trapezoid has a unique point leftp( ), which is - the lower left corner of R - the left endpoint of a segment (can be leftp( ) of at most two different trapezoids) - the right endpoint of a segment (can be leftp( ) of atmost one trapezoid) 1 2n n 3n + 1
62
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 62 Adjacent Trapezoids Two trapezoids and ´ are adjacent if they meet along a vertical edge. 11 22 33 44 55 11 22 33 44 55 66 1)Segments in general position : A trapezoid has atmost four adjacent trapezoids 2) Segments not in general position : A trapezoid can have an arbitrary number of adjacent trapezoids.
63
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 63 Vertical Neighbours: Upper, Lower Left Trapezoid ' is (vertical) neighbor of top( ) = top( ’) or bottom( ) = bottom( ’) In the first case ´ is upper left neighbor of , in the second case ´ is lower left neighbor of .
64
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 64 Representing Trapezoidal Maps There are records for all line segments and endpoints of S, the structure contains records for trapezoids of T(S), but not for vertices or edges of T(S). The record for trapezoid stores pointers to top( ), and bottom( ), pointers to leftp( ) and rightp( ) and finally pointers to its atmost 4 neighbors. is uniquely defined by top( ), bottom( ), leftp( ) and rightp( ).
65
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 65 Search Structure: DAG A B C D F E G 1l 1r 2l 2r A B C D E F G 1l 1r 2r 2l 1 2 2 End points decide between left, right Segments decide between below, above 1 2
66
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 66 A Randomized Incremental Algorithm Input : A set S of n non-crossing line segments Output : The trapezoidal map T(S) and a search structure D(S) for T(S) in a bounding box. Determine a bounding box R, initialize T and D Compute a random permutation s 1,s 2,..., s n of the elements of S for i = 1 to n do add s i and change T(S i - 1 ) into T(S i ) and D(S i -1 ) into D(S i ) Invariant : In the step i T(S i ) is correct trapezoidal map of S i and D(S i ) is an associated search structure.
67
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 67 A Randomized Incremental Algorithm Input : A set of n non-crossing line segments Output : The trapezoidal map T(S) and a search structure D for T(S) in a bounding box. Determine a bounding box R, initialize T and D Compute a random permutation s 1,s 2,..., s n of the elements of S for i = 1 to n do Find the set 0, 1,..., k of trapezoids in T properly intersected by s i. Remove 0, 1,..., k from T and replace them by new trapezoids that appear because of the intersection of s i. Remove the leaves for 0, 1,..., k from D and create leaves for the new Trapezoids. Link the new leaves to the existing inner nodes by adding some new inner nodes.
68
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 68 Questions How can we find the intersecting trapezoids? How can T and D be updated a) if new segment intersects no previous trapezoid ? b) if new segment intersects previous trapezoids ?
69
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 69 Finding the Intersecting Trapezoids 00 sisi 11 22 33 j+1 is lower right neighbour of j In T(S i ) exactly those trapezoids are changed, which are intersected by s i if rightp( j ) lies above s i then Let j+1 be the lower right neighbor of j. else Let j+1 be the upper right neighbor of j Clue : 0 can be found by a query in the search structure D(S i -1 ) constructed in iteration stage i -1.
70
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 70 New Segment Completely Contained in Trapezoid Decomposition t p q s T(S i-1 ) A C B D T(S i ) Search structure D(S i-1 ) t A B CD p q s 4 new trapezoids, -1 old trapezoid, search depth + 3
71
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 71 New Segment Intersects Previous Ones Decomposition p q t0t0 t1t1 t2t2 t3t3 s T(S i - 1 ) t0t0 t1t1 t2t2 t3t3 D(S i - 1 ) Search structure F A B C E D T(S i ) D(S i ) A B C D E F sss q s 6 new trapezoids, – 4 old, depth + 2
72
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 72 Estimation of the Depth of the Search Structure Let S be a set of n segments in general position, q be an arbitrary fixed query point. Depth of D(S): worst case : 3n, average case : O(log n) Consider the path traversed by the query for q in D Let X i = # of nodes on the search path for q created in iteration step i. X i <= 3 P i = probability that there exists node on the search path for q that is created in iteration step i. E[X i ] <= 3 P i
73
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 73 Observation Iteration step i contributes a node to the search path for q exactly if q (S i - 1 ), the trapezoid containing q in T(S i - 1 ), is not the same as q (S i ), the trapezoid containing q in T(S i ) P i = Pr[ q (S i ) q (S i - 1 )]. If q (S i ) is not same as q (S i - 1 ), then q (S i ) must be one of the trapezoids created in iteration i. q (S i ) does not depend on the order in which the segments in S i have been inserted. Backwards analysis : We consider T(S i ) and look at the probability that q (S i ) disappears from the trapezoidal map when we remove the segment s i. q (S i ) disappears if and only if one of top( q (S i )), bottom( q (S i )), leftp( q (S i )), or right( q (S i )) disappears with removal of s i.
74
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 74 Observation Prob[top( q (S i ))] = Prob[bottom( q (S i ))] = 1/i. Prob[leftp( q (S i ))] disappears is at most 1/i. Prob[rightp( q (S i ))] disappears is at most 1/i. P i = Pr[ q (S i ) q (S i - 1 )] = Pr[ q (S i ) T(S i - 1 )] 4/i
75
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 75 Analysis: Size of Search Structure Leaves in D are in one – to – one correspondence with the trapezoids in , of which there are O(n). The total number of nodes is bounded by : (# of inner nodes created in iteration step i) The worst case upper bound on the size of the structure
76
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 76 Analysis: Size of Search Structure Theorem: The expected number of nodes of D is O(n). Proof: The # of leaves is in O(n). Consider the internal nodes: X i = # of internal nodes created in iteration step i if disappears from T(S i ) when s is removed from S i otherwise There are at most four segments that cause a given trapezoid to disappear
77
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 77 Analysis: Size of Search Structure The expected number of newly created trapezoids is O(1) in every iteration of the algorithm, from which the O(n) bound on the expected amount of storage follows.
78
Computational Geometry, WS 2007/08 Prof. Dr. Thomas Ottmann 78 Summary Let S be a planar subdivision with n edges. In O(n log n) expected time one can construct a data structure that uses O(n) expected storage, such that for any query point q, the expected time for a point location query is O(log n).
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.