introduction to computational geometry
play

Introduction to Computational Geometry Partha P. Goswami ( - PowerPoint PPT Presentation

Introduction Area Inclusion Line Hull Art Gallery Introduction to Computational Geometry Partha P. Goswami ( ppg.rpe@caluniv.ac.in ) Institute of Radiophysics and Electronics University of Calcutta 92, APC Road, Kolkata - 700009, West


  1. Introduction Area Inclusion Line Hull Art Gallery Point Inclusion Another technique: Ray Shooting Shoot a ray and count the number of crossings with edges of P . If it is odd, then q ∈ P . If q P it is even, then q �∈ P . Some q degenerate cases need to be handled. Time taken is O ( n ).

  2. Introduction Area Inclusion Line Hull Art Gallery Outline Introduction 1 Area Computation of a Simple Polygon 2 Point Inclusion in a Simple Polygon 3 Line Segment Intersection: An application of plane sweep 4 paradigm Convex Hull: An application of incremental algorithm 5 Art Gallery Problem: A study of combinatorial geometry 6

  3. Introduction Area Inclusion Line Hull Art Gallery Line Segment Intersection Input A set of line segments L in general position in the plane. |L| = n .

  4. Introduction Area Inclusion Line Hull Art Gallery Line Segment Intersection Input A set of line segments L in general position in the plane. |L| = n . Output Report the intersections.

  5. Introduction Area Inclusion Line Hull Art Gallery Line Segment Intersection Input A set of line segments L in general position in the plane. |L| = n . Output Report the intersections. Output Sensitive Algorithm Number of intersections might � n � = O ( n 2 ). So, vary from 0 to 2 the lower bound of the problem is Ω( n 2 ). The idea is now to look for an output sensitive algorithm.

  6. Introduction Area Inclusion Line Hull Art Gallery An Output Sensitive Algorithm The idea Avoid testing pairs of segments that are far apart.

  7. Introduction Area Inclusion Line Hull Art Gallery An Output Sensitive Algorithm The idea Avoid testing pairs of segments that are far apart. To find such pairs, imagine sweeping a horizontal line ℓ downwards from above all segments.

  8. Introduction Area Inclusion Line Hull Art Gallery An Output Sensitive Algorithm The idea Avoid testing pairs of segments that are far apart. To find such pairs, imagine sweeping a horizontal line ℓ downwards from above all segments. Keep track of all segments that intersect ℓ .

  9. Introduction Area Inclusion Line Hull Art Gallery An Output Sensitive Algorithm The idea Avoid testing pairs of segments that are far apart. To find such pairs, imagine sweeping a horizontal line ℓ downwards from above all segments. Keep track of all segments that intersect ℓ . ℓ is the sweep line and the algorithm paradigm is plane sweep.

  10. Introduction Area Inclusion Line Hull Art Gallery An Output Sensitive Algorithm The idea Avoid testing pairs of segments that are far apart. To find such pairs, imagine sweeping a horizontal line ℓ downwards from above all segments. Keep track of all segments that intersect ℓ . ℓ is the sweep line and the algorithm paradigm is plane sweep. The status of the sweep line is the line segments intersecting it.

  11. Introduction Area Inclusion Line Hull Art Gallery An Output Sensitive Algorithm The idea Avoid testing pairs of segments that are far apart. To find such pairs, imagine sweeping a horizontal line ℓ downwards from above all segments. Keep track of all segments that intersect ℓ . ℓ is the sweep line and the algorithm paradigm is plane sweep. The status of the sweep line is the line segments intersecting it. Only at particular points known as event points, the status needs to be updated.

  12. Introduction Area Inclusion Line Hull Art Gallery Event Points and Sweep Line Status Event Points and the Event Queue The start and end points of each line segment. They are static.

  13. Introduction Area Inclusion Line Hull Art Gallery Event Points and Sweep Line Status Event Points and the Event Queue The start and end points of each line segment. They are static. The intersection points. They are dynamic and are generated as the sweep line ℓ sweeps down.

  14. Introduction Area Inclusion Line Hull Art Gallery Event Points and Sweep Line Status Event Points and the Event Queue The start and end points of each line segment. They are static. The intersection points. They are dynamic and are generated as the sweep line ℓ sweeps down. The event points are to be arranged in a data structure in a way in which the sweep line sees them.

  15. Introduction Area Inclusion Line Hull Art Gallery Event Points and Sweep Line Status Event Points and the Event Queue The start and end points of each line segment. They are static. The intersection points. They are dynamic and are generated as the sweep line ℓ sweeps down. The event points are to be arranged in a data structure in a way in which the sweep line sees them. The data structure should support extracting the minimum y -coordinate, insertion and deletion.

  16. Introduction Area Inclusion Line Hull Art Gallery Event Points and Sweep Line Status Event Points and the Event Queue The start and end points of each line segment. They are static. The intersection points. They are dynamic and are generated as the sweep line ℓ sweeps down. The event points are to be arranged in a data structure in a way in which the sweep line sees them. The data structure should support extracting the minimum y -coordinate, insertion and deletion. A heap or a balanced binary search tree can support these operations in O (log n ) time.

  17. Introduction Area Inclusion Line Hull Art Gallery Event Points and Sweep Line Status Sweep Line Status We need to store the left to right order in which the line segments intersect ℓ . This data structure has to be dynamic.

  18. Introduction Area Inclusion Line Hull Art Gallery Event Points and Sweep Line Status Sweep Line Status We need to store the left to right order in which the line segments intersect ℓ . This data structure has to be dynamic. A line segment might come in (insertion) or go off (deletion) the sweep line. We need to search for its position.

  19. Introduction Area Inclusion Line Hull Art Gallery Event Points and Sweep Line Status Sweep Line Status We need to store the left to right order in which the line segments intersect ℓ . This data structure has to be dynamic. A line segment might come in (insertion) or go off (deletion) the sweep line. We need to search for its position. A balanced binary search tree can support these operations in O (log n ) time.

  20. Introduction Area Inclusion Line Hull Art Gallery Event Points and Sweep Line Status Sweep Line Status The sweep line status changes during three events: start and end points and intersection points and nowhere else.

  21. Introduction Area Inclusion Line Hull Art Gallery Event Points and Sweep Line Status Sweep Line Status The sweep line status changes during three events: start and end points and intersection points and nowhere else. s i and s j are two segments intersecting at p .

  22. Introduction Area Inclusion Line Hull Art Gallery Event Points and Sweep Line Status Sweep Line Status The sweep line status changes during three events: start and end points and intersection points and nowhere else. s i and s j are two segments intersecting at p . There is an event point above p where s i and s j are adjacent and are tested for intersection. So, no intersection point is ever missed.

  23. Introduction Area Inclusion Line Hull Art Gallery The Algorithm Algorithm Create a heap H with the y -coordinates of end points of L . Create sweep status data structure T on x -coordinates of the points. Initially T is empty.

  24. Introduction Area Inclusion Line Hull Art Gallery The Algorithm Algorithm Create a heap H with the y -coordinates of end points of L . Create sweep status data structure T on x -coordinates of the points. Initially T is empty. Keep on extracting points from H till it is non-empty.

  25. Introduction Area Inclusion Line Hull Art Gallery The Algorithm Algorithm Create a heap H with the y -coordinates of end points of L . Create sweep status data structure T on x -coordinates of the points. Initially T is empty. Keep on extracting points from H till it is non-empty. Based on the three cases: segment top end point, segment bottom end point and intersection point, we take necessary actions.

  26. Introduction Area Inclusion Line Hull Art Gallery The Algorithm Algorithm [Top end point] Insert the line segment into T based on x -coordinates.

  27. Introduction Area Inclusion Line Hull Art Gallery The Algorithm Algorithm [Top end point] Insert the line segment into T based on x -coordinates. Test for intersections with line segmentes to the left and right. Insert intersection point, if any, into H .

  28. Introduction Area Inclusion Line Hull Art Gallery The Algorithm Algorithm [Top end point] Insert the line segment into T based on x -coordinates. Test for intersections with line segmentes to the left and right. Insert intersection point, if any, into H . [Bottom end point] Delete this line segment from T . Test for intersections between preceding and succeeding entries in T .

  29. Introduction Area Inclusion Line Hull Art Gallery The Algorithm Algorithm [Top end point] Insert the line segment into T based on x -coordinates. Test for intersections with line segmentes to the left and right. Insert intersection point, if any, into H . [Bottom end point] Delete this line segment from T . Test for intersections between preceding and succeeding entries in T . [Intersection point] Swap the line segments’ status in T . Check for intersections of preceding and succeeding entries.

  30. Introduction Area Inclusion Line Hull Art Gallery The Analysis Analysis The heap H grows to a size at most 2 n + I where I is the number of intersections. Each operation takes O (log(2 n + I )). As I ≤ n 2 , so O (log(2 n + I )) = O (log n ).

  31. Introduction Area Inclusion Line Hull Art Gallery The Analysis Analysis The heap H grows to a size at most 2 n + I where I is the number of intersections. Each operation takes O (log(2 n + I )). As I ≤ n 2 , so O (log(2 n + I )) = O (log n ). The balanced binary search tree T grows to a size at most n . So, each operation takes O (log n ).

  32. Introduction Area Inclusion Line Hull Art Gallery The Analysis Analysis The heap H grows to a size at most 2 n + I where I is the number of intersections. Each operation takes O (log(2 n + I )). As I ≤ n 2 , so O (log(2 n + I )) = O (log n ). The balanced binary search tree T grows to a size at most n . So, each operation takes O (log n ). So, the total time taken is O ((2 n + I ) log n ) = O ( n log n + I log n ).

  33. Introduction Area Inclusion Line Hull Art Gallery Outline Introduction 1 Area Computation of a Simple Polygon 2 Point Inclusion in a Simple Polygon 3 Line Segment Intersection: An application of plane sweep 4 paradigm Convex Hull: An application of incremental algorithm 5 Art Gallery Problem: A study of combinatorial geometry 6

  34. Introduction Area Inclusion Line Hull Art Gallery Definitions Definition A set S ⊂ R 2 is convex If for any two points p , q ∈ S , pq ∈ S .

  35. Introduction Area Inclusion Line Hull Art Gallery Definitions Definition A set S ⊂ R 2 is convex If for any two points p , q ∈ S , pq ∈ S . p p pq pq q q convex not convex

  36. Introduction Area Inclusion Line Hull Art Gallery Definitions Definition A set S ⊂ R 2 is convex If for any two points p , q ∈ S , pq ∈ S . Definition Let P be a set of points in R 2 . Convex hull of P , denoted by CH ( P ), is the smallest convex set containing P .

  37. Introduction Area Inclusion Line Hull Art Gallery Definitions Definition A set S ⊂ R 2 is convex If for any two points p , q ∈ S , pq ∈ S . Definition Let P be a set of points in R 2 . Convex hull of P , denoted by CH ( P ), is the smallest convex set containing P .

  38. Introduction Area Inclusion Line Hull Art Gallery Definitions Definition A set S ⊂ R 2 is convex If for any two points p , q ∈ S , pq ∈ S . Definition Let P be a set of points in R 2 . Convex hull of P , denoted by CH ( P ), is the smallest convex set containing P .

  39. Introduction Area Inclusion Line Hull Art Gallery Definitions Definition A set S ⊂ R 2 is convex If for any Hull edge two points p , q ∈ S , pq ∈ S . Hull vertex Definition Let P be a set of points in R 2 . Convex hull of P , denoted by CH ( P ), is the smallest convex set containing P .

  40. Introduction Area Inclusion Line Hull Art Gallery Convex Hull Problem Problem Given a set of points P in the plane, compute the convex hull CH ( P ) of the set P .

  41. Introduction Area Inclusion Line Hull Art Gallery A Naive Algorithm Outline Consider all line segments � n � = O ( n 2 ) determined by 2 pairs of points.

  42. Introduction Area Inclusion Line Hull Art Gallery A Naive Algorithm Outline Consider all line segments � n � q = O ( n 2 ) determined by 2 p pairs of points. If a line segment has all the other n − 2 points on one side of it, then it is a hull edge.

  43. Introduction Area Inclusion Line Hull Art Gallery A Naive Algorithm Outline Consider all line segments � n � q = O ( n 2 ) determined by 2 p pairs of points. If a line segment has all the other n − 2 points on one side of it, then it is a hull edge. We need � n � ( n − 2) = O ( n 3 ) time. 2

  44. Introduction Area Inclusion Line Hull Art Gallery Towards a Better Algorithm How much betterment is possible? Better characterizations lead to better algorithms.

  45. Introduction Area Inclusion Line Hull Art Gallery Towards a Better Algorithm How much betterment is possible? Better characterizations lead to better algorithms. How much better can we make?

  46. Introduction Area Inclusion Line Hull Art Gallery Towards a Better Algorithm How much betterment is possible? Better characterizations lead to better algorithms. How much better can we make? Leads to the notion of lower bound of a problem.

  47. Introduction Area Inclusion Line Hull Art Gallery Towards a Better Algorithm How much betterment is possible? Better characterizations lead to better algorithms. How much better can we make? Leads to the notion of lower bound of a problem. The problem of Convex Hull has a lower bound of Ω( n log n ). This can be shown by a reduction from the problem of sorting which also has a lower bound of Ω( n log n ).

  48. Introduction Area Inclusion Line Hull Art Gallery Optimal Algorithms Grahams scan, time complexity O ( nlogn ). (Graham, R.L., 1972) Divide and conquer algorithm, time complexity O ( nlogn ). (Preparata, F. P. and Hong, S. J., 1977) Jarvis’s march or gift wrapping algorithm, time complexity O ( nh ) where h number of vertices of the convex hull. (Jarvis, R. A., 1973) Most efficient algorithm to date is based on the idea of Jarvis’s march, time complexity O ( nlogh ). (T. M. Chan, 1996)

  49. Introduction Area Inclusion Line Hull Art Gallery Definitions A better characterization Consider a walk in clockwise direction on the vertices of a closed polygon. upper hull p n p 1 lower hull

  50. Introduction Area Inclusion Line Hull Art Gallery Definitions A better characterization Consider a walk in clockwise direction on the vertices of a closed polygon. Only for a convex polygon, we will upper hull make a right turn always. p n p 1 lower hull

  51. Introduction Area Inclusion Line Hull Art Gallery Definitions A better characterization Consider a walk in clockwise direction on the vertices of a closed polygon. Only for a convex polygon, we will upper hull make a right turn always. The incremental paradigm p n p 1 lower hull

  52. Introduction Area Inclusion Line Hull Art Gallery Definitions A better characterization Consider a walk in clockwise direction on the vertices of a closed polygon. Only for a convex polygon, we will upper hull make a right turn always. The incremental paradigm p n Insert points in P one by one and p 1 update the solution at each step. lower hull

  53. Introduction Area Inclusion Line Hull Art Gallery Definitions A better characterization Consider a walk in clockwise direction on the vertices of a closed polygon. Only for a convex polygon, we will upper hull make a right turn always. The incremental paradigm p n Insert points in P one by one and p 1 update the solution at each step. We compute the upper hull first. The lower hull upper hull contains the convex hull edges that bound the convex hull from above.

  54. Introduction Area Inclusion Line Hull Art Gallery Definitions A better characterization Consider a walk in clockwise direction on the vertices of a closed polygon. Only for a convex polygon, we will upper hull make a right turn always. The incremental paradigm p n Insert points in P one by one and p 1 update the solution at each step. We compute the upper hull first. The lower hull upper hull contains the convex hull edges that bound the convex hull from above. Sort the points in P from left to right.

  55. Introduction Area Inclusion Line Hull Art Gallery A Naive Algorithm Input: A set P of n points in the plane

  56. Introduction Area Inclusion Line Hull Art Gallery A Naive Algorithm Input: A set P of n points in the plane Output: Convex Hull of P

  57. Introduction Area Inclusion Line Hull Art Gallery A Naive Algorithm Input: A set P of n points in the plane Output: Convex Hull of P Sort P according to x-coordinate to generate a sequence of points p[1], p[2], ..., p[n];

  58. Introduction Area Inclusion Line Hull Art Gallery A Naive Algorithm Input: A set P of n points in the plane Output: Convex Hull of P Sort P according to x-coordinate to generate a sequence of points p[1], p[2], ..., p[n]; Insert p[1] and then p[2] in a list L_U;

  59. Introduction Area Inclusion Line Hull Art Gallery A Naive Algorithm Input: A set P of n points in the plane Output: Convex Hull of P Sort P according to x-coordinate to generate a sequence of points p[1], p[2], ..., p[n]; Insert p[1] and then p[2] in a list L_U; for i = 3 to n { }

  60. Introduction Area Inclusion Line Hull Art Gallery A Naive Algorithm Input: A set P of n points in the plane Output: Convex Hull of P Sort P according to x-coordinate to generate a sequence of points p[1], p[2], ..., p[n]; Insert p[1] and then p[2] in a list L_U; for i = 3 to n { Append p[i] to L_U; }

  61. Introduction Area Inclusion Line Hull Art Gallery A Naive Algorithm Input: A set P of n points in the plane Output: Convex Hull of P Sort P according to x-coordinate to generate a sequence of points p[1], p[2], ..., p[n]; Insert p[1] and then p[2] in a list L_U; for i = 3 to n { Append p[i] to L_U; while(L_U contains more than two points AND the last three points in L_U do not make a right turn) { } }

  62. Introduction Area Inclusion Line Hull Art Gallery A Naive Algorithm Input: A set P of n points in the plane Output: Convex Hull of P Sort P according to x-coordinate to generate a sequence of points p[1], p[2], ..., p[n]; Insert p[1] and then p[2] in a list L_U; for i = 3 to n { Append p[i] to L_U; while(L_U contains more than two points AND the last three points in L_U do not make a right turn) { Delete the middle of the last three points from L_U; } }

  63. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

  64. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

  65. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

  66. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

  67. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

  68. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

  69. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

  70. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

  71. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

  72. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

  73. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

  74. Introduction Area Inclusion Line Hull Art Gallery The Algorithm in Action p n p 1

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend