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

introduction to computational geometry
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

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 Bengal, India.

slide-2
SLIDE 2

Introduction Area Inclusion Line Hull Art Gallery

Outline

1

Introduction

2

Area Computation of a Simple Polygon

3

Point Inclusion in a Simple Polygon

4

Line Segment Intersection: An application of plane sweep paradigm

5

Convex Hull: An application of incremental algorithm

6

Art Gallery Problem: A study of combinatorial geometry

slide-3
SLIDE 3

Introduction Area Inclusion Line Hull Art Gallery

Introduction

Computational Geometry (CG) involves study of algorithms for solving geometric problems on a computer. The emphasis is more on discrete and combinatorial geometry.

slide-4
SLIDE 4

Introduction Area Inclusion Line Hull Art Gallery

Introduction

Computational Geometry (CG) involves study of algorithms for solving geometric problems on a computer. The emphasis is more on discrete and combinatorial geometry. There are many areas in computer science like computer graphics, computer vision and image processing, robotics, computer-aided designing (CAD), geographic information systems (GIS), etc. that give rise to geometric problems.

slide-5
SLIDE 5

Introduction Area Inclusion Line Hull Art Gallery

Introduction

Computational Geometry (CG) involves study of algorithms for solving geometric problems on a computer. The emphasis is more on discrete and combinatorial geometry. There are many areas in computer science like computer graphics, computer vision and image processing, robotics, computer-aided designing (CAD), geographic information systems (GIS), etc. that give rise to geometric problems. In CG, the focus is more on discrete nature of geometric problems as opposed to continuous issues. Simply put, we would deal more with straight or flat objects (lines, line segments, polygons) or simple curved objects as circles, than with high degree algebraic curves.

slide-6
SLIDE 6

Introduction Area Inclusion Line Hull Art Gallery

Introduction

Computational Geometry (CG) involves study of algorithms for solving geometric problems on a computer. The emphasis is more on discrete and combinatorial geometry. There are many areas in computer science like computer graphics, computer vision and image processing, robotics, computer-aided designing (CAD), geographic information systems (GIS), etc. that give rise to geometric problems. In CG, the focus is more on discrete nature of geometric problems as opposed to continuous issues. Simply put, we would deal more with straight or flat objects (lines, line segments, polygons) or simple curved objects as circles, than with high degree algebraic curves. This branch of study is around thirty years old if one assumes Michael Ian Shamos’s thesis [6] as the starting point.

slide-7
SLIDE 7

Introduction Area Inclusion Line Hull Art Gallery

Introduction

Any problem that is to be solved using a digital computer has to be discrete in form. It is the same with CG.

slide-8
SLIDE 8

Introduction Area Inclusion Line Hull Art Gallery

Introduction

Any problem that is to be solved using a digital computer has to be discrete in form. It is the same with CG. For CG techniques to be applied to areas that involves continuous issues, discrete approximations to continuous curves or surfaces are needed.

slide-9
SLIDE 9

Introduction Area Inclusion Line Hull Art Gallery

Introduction

Any problem that is to be solved using a digital computer has to be discrete in form. It is the same with CG. For CG techniques to be applied to areas that involves continuous issues, discrete approximations to continuous curves or surfaces are needed. Programming in CG is also a little difficult. Fortunately, libraries like LEDA [7] and CGAL [8] are now available. These libraries implement various data structures and algorithms specific to CG.

slide-10
SLIDE 10

Introduction Area Inclusion Line Hull Art Gallery

Introduction

Any problem that is to be solved using a digital computer has to be discrete in form. It is the same with CG. For CG techniques to be applied to areas that involves continuous issues, discrete approximations to continuous curves or surfaces are needed. Programming in CG is also a little difficult. Fortunately, libraries like LEDA [7] and CGAL [8] are now available. These libraries implement various data structures and algorithms specific to CG. CG algorithms suffer from the curse of degeneracies. So, we would make certain simplifying assumptions at times like no three points are collinear, no four points are cocircular, etc.

slide-11
SLIDE 11

Introduction Area Inclusion Line Hull Art Gallery

Introduction

In this lecture, we touch upon a few simple topics for having a glimpse of the area of computational geometry.

slide-12
SLIDE 12

Introduction Area Inclusion Line Hull Art Gallery

Introduction

In this lecture, we touch upon a few simple topics for having a glimpse of the area of computational geometry. First we consider some geometric primitives, that is, problems that arise frequently in computational geometry.

slide-13
SLIDE 13

Introduction Area Inclusion Line Hull Art Gallery

Outline

1

Introduction

2

Area Computation of a Simple Polygon

3

Point Inclusion in a Simple Polygon

4

Line Segment Intersection: An application of plane sweep paradigm

5

Convex Hull: An application of incremental algorithm

6

Art Gallery Problem: A study of combinatorial geometry

slide-14
SLIDE 14

Introduction Area Inclusion Line Hull Art Gallery

Area Computation

Problem Given a simple polygon P of n vertices, compute its area.

p1 p2 pn pn−1

slide-15
SLIDE 15

Introduction Area Inclusion Line Hull Art Gallery

Area Computation

Problem Given a simple polygon P of n vertices, compute its area. Area of a convex polygon Find a point inside P, draw n triangles and compute the area.

slide-16
SLIDE 16

Introduction Area Inclusion Line Hull Art Gallery

Area Computation

Problem Given a simple polygon P of n vertices, compute its area. Area of a convex polygon Find a point inside P, draw n triangles and compute the area. A better idea for convex polygon We can triangulate P by non-crossing diagonals into n − 2 triangles and then find the area.

slide-17
SLIDE 17

Introduction Area Inclusion Line Hull Art Gallery

Area Computation

Problem Given a simple polygon P of n vertices, compute its area. Area of a convex polygon Find a point inside P, draw n triangles and compute the area. A better idea for convex polygon We can triangulate P by non-crossing diagonals into n − 2 triangles and then find the area. A better idea for simple polygon We can do likewise.

p1 p2 pn pn−1

slide-18
SLIDE 18

Introduction Area Inclusion Line Hull Art Gallery

Area Computation

Result If P be a simple polygon with n vertices with coordinates of the vertex pi being (xi, yi), 1 ≤ i ≤ n, then twice the area of P is given by 2A(P) =

n

  • i=1

(xiyi+1 − yixi+1)

slide-19
SLIDE 19

Introduction Area Inclusion Line Hull Art Gallery

Polygon Triangulation

Theorem Any simple polygon can be triangulated.

slide-20
SLIDE 20

Introduction Area Inclusion Line Hull Art Gallery

Polygon Triangulation

Theorem Any simple polygon can be triangulated. Theorem A simple polygon can be triangulated into (n − 2) triangles by (n − 3) non-crossing diagonals.

slide-21
SLIDE 21

Introduction Area Inclusion Line Hull Art Gallery

Polygon Triangulation

Theorem Any simple polygon can be triangulated. Theorem A simple polygon can be triangulated into (n − 2) triangles by (n − 3) non-crossing diagonals. Proof. The proof is by induction on n.

slide-22
SLIDE 22

Introduction Area Inclusion Line Hull Art Gallery

Polygon Triangulation

Theorem Any simple polygon can be triangulated. Theorem A simple polygon can be triangulated into (n − 2) triangles by (n − 3) non-crossing diagonals. Proof. The proof is by induction on n. Time complexity We can triangulate P by a very complicated O(n) algorithm [2] OR by a more or less simple O(n log n) time algorithm [1].

slide-23
SLIDE 23

Introduction Area Inclusion Line Hull Art Gallery

Outline

1

Introduction

2

Area Computation of a Simple Polygon

3

Point Inclusion in a Simple Polygon

4

Line Segment Intersection: An application of plane sweep paradigm

5

Convex Hull: An application of incremental algorithm

6

Art Gallery Problem: A study of combinatorial geometry

slide-24
SLIDE 24

Introduction Area Inclusion Line Hull Art Gallery

Point Inclusion

Problem Given a simple polygon P of n points, and a query point q, is q ∈ P?

q P

slide-25
SLIDE 25

Introduction Area Inclusion Line Hull Art Gallery

Point Inclusion

Problem Given a simple polygon P of n points, and a query point q, is q ∈ P? What if P is convex? Easy in O(n). Takes a little effort to do it in O(log n). Left as an exercise.

q p1 p2 p3 p4 p5 p6 p7 p8 p9 q q is always to the right if q ∈ P, else, it varies

slide-26
SLIDE 26

Introduction Area Inclusion Line Hull Art Gallery

Point Inclusion

Problem Given a simple polygon P of n points, and a query point q, is q ∈ P? What if P is convex? Easy in O(n). Takes a little effort to do it in O(log n). Left as an exercise. Another idea for convex polygon Stand at q and walk around the

  • polygon. We can show the same

result for a simple polygon also.

q p1 p2 p3 p4 p5 p6 p7 p8 p9 q Total angular turn around q is 2π if q ∈ P, else, 0

slide-27
SLIDE 27

Introduction Area Inclusion Line Hull Art Gallery

Point Inclusion

Another technique: Ray Shooting Shoot a ray and count the number of crossings with edges

  • f P. If it is odd, then q ∈ P. If

it is even, then q ∈ P. Some degenerate cases need to be

  • handled. Time taken is O(n).

q P q

slide-28
SLIDE 28

Introduction Area Inclusion Line Hull Art Gallery

Outline

1

Introduction

2

Area Computation of a Simple Polygon

3

Point Inclusion in a Simple Polygon

4

Line Segment Intersection: An application of plane sweep paradigm

5

Convex Hull: An application of incremental algorithm

6

Art Gallery Problem: A study of combinatorial geometry

slide-29
SLIDE 29

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.

slide-30
SLIDE 30

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.

slide-31
SLIDE 31

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 vary from 0 to n

2

  • = O(n2). So,

the lower bound of the problem is Ω(n2). The idea is now to look for an output sensitive algorithm.

slide-32
SLIDE 32

Introduction Area Inclusion Line Hull Art Gallery

An Output Sensitive Algorithm

The idea Avoid testing pairs of segments that are far apart.

slide-33
SLIDE 33

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.

slide-34
SLIDE 34

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 ℓ.

slide-35
SLIDE 35

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.

slide-36
SLIDE 36

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.

slide-37
SLIDE 37

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.

slide-38
SLIDE 38

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.
slide-39
SLIDE 39

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.

slide-40
SLIDE 40

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.

slide-41
SLIDE 41

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.

slide-42
SLIDE 42

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.

slide-43
SLIDE 43

Introduction Area Inclusion Line Hull Art Gallery

Event Points and Sweep Line Status

Sweep Line Status We need to store the left to right

  • rder in which the line segments

intersect ℓ. This data structure has to be dynamic.

slide-44
SLIDE 44

Introduction Area Inclusion Line Hull Art Gallery

Event Points and Sweep Line Status

Sweep Line Status We need to store the left to right

  • rder 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.

slide-45
SLIDE 45

Introduction Area Inclusion Line Hull Art Gallery

Event Points and Sweep Line Status

Sweep Line Status We need to store the left to right

  • rder 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.

slide-46
SLIDE 46

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.

slide-47
SLIDE 47

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. si and sj are two segments intersecting at p.

slide-48
SLIDE 48

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. si and sj are two segments intersecting at p. There is an event point above p where si and sj are adjacent and are tested for intersection. So, no intersection point is ever missed.

slide-49
SLIDE 49

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

  • n x-coordinates of the points.

Initially T is empty.

slide-50
SLIDE 50

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

  • n x-coordinates of the points.

Initially T is empty. Keep on extracting points from H till it is non-empty.

slide-51
SLIDE 51

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

  • n 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.

slide-52
SLIDE 52

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm

Algorithm [Top end point] Insert the line segment into T based on x-coordinates.

slide-53
SLIDE 53

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.

slide-54
SLIDE 54

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 .

slide-55
SLIDE 55

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.

slide-56
SLIDE 56

Introduction Area Inclusion Line Hull Art Gallery

The Analysis

Analysis The heap H grows to a size at most 2n + I where I is the number

  • f intersections. Each operation

takes O(log(2n + I)). As I ≤ n2, so O(log(2n + I)) = O(log n).

slide-57
SLIDE 57

Introduction Area Inclusion Line Hull Art Gallery

The Analysis

Analysis The heap H grows to a size at most 2n + I where I is the number

  • f intersections. Each operation

takes O(log(2n + I)). As I ≤ n2, so O(log(2n + I)) = O(log n). The balanced binary search tree T grows to a size at most n. So, each

  • peration takes O(log n).
slide-58
SLIDE 58

Introduction Area Inclusion Line Hull Art Gallery

The Analysis

Analysis The heap H grows to a size at most 2n + I where I is the number

  • f intersections. Each operation

takes O(log(2n + I)). As I ≤ n2, so O(log(2n + I)) = O(log n). The balanced binary search tree T grows to a size at most n. So, each

  • peration takes O(log n).

So, the total time taken is O((2n + I) log n) = O(n log n + I log n).

slide-59
SLIDE 59

Introduction Area Inclusion Line Hull Art Gallery

Outline

1

Introduction

2

Area Computation of a Simple Polygon

3

Point Inclusion in a Simple Polygon

4

Line Segment Intersection: An application of plane sweep paradigm

5

Convex Hull: An application of incremental algorithm

6

Art Gallery Problem: A study of combinatorial geometry

slide-60
SLIDE 60

Introduction Area Inclusion Line Hull Art Gallery

Definitions

Definition A set S ⊂ R2 is convex If for any two points p, q ∈ S, pq ∈ S.

slide-61
SLIDE 61

Introduction Area Inclusion Line Hull Art Gallery

Definitions

Definition A set S ⊂ R2 is convex If for any two points p, q ∈ S, pq ∈ S. convex not convex p q p q pq pq

slide-62
SLIDE 62

Introduction Area Inclusion Line Hull Art Gallery

Definitions

Definition A set S ⊂ R2 is convex If for any two points p, q ∈ S, pq ∈ S. Definition Let P be a set of points in R2. Convex hull of P, denoted by CH(P), is the smallest convex set containing P.

slide-63
SLIDE 63

Introduction Area Inclusion Line Hull Art Gallery

Definitions

Definition A set S ⊂ R2 is convex If for any two points p, q ∈ S, pq ∈ S. Definition Let P be a set of points in R2. Convex hull of P, denoted by CH(P), is the smallest convex set containing P.

slide-64
SLIDE 64

Introduction Area Inclusion Line Hull Art Gallery

Definitions

Definition A set S ⊂ R2 is convex If for any two points p, q ∈ S, pq ∈ S. Definition Let P be a set of points in R2. Convex hull of P, denoted by CH(P), is the smallest convex set containing P.

slide-65
SLIDE 65

Introduction Area Inclusion Line Hull Art Gallery

Definitions

Definition A set S ⊂ R2 is convex If for any two points p, q ∈ S, pq ∈ S. Definition Let P be a set of points in R2. Convex hull of P, denoted by CH(P), is the smallest convex set containing P.

Hull edge Hull vertex

slide-66
SLIDE 66

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.

slide-67
SLIDE 67

Introduction Area Inclusion Line Hull Art Gallery

A Naive Algorithm

Outline Consider all line segments determined by n

2

  • = O(n2)

pairs of points.

slide-68
SLIDE 68

Introduction Area Inclusion Line Hull Art Gallery

A Naive Algorithm

Outline Consider all line segments determined by n

2

  • = O(n2)

pairs of points. If a line segment has all the

  • ther n − 2 points on one

side of it, then it is a hull edge.

p q

slide-69
SLIDE 69

Introduction Area Inclusion Line Hull Art Gallery

A Naive Algorithm

Outline Consider all line segments determined by n

2

  • = O(n2)

pairs of points. If a line segment has all the

  • ther n − 2 points on one

side of it, then it is a hull edge. We need n

2

  • (n − 2) = O(n3) time.

p q

slide-70
SLIDE 70

Introduction Area Inclusion Line Hull Art Gallery

Towards a Better Algorithm

How much betterment is possible? Better characterizations lead to better algorithms.

slide-71
SLIDE 71

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?

slide-72
SLIDE 72

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.

slide-73
SLIDE 73

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).

slide-74
SLIDE 74

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)

slide-75
SLIDE 75

Introduction Area Inclusion Line Hull Art Gallery

Definitions

A better characterization Consider a walk in clockwise direction

  • n the vertices of a closed polygon.

upper hull lower hull p1 pn

slide-76
SLIDE 76

Introduction Area Inclusion Line Hull Art Gallery

Definitions

A better characterization Consider a walk in clockwise direction

  • n the vertices of a closed polygon.

Only for a convex polygon, we will make a right turn always.

upper hull lower hull p1 pn

slide-77
SLIDE 77

Introduction Area Inclusion Line Hull Art Gallery

Definitions

A better characterization Consider a walk in clockwise direction

  • n the vertices of a closed polygon.

Only for a convex polygon, we will make a right turn always. The incremental paradigm

upper hull lower hull p1 pn

slide-78
SLIDE 78

Introduction Area Inclusion Line Hull Art Gallery

Definitions

A better characterization Consider a walk in clockwise direction

  • n the vertices of a closed polygon.

Only for a convex polygon, we will make a right turn always. The incremental paradigm Insert points in P one by one and update the solution at each step.

upper hull lower hull p1 pn

slide-79
SLIDE 79

Introduction Area Inclusion Line Hull Art Gallery

Definitions

A better characterization Consider a walk in clockwise direction

  • n the vertices of a closed polygon.

Only for a convex polygon, we will make a right turn always. The incremental paradigm Insert points in P one by one and update the solution at each step. We compute the upper hull first. The upper hull contains the convex hull edges that bound the convex hull from above.

upper hull lower hull p1 pn

slide-80
SLIDE 80

Introduction Area Inclusion Line Hull Art Gallery

Definitions

A better characterization Consider a walk in clockwise direction

  • n the vertices of a closed polygon.

Only for a convex polygon, we will make a right turn always. The incremental paradigm Insert points in P one by one and update the solution at each step. We compute the upper hull first. The upper hull contains the convex hull edges that bound the convex hull from above. Sort the points in P from left to right.

upper hull lower hull p1 pn

slide-81
SLIDE 81

Introduction Area Inclusion Line Hull Art Gallery

A Naive Algorithm

Input: A set P of n points in the plane

slide-82
SLIDE 82

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

slide-83
SLIDE 83

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];

slide-84
SLIDE 84

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;

slide-85
SLIDE 85

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 { }

slide-86
SLIDE 86

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; }

slide-87
SLIDE 87

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) { } }

slide-88
SLIDE 88

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; } }

slide-89
SLIDE 89

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-90
SLIDE 90

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-91
SLIDE 91

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-92
SLIDE 92

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-93
SLIDE 93

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-94
SLIDE 94

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-95
SLIDE 95

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-96
SLIDE 96

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-97
SLIDE 97

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-98
SLIDE 98

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-99
SLIDE 99

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-100
SLIDE 100

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-101
SLIDE 101

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-102
SLIDE 102

Introduction Area Inclusion Line Hull Art Gallery

The Algorithm in Action p1 pn

slide-103
SLIDE 103

Introduction Area Inclusion Line Hull Art Gallery

Analysis

Time complexity Sorting takes time O(n log n).

slide-104
SLIDE 104

Introduction Area Inclusion Line Hull Art Gallery

Analysis

Time complexity Sorting takes time O(n log n). The for loop is executed O(n) times.

slide-105
SLIDE 105

Introduction Area Inclusion Line Hull Art Gallery

Analysis

Time complexity Sorting takes time O(n log n). The for loop is executed O(n) times. For each execution of the for loop, the while loop is encountered once.

slide-106
SLIDE 106

Introduction Area Inclusion Line Hull Art Gallery

Analysis

Time complexity Sorting takes time O(n log n). The for loop is executed O(n) times. For each execution of the for loop, the while loop is encountered once. For each execution of the while loop body, a point gets deleted.

slide-107
SLIDE 107

Introduction Area Inclusion Line Hull Art Gallery

Analysis

Time complexity Sorting takes time O(n log n). The for loop is executed O(n) times. For each execution of the for loop, the while loop is encountered once. For each execution of the while loop body, a point gets deleted. A point once deleted, is never deleted again.

slide-108
SLIDE 108

Introduction Area Inclusion Line Hull Art Gallery

Analysis

Time complexity Sorting takes time O(n log n). The for loop is executed O(n) times. For each execution of the for loop, the while loop is encountered once. For each execution of the while loop body, a point gets deleted. A point once deleted, is never deleted again. So, the total number of executions of the while loop body is bounded by O(n).

slide-109
SLIDE 109

Introduction Area Inclusion Line Hull Art Gallery

Analysis

Time complexity Sorting takes time O(n log n). The for loop is executed O(n) times. For each execution of the for loop, the while loop is encountered once. For each execution of the while loop body, a point gets deleted. A point once deleted, is never deleted again. So, the total number of executions of the while loop body is bounded by O(n). Hence, the total time complexity is O(n log n).

slide-110
SLIDE 110

Introduction Area Inclusion Line Hull Art Gallery

Outline

1

Introduction

2

Area Computation of a Simple Polygon

3

Point Inclusion in a Simple Polygon

4

Line Segment Intersection: An application of plane sweep paradigm

5

Convex Hull: An application of incremental algorithm

6

Art Gallery Problem: A study of combinatorial geometry

slide-111
SLIDE 111

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

The problem Given a simple polygon P of n vertices, find the minimum number

  • f cameras that can guard P.
slide-112
SLIDE 112

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

The problem Given a simple polygon P of n vertices, find the minimum number

  • f cameras that can guard P.

Hardness The above problem is NP-Hard.

slide-113
SLIDE 113

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

The problem Given a simple polygon P of n vertices, find the minimum number

  • f cameras that can guard P.

Hardness The above problem is NP-Hard. Any solution?

slide-114
SLIDE 114

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

The problem Given a simple polygon P of n vertices, find the minimum number

  • f cameras that can guard P.

Hardness The above problem is NP-Hard. Any solution? Can we find, as a function of n, the number of cameras that suffices to guard P?

slide-115
SLIDE 115

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

The problem Given a simple polygon P of n vertices, find the minimum number

  • f cameras that can guard P.

Hardness The above problem is NP-Hard. Any solution? Can we find, as a function of n, the number of cameras that suffices to guard P? Recall P can be triangulated into n − 2 triangles. Place a guard in each triangle.

slide-116
SLIDE 116

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

Can the bound be reduced? Place guards at vertices of the triangulation T of P.

slide-117
SLIDE 117

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

Can the bound be reduced? Place guards at vertices of the triangulation T of P. We do a 3-coloring of the vertices of T . Each triangle of T has a blue, gray and white vertex.

slide-118
SLIDE 118

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

Can the bound be reduced? Place guards at vertices of the triangulation T of P. We do a 3-coloring of the vertices of T . Each triangle of T has a blue, gray and white vertex. Choose the smallest color class to guard P.

slide-119
SLIDE 119

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

Can the bound be reduced? Place guards at vertices of the triangulation T of P. We do a 3-coloring of the vertices of T . Each triangle of T has a blue, gray and white vertex. Choose the smallest color class to guard P. Hence, ⌊ n

3⌋ guards suffice.

slide-120
SLIDE 120

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

Can the bound be reduced? Place guards at vertices of the triangulation T of P. We do a 3-coloring of the vertices of T . Each triangle of T has a blue, gray and white vertex. Choose the smallest color class to guard P. Hence, ⌊ n

3⌋ guards suffice.

But, does a 3-coloring always exist?

slide-121
SLIDE 121

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

A 3-coloring always exist

slide-122
SLIDE 122

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

A 3-coloring always exist Consider the dual graph GT of T of P.

slide-123
SLIDE 123

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

A 3-coloring always exist Consider the dual graph GT of T of P. GT is a tree as P has no holes.

slide-124
SLIDE 124

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

A 3-coloring always exist Consider the dual graph GT of T of P. GT is a tree as P has no holes. Do a DFS on GT to obtain the coloring.

slide-125
SLIDE 125

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

A 3-coloring always exist Consider the dual graph GT of T of P. GT is a tree as P has no holes. Do a DFS on GT to obtain the coloring. Place guards at those vertices that have color of the minimum color class. Hence, ⌊ n

3⌋ guards

are sufficient to guard P.

slide-126
SLIDE 126

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Problem

A 3-coloring always exist Consider the dual graph GT of T of P. GT is a tree as P has no holes. Do a DFS on GT to obtain the coloring. Place guards at those vertices that have color of the minimum color class. Hence, ⌊ n

3⌋ guards

are sufficient to guard P. Necessity? Are ⌊ n

3⌋ guards sometimes

necessary?

⌊n

3⌋

prongs

slide-127
SLIDE 127

Introduction Area Inclusion Line Hull Art Gallery

Art Gallery Theorem

Final Result For a simple polygon with n vertices, ⌊ n

3⌋ cameras are always

sufficient and occasionally necessary to have every point in the polygon visible from at least one of the cameras.

slide-128
SLIDE 128

Introduction Area Inclusion Line Hull Art Gallery

References I

Mark de Berg, Marc van Kreveld, Mark Overmars and Otfried Schwarzkof, Computational Geometry: Algorithms and Applications, Springer, 1997.

  • B. Chazelle, Triangulating a simple polygon in linear time,

Discrete Comput. Geom., 6:485524, 1991. Herbert Edelsbrunner, Algorithms in Computational Geometry, Springer, 1987. Joseph O’Rourke, Computational Geometry in C, Cambridge University Press, 1998. Franco P. Preparata and Michael Ian Shamos, Computational Geometry: An Introduction, Springer-Verlag, New York, 1985. Michael Ian Shamos, Computational Geometry, PhD thesis, Yale University, New Haven., 1978.

slide-129
SLIDE 129

Introduction Area Inclusion Line Hull Art Gallery

References II

http://www.algorithmic-solutions.com http://www.cgal.org http: //en.wikipedia.org/wiki/Computational_geometry

slide-130
SLIDE 130

Introduction Area Inclusion Line Hull Art Gallery

Thank you!