Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry...

162
Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls Tamara Mchedlidze · Darren Strash Computational Geometry · Lecture INSTITUT F ¨ UR THEORETISCHE INFORMATIK · FAKULT ¨ AT F ¨ UR INFORMATIK Introduction & Convex Hulls 19.10.2015 1

Transcript of Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry...

Page 1: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Tamara Mchedlidze · Darren Strash

Computational Geometry · Lecture

INSTITUT FUR THEORETISCHE INFORMATIK · FAKULTAT FUR INFORMATIK

Introduction & Convex Hulls

19.10.2015

1

Page 2: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

AlgoGeom-Team

Lecturers

Tamara [email protected]

Room 307Office hours: byappointment

Darren [email protected]

Room 206Office hours: byappointment

2

Page 3: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

AlgoGeom-Team

Lecturers

Exercise Leader

Benjamin [email protected]

Room 309Office hours: by appointment

Tamara [email protected]

Room 307Office hours: byappointment

Darren [email protected]

Room 206Office hours: byappointment

2

Page 4: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

AlgoGeom-Team

Lecturers

Exercise Leader

Benjamin [email protected]

Room 309Office hours: by appointment

Schedule

Lecture: Mon. 15:45 – 17:15, SR 301Exercises: Wed. 15:45 – 17:15, SR 301 (starting Oct. 28)

Tamara [email protected]

Room 307Office hours: byappointment

Darren [email protected]

Room 206Office hours: byappointment

2

Page 5: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Organization

Websitehttp://i11www.iti.kit.edu/teaching/winter2015/compgeom/

Course InformationLecture SlidesExercisesAdditional Material

3

Page 6: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Organization

Websitehttp://i11www.iti.kit.edu/teaching/winter2015/compgeom/

Course InformationLecture SlidesExercisesAdditional Material

Computational Geometry in Computer Science Master’sStudies

Algorithms 1+2

Theoretical Basics

Bachelor Master

Algorithm design, theoreticalbasics, computer graphics

ComputationalGeometry

...Algorithms for Planar Graphs

3

Page 7: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Organization

ExercisesEvery second Wednesday starting 28.10Exercise problems posted at least one week before anexercise session.Rinforce lecture material, help prepare for exam.

What will the exercises involve?Weekly work for about 45–60 minutesActive participation in exercises is expectedVolunteers will work problems on the boardCan hand in exercises for feedbackVariations will be announced

Exercise on 16.12 instead of 23.12

4

Page 8: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Computational Geometry

Objectives: At the end of the course you will be able to...

explain concepts, structures, and problem definitionsunderstand the discussed algorithms, and explain and analyze themselect and adapt appropriate algorithms and data structuresanalyze new geometric problems and develop efficient solutions

5

Page 9: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Computational Geometry

Objectives: At the end of the course you will be able to...

explain concepts, structures, and problem definitionsunderstand the discussed algorithms, and explain and analyze themselect and adapt appropriate algorithms and data structuresanalyze new geometric problems and develop efficient solutions

Prior Knowledge: Algorithms and Elementary Geometry

5

Page 10: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Computational Geometry

Objectives: At the end of the course you will be able to...

explain concepts, structures, and problem definitionsunderstand the discussed algorithms, and explain and analyze themselect and adapt appropriate algorithms and data structuresanalyze new geometric problems and develop efficient solutions

Course Time Breakdown:

Time in lectures and exercise sessionsPreparation and reviewWorking on exercisesProject workExam preparation

ca. 35h

5LP = 150h

ca. 25hca. 20hca. 40hca. 30h

Prior Knowledge: Algorithms and Elementary Geometry

5

Page 11: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Modules and Grading

Master’s in Computer Science

Computational Geometry (IN4INAG) [5 LP]Algorithm Engineering & Applications (IN4INAEA) [5 LP]Design and Analysis of Algorithms (IN4INDAA) [5 LP]Computer Graphics Algorithms (IN4INACG) [3 LP]

6

Page 12: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Modules and Grading

Master’s in Computer Science

Computational Geometry (IN4INAG) [5 LP]Algorithm Engineering & Applications (IN4INAEA) [5 LP]Design and Analysis of Algorithms (IN4INDAA) [5 LP]Computer Graphics Algorithms (IN4INACG) [3 LP]

Test Modalities

Semester-long project in small teams (application-drivengeometric algorithms)→ 20% of gradeOne oral examination (about 20 minutes)→ 80% of grade

6

Page 13: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Modules and Grading

Master’s in Computer Science

Computational Geometry (IN4INAG) [5 LP]Algorithm Engineering & Applications (IN4INAEA) [5 LP]Design and Analysis of Algorithms (IN4INDAA) [5 LP]Computer Graphics Algorithms (IN4INACG) [3 LP]

Test Modalities

Semester-long project in small teams (application-drivengeometric algorithms)→ 20% of gradeOne oral examination (about 20 minutes)→ 80% of grade

More on this in 1–2 weeks

6

Page 14: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Class Materials

Rolf Klein:Algorithmische GeometrieSpringer, 2nd Edition, 2005

M. de Berg, O. Cheong, M. van Kreveld, M. Overmars:Computational Geometry: Algorithms and Applications

Springer, 3rd Edition, 2008

Both books are available in the library!

David Mount:Computational GeometryLecture Notes CMSC 754, U. Maryland, 2012http://www.cs.umd.edu/class/spring2012/cmsc754/Lects/cmsc754-lects.pdf

7

Page 15: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Class Materials

Rolf Klein:Algorithmische GeometrieSpringer, 2nd Edition, 2005

M. de Berg, O. Cheong, M. van Kreveld, M. Overmars:Computational Geometry: Algorithms and Applications

Springer, 3rd Edition, 2008

Both books are available in the library!

David Mount:Computational GeometryLecture Notes CMSC 754, U. Maryland, 2012http://www.cs.umd.edu/class/spring2012/cmsc754/Lects/cmsc754-lects.pdf

PDF available on springerlink.com!

7

Page 16: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What is Computational Geometry?

8

Page 17: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What is Computational Geometry?

Computational geometry is a branch of computer science thatdeals with algorithmic solutions to geometric problems. Acentral problem is the storage and processing of geometricdata...such as points, lines, circles, polygons...

8

Page 18: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What is Computational Geometry?

Where is Computational Geometry Used?

Computer Graphics and Image ProcessingVisualizationGeographic Information Systems (GIS)Robotics. . .

Computational geometry is a branch of computer science thatdeals with algorithmic solutions to geometric problems. Acentral problem is the storage and processing of geometricdata...such as points, lines, circles, polygons...

8

Page 19: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What is Computational Geometry?

Where is Computational Geometry Used?

Computer Graphics and Image ProcessingVisualizationGeographic Information Systems (GIS)Robotics. . .

Central ThemesGeometric algorithms and data structuresDiscrete and combinatorial geometric problems

Computational geometry is a branch of computer science thatdeals with algorithmic solutions to geometric problems. Acentral problem is the storage and processing of geometricdata...such as points, lines, circles, polygons...

8

Page 20: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 1

?

It’s a hot 42C summer day in Karlsruhe. Suppose you knowthe location of every ice cream shop in the city. How can youdetermine the closest ice cream shop for any location on amap?

9

Page 21: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 1

?

It’s a hot 42C summer day in Karlsruhe. Suppose you knowthe location of every ice cream shop in the city. How can youdetermine the closest ice cream shop for any location on amap?

9

Page 22: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 1

?

It’s a hot 42C summer day in Karlsruhe. Suppose you knowthe location of every ice cream shop in the city. How can youdetermine the closest ice cream shop for any location on amap?

!

9

Page 23: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 1

?

It’s a hot 42C summer day in Karlsruhe. Suppose you knowthe location of every ice cream shop in the city. How can youdetermine the closest ice cream shop for any location on amap?

!

The solution is a division of R2, called a Voronoi Diagram.

Many applications, including: site planning, nearest-neighborfinding, robot motion planning, radio cells . . .

9

Page 24: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 2

Now it is 50C in Karlsruhe. We want to send a robot to buyan ice cream cone. How can the robot reach the destinationwithout passing through houses, park benches, and trees?

10

Page 25: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 2

Now it is 50C in Karlsruhe. We want to send a robot to buyan ice cream cone. How can the robot reach the destinationwithout passing through houses, park benches, and trees?

10

Page 26: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 2

Now it is 50C in Karlsruhe. We want to send a robot to buyan ice cream cone. How can the robot reach the destinationwithout passing through houses, park benches, and trees?

Motion planning problem in robotics:Given a set of obstacles with a start and destination point, finda collision-free shortest route (e.g., using the visibility graph).

10

Page 27: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 3

Maps in geographic information systems consist of severallevels (e.g., roads, water, borders, etc.). When superimposingseveral layers, what are the intersection points?

One example is to to view all roads and rivers as a set of linksand ask for the bridges. For these, you have to find allintersections between the two layers.

11

Page 28: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 3

Maps in geographic information systems consist of severallevels (e.g., roads, water, borders, etc.). When superimposingseveral layers, what are the intersection points?

One example is to to view all roads and rivers as a set of linksand ask for the bridges. For these, you have to find allintersections between the two layers.

11

Page 29: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 3

Maps in geographic information systems consist of severallevels (e.g., roads, water, borders, etc.). When superimposingseveral layers, what are the intersection points?

One example is to to view all roads and rivers as a set of linksand ask for the bridges. For these, you have to find allintersections between the two layers.

11

Page 30: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 3

Maps in geographic information systems consist of severallevels (e.g., roads, water, borders, etc.). When superimposingseveral layers, what are the intersection points?

One example is to to view all roads and rivers as a set of linksand ask for the bridges. For these, you have to find allintersections between the two layers.

Testing all edge pairs isslow. How can youquickly find allintersections?

11

Page 31: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 4

Given a map and a query point q (e.g., a mouse click),determine the country containing q.

12

Page 32: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 4

Given a map and a query point q (e.g., a mouse click),determine the country containing q.

We want a fast data structure for answering point queries.

12

Page 33: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 5

A navigation system should display a current map. How can weeffectively choose the data to display?

13

Page 34: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 5

A navigation system should display a current map. How can weeffectively choose the data to display?

13

Page 35: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example 5

A navigation system should display a current map. How can weeffectively choose the data to display?

Evaluating each map feature is unrealistic.

We want a fast data structure for answering range queries

13

Page 36: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Topics

We will cover the following topics:Convex HullsLine Segment IntersectionPolygon TriangulationGeometric Linear ProgrammingData Structures for Range QueriesData Structure for Point Location QueriesVoronoi Diagrams and Delaunay TriangulationDuality of Points and LinesQuadtreesWell-Separated Pair DecompositionsVisibility Graphs...

14

Page 37: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Convex Hulls

15

Page 38: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Mixing Ratios

Mixture fraction A fraction Bs1 10 % 35 %s2 20 % 5 %

Given...

16

Page 39: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Mixing Ratios

Mixture fraction A fraction Bs1 10 % 35 %s2 20 % 5 %

Given...

Mixtur Anteil A Anteil Bq1 15 % 20 %q2 25 % 28 %

can we mix

using s1, s2?

16

Page 40: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Mixing Ratios

Mixture fraction A fraction Bs1 10 % 35 %s2 20 % 5 %

Given...

Mixtur Anteil A Anteil Bq1 15 % 20 %q2 25 % 28 %

can we mix

using s1, s2?

q1: Yes! Ratio 1:1

q2: No!

16

Page 41: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Mixing Ratios

Given...

Mixture fraction A fraction Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %

Mixtur Anteil A Anteil Bq1 15 % 20 %q2 25 % 28 %

can we mix

using s1, s2, s3?

16

Page 42: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Mixing Ratios

.1 .2 .3 .4

.4

.3

.2

.1

B

A

s1

s2

s3

Given...

Mixture fraction A fraction Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %

Mixtur Anteil A Anteil Bq1 15 % 20 %q2 25 % 28 %

can we mix

using s1, s2, s3?

geom. interpretation

16

Page 43: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Mixing Ratios

.1 .2 .3 .4

.4

.3

.2

.1

B

A

s1

s2

s3q2

q1

Given...

Mixture fraction A fraction Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %

Mixtur Anteil A Anteil Bq1 15 % 20 %q2 25 % 28 %

can we mix

using s1, s2, s3?

geom. interpretation

16

Page 44: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Mixing Ratios

.1 .2 .3 .4

.4

.3

.2

.1

B

A

s1

s2

s3q2

q1

Given...

Mixture fraction A fraction Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %

Mixtur Anteil A Anteil Bq1 15 % 20 %q2 25 % 28 %

can we mix

using s1, s2, s3?

geom. interpretation

16

Page 45: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Mixing Ratios

.1 .2 .3 .4

.4

.3

.2

.1

B

A

s1

s2

s3q2

q1

Obs: Given a set S ⊂ R2 of mixtures, we can make anothermixture q ∈ R2 out of S ⇔

Given...

Mixture fraction A fraction Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %

Mixtur Anteil A Anteil Bq1 15 % 20 %q2 25 % 28 %

can we mix

using s1, s2, s3?

geom. interpretation

16

Page 46: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Mixing Ratios

.1 .2 .3 .4

.4

.3

.2

.1

B

A

s1

s2

s3q2

q1

Obs: Given a set S ⊂ R2 of mixtures, we can make anothermixture q ∈ R2 out of S ⇔ q ∈ convex hull CH(S).

Given...

Mixture fraction A fraction Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %

Mixtur Anteil A Anteil Bq1 15 % 20 %q2 25 % 28 %

can we mix

using s1, s2, s3?

geom. interpretation

q =∑

i λisi with∑

i λi = 1.

16

Page 47: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Mixing Ratios

.1 .2 .3 .4

.4

.3

.2

.1

B

A

s1

s2

s3q2

q1

Obs: Given a set S ⊂ R2 of mixtures, we can make anothermixture q ∈ R2 out of S ⇔ q ∈ convex hull CH(S).

d

d

Given...

Mixture fraction A fraction Bs1 10 % 35 %s2 20 % 5 %s3 40 % 25 %

Mixtur Anteil A Anteil Bq1 15 % 20 %q2 25 % 28 %

can we mix

using s1, s2, s3?

geom. interpretation

q =∑

i λisi with∑

i λi = 1.

16

Page 48: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Definition of Convex Hull

Def: A region S ⊆ R2 is called convex, when for two pointsp, q ∈ S then line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

17

Page 49: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Definition of Convex Hull

Def: A region S ⊆ R2 is called convex, when for two pointsp, q ∈ S then line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

17

Page 50: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Definition of Convex Hull

Def: A region S ⊆ R2 is called convex, when for two pointsp, q ∈ S then line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

In physics:

17

Page 51: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Definition of Convex Hull

Def: A region S ⊆ R2 is called convex, when for two pointsp, q ∈ S then line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

In physics:

put a large rubber bandaround all points

17

Page 52: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Definition of Convex Hull

Def: A region S ⊆ R2 is called convex, when for two pointsp, q ∈ S then line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

In physics:

put a large rubber bandaround all points

and let it go!

17

Page 53: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Definition of Convex Hull

Def: A region S ⊆ R2 is called convex, when for two pointsp, q ∈ S then line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

In physics:

put a large rubber bandaround all points

and let it go!unfortunately, does not helpalgorithmically

17

Page 54: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Definition of Convex Hull

Def: A region S ⊆ R2 is called convex, when for two pointsp, q ∈ S then line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

In physics:

put a large rubber bandaround all points

and let it go!unfortunately, does not helpalgorithmically

In mathematics:

define CH(S) =⋂

C⊇S : C convex

C

does not help :-(17

Page 55: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Algorithmic Approach

Lemma:For a set of points P ⊆ R2, CH(P ) isa convex polygon that contains P andwhose vertices are in P .

18

Page 56: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Algorithmic Approach

Lemma:For a set of points P ⊆ R2, CH(P ) isa convex polygon that contains P andwhose vertices are in P .

Input: A set of points P = p1, . . . , pnOutput: List of vertices of CH(P ) in clockwise order

18

Page 57: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Algorithmic Approach

Lemma:For a set of points P ⊆ R2, CH(P ) isa convex polygon that contains P andwhose vertices are in P .

Input: A set of points P = p1, . . . , pnOutput: List of vertices of CH(P ) in clockwise order

Observation:

(p, q) is an edge of CH(P ) ⇔ each point r ∈ P \ p, qstrictly right of the oriented line −→pq oron the line segment pq

p q

−→pq

18

Page 58: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

A First Algorithm

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

19

Page 59: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

A First Algorithm

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

Check all possibleedges (p, q)

19

Page 60: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

A First Algorithm

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

Check all possibleedges (p, q)

Test in O(1) time with∣∣∣∣∣∣xr yr 1xp yp 1xq yq 1

∣∣∣∣∣∣ < 0→ Exercise!

19

Page 61: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

20

Page 62: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

Θ(1

)

20

Page 63: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

Θ(1

(n)

20

Page 64: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

Θ(1

(n)

(n2 − n)·

20

Page 65: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

Θ(1

(n)

(n2 − n)·

Θ(n

3)

20

Page 66: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

Θ(1

(n)

(n2 − n)·

Θ(n

3)

Question: How do we implement this?

20

Page 67: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

Θ(1

(n)

(n2 − n)·

Θ(n

3)

O(n

2)

20

Page 68: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

Θ(1

(n)

(n2 − n)·

Θ(n

3)

O(n

2)

Lemma: The convex hull of n points in the plane can becomputed in O(n3) time.

20

Page 69: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

FirstConvexHull(P )

E ← ∅foreach (p, q) ∈ P × P with p 6= q do

valid ← trueforeach r ∈ P do

if not (r strictly right of −→pq or r ∈ pq) thenvalid ← false

if valid thenE ← E ∪ (p, q)

construct sorted node list L of CH(P ) from Ereturn L

Θ(1

(n)

(n2 − n)·

Θ(n

3)

O(n

2)

Lemma: The convex hull of n points in the plane can becomputed in O(n3) time.

Can we do better?

20

Page 70: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Incremental Approach

Idea: For i = 1, . . . , n compute CH(Pi) where Pi = p1, . . . , piQuestion: Which ordering of the points is useful?

21

Page 71: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Incremental Approach

Idea: For i = 1, . . . , n compute CH(Pi) where Pi = p1, . . . , piQuestion: Which ordering of the points is useful?

Answer: From left to right!

21

Page 72: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Incremental Approach

Idea: For i = 1, . . . , n compute CH(Pi) where Pi = p1, . . . , piQuestion: Which ordering of the points is useful?

Answer: From left to right!

lower hull

upper hull

Consider the upper andlower hull separately

21

Page 73: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Incremental Approach

Idea: For i = 1, . . . , n compute CH(Pi) where Pi = p1, . . . , piQuestion: Which ordering of the points is useful?

Answer: From left to right!

lower hull

upper hull

Consider the upper andlower hull separately

UpperConvexHull(P )

〈p1, p2, . . . , pn〉 ← sort P from left to rightL← 〈p1, p2〉for i← 3 to n do

L.append(pi)while |L| > 2 and the last 3 points in L do not form right turn do

remove the second-to-last point in L

return L

?

21

Page 74: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Incremental Approach

Idea: For i = 1, . . . , n compute CH(Pi) where Pi = p1, . . . , piQuestion: Which ordering of the points is useful?

Answer: From left to right!

lower hull

upper hull

Consider the upper andlower hull separately

UpperConvexHull(P )

〈p1, p2, . . . , pn〉 ← sort P from left to rightL← 〈p1, p2〉for i← 3 to n do

L.append(pi)while |L| > 2 and the last 3 points in L do not form right turn do

remove the second-to-last point in L

return L21

Page 75: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Incremental Approach

Idea: For i = 1, . . . , n compute CH(Pi) where Pi = p1, . . . , piQuestion: Which ordering of the points is useful?

Answer: From left to right!

lower hull

upper hull

Consider the upper andlower hull separately

UpperConvexHull(P )

〈p1, p2, . . . , pn〉 ← sort P from left to rightL← 〈p1, p2〉for i← 3 to n do

L.append(pi)while |L| > 2 and the last 3 points in L do not form right turn do

remove the second-to-last point in L

return L

lower hull is handled similarly!

21

Page 76: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

UpperConvexHull(P )

〈p1, p2, . . . , pn〉 ← sort P from right to leftL← 〈p1, p2〉for i← 3 to n do

L.append(pi)while |L| > 2 and last 3 points in L do not form right turn do

remove the second-to-last point from L

return L

22

Page 77: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

UpperConvexHull(P )

〈p1, p2, . . . , pn〉 ← sort P from right to leftL← 〈p1, p2〉for i← 3 to n do

L.append(pi)while |L| > 2 and last 3 points in L do not form right turn do

remove the second-to-last point from L

return L

O(n log n)

22

Page 78: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

UpperConvexHull(P )

〈p1, p2, . . . , pn〉 ← sort P from right to leftL← 〈p1, p2〉for i← 3 to n do

L.append(pi)while |L| > 2 and last 3 points in L do not form right turn do

remove the second-to-last point from L

return L

O(n log n)

(n− 2)·

?

22

Page 79: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

UpperConvexHull(P )

〈p1, p2, . . . , pn〉 ← sort P from right to leftL← 〈p1, p2〉for i← 3 to n do

L.append(pi)while |L| > 2 and last 3 points in L do not form right turn do

remove the second-to-last point from L

return L

O(n log n)

(n− 2)·

?

Amortized Analysis

Each point is inserted into L exactly onceA point in L is removed at most once from L⇒ Running time of the for loop including the while loop is O(n)

22

Page 80: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

UpperConvexHull(P )

〈p1, p2, . . . , pn〉 ← sort P from right to leftL← 〈p1, p2〉for i← 3 to n do

L.append(pi)while |L| > 2 and last 3 points in L do not form right turn do

remove the second-to-last point from L

return L

O(n log n)

(n− 2)·

?

Amortized Analysis

Each point is inserted into L exactly onceA point in L is removed at most once from L⇒ Running time of the for loop including the while loop is O(n)

O(n

)

22

Page 81: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Running Time Analysis

UpperConvexHull(P )

〈p1, p2, . . . , pn〉 ← sort P from right to leftL← 〈p1, p2〉for i← 3 to n do

L.append(pi)while |L| > 2 and last 3 points in L do not form right turn do

remove the second-to-last point from L

return L

O(n log n)

(n− 2)·

?

Amortized Analysis

Each point is inserted into L exactly onceA point in L is removed at most once from L⇒ Running time of the for loop including the while loop is O(n)

O(n

)

Theorem 1: The convex hull of n points in the plane can becomputed in O(n log n) time. → Graham’s Scan.

22

Page 82: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

23

Page 83: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

23

Page 84: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

p1

23

Page 85: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

p1

23

Page 86: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

p1

23

Page 87: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

p1

23

Page 88: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

p1

23

Page 89: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

p1

23

Page 90: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

p1

23

Page 91: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

p1

p2

23

Page 92: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

p1

p2p3

23

Page 93: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

p1

p2p3

p4

23

Page 94: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

p1

p2p3

p4

p5

23

Page 95: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

= p6p1

p2p3

p4

p5

23

Page 96: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

= p6p1

p2p3

p4

p5

23

Page 97: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

= p6p1

p2p3

p4

p5

O(n)

23

Page 98: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

= p6p1

p2p3

p4

p5

O(n)

O(h)

23

Page 99: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

= p6p1

p2p3

p4

p5

O(n)

O(h)O(n)

O(n · h)

23

Page 100: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

O(n)

O(h)O(n)

O(n · h)

Theorem 2: The convex hull CH(P ) of n points P in R2 canbe computed in O(n · h) time using Gift Wrapping(also called Jarvis’ March), where h = |CH(P )|.

23

Page 101: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Alternative Approach: Gift Wrapping

Idea: Begin with a point p1 of CH(P ), then find the next edge ofCH(P ) in clockwise order.

GiftWrapping(P )

p1 = (x1, y1) ← rightmost point in P ; p0 ← (x1,∞); j ← 1while true do

pj+1 ← arg max∠pj−1, pj , q | q ∈ P \ pj−1, pjif pj+1 = p1 then break else j ← j + 1

return (p1, . . . , pj+1)

O(n)

O(h)O(n)

O(n · h)

Theorem 2: The convex hull CH(P ) of n points P in R2 canbe computed in O(n · h) time using Gift Wrapping(also called Jarvis’ March), where h = |CH(P )|.

→ more on that in the exercises!

23

Page 102: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Comparison

Which algorithm is better?

Graham’s Scan: O(n log n) timeJarvis’ March: O(n · h) time

24

Page 103: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Comparison

Which algorithm is better?

Graham’s Scan: O(n log n) timeJarvis’ March: O(n · h) time

It depends on how large CH(P ) is!

24

Page 104: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Comparison

Which algorithm is better?

Graham’s Scan: O(n log n) timeJarvis’ March: O(n · h) time

It depends on how large CH(P ) is!

Idea: Combine the two approaches into an optimal algorithm!

24

Page 105: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

Suppose we know h:ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

25

Page 106: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

Suppose we know h:ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

25

Page 107: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

Suppose we know h:

Gift Wrapping

GrahamScan

ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

25

Page 108: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

26

Page 109: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

26

Page 110: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

26

Page 111: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

26

Page 112: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

26

Page 113: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

26

Page 114: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

26

Page 115: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 116: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 117: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 118: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 119: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 120: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 121: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 122: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 123: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 124: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 125: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 126: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 127: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 128: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 129: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 130: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Example

n = 16

GrahamScan

Gift Wrapping26

Page 131: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

Suppose we know h:

Gift Wrapping

GrahamScan

ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

27

Page 132: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

Suppose we know h:ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

27

Page 133: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

Suppose we know h:ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

O(h log h)

27

Page 134: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

Suppose we know h:ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

O(h log h)

O(n/h)

27

Page 135: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

Suppose we know h:ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

O(h log h)

O(n/h)

O(n

logh

)

27

Page 136: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

O(log h) → Exercise!

Suppose we know h:ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

O(h log h)

O(n/h)

O(n

logh

)

27

Page 137: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

O(log h) → Exercise!

Suppose we know h:ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

O(h log h)

O(n/h)

O(n

logh

)

O(h) · O(n/h) = O(n)

27

Page 138: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

O(log h) → Exercise!

Suppose we know h:ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

O(h log h)

O(n/h)

O(n

logh

)

O(h) · O(n/h) = O(n)

O(n

logh

)

27

Page 139: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

O(log h) → Exercise!

Suppose we know h:ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

O(h log h)

O(n/h)

O(n

logh

)

O(h) · O(n/h) = O(n)

O(n

logh

)

Total: O(n log h)27

Page 140: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

O(log h) → Exercise!

ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

O(h log h)

O(n/h)

O(n

logh

)

O(h) · O(n/h) = O(n)

O(n

logh

)

But in general h is unknown!

27

Page 141: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

O(log h) → Exercise!

ChanHull(P ,h)

Divide P into sets Pi with ≤ h nodesfor i from 1 to dn/he do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to h do

for i = 1 to dn/he doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/hereturn (p1, . . . , ph)

O(h log h)

O(n/h)

O(n

logh

)

O(h) · O(n/h) = O(n)

O(n

logh

)

But in general h is unknown!m

27

Page 142: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

O(m logm)

O(n/m)

O(n

logm

)O

(nlo

gm

)

O(logm)O(m) · O(n/m) = O(n)

ChanHull(P ,m)

Divide P into sets Pi with ≤ m nodesfor i from 1 to dn/me do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to m do

for i = 1 to dn/me doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/mereturn (p1, . . . , pm)

But in general h is unknown!

Total: O(n log h)Total: O(n log h)28

Page 143: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

O(m logm)

O(n/m)

O(n

logm

)O

(nlo

gm

)

O(logm)O(m) · O(n/m) = O(n)

ChanHull(P ,m)

Divide P into sets Pi with ≤ m nodesfor i from 1 to dn/me do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to m do

for i = 1 to dn/me doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/mereturn (p1, . . . , pm)

But in general h is unknown!

Total: O(n log h)Total: O(n log h)28

Page 144: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Chan’s Algorithm

O(m logm)

O(n/m)

O(n

logm

)O

(nlo

gm

)

O(logm)O(m) · O(n/m) = O(n)

ChanHull(P ,m)

Divide P into sets Pi with ≤ m nodesfor i from 1 to dn/me do

Compute with GrahamScan CH(Pi)

p1 = (x1, y1)← rightmost point in Pp0 ← (x1,∞)for j = 1 to m do

for i = 1 to dn/me doqi ← arg max∠pj−1pjq | q ∈ Pi \ pj−1, pj

pj+1 ← arg max∠pj−1pjq | q ∈ q1, . . . , qdn/meif pj+1 = p1 then return (p1, . . . , pj+1)

return failure

But in general h is unknown!

Total: O(n logm)28

Page 145: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What to do with m?

Suggestions?

29

Page 146: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What to do with m?

FullChanHull(P )

for t = 0, 1, 2, . . . do

m =← minn, 22tresult ← ChanHull(P , m)if result 6= failure then break

return result

29

Page 147: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What to do with m?

FullChanHull(P )

for t = 0, 1, 2, . . . do

m =← minn, 22tresult ← ChanHull(P , m)if result 6= failure then break

return result

Running time:

O(n logm) =O(n log 22

t)

29

Page 148: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What to do with m?

FullChanHull(P )

for t = 0, 1, 2, . . . do

m =← minn, 22tresult ← ChanHull(P , m)if result 6= failure then break

return result

Running time:

O(n logm) =O(n log 22

t)

dlog log he∑t=0

O(n log 22t)

29

Page 149: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What to do with m?

FullChanHull(P )

for t = 0, 1, 2, . . . do

m =← minn, 22tresult ← ChanHull(P , m)if result 6= failure then break

return result

Running time:

O(n logm) =O(n log 22

t)

dlog log he∑t=0

O(n log 22t) = O(n)

dlog log he∑t=0

O(2t)

29

Page 150: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What to do with m?

FullChanHull(P )

for t = 0, 1, 2, . . . do

m =← minn, 22tresult ← ChanHull(P , m)if result 6= failure then break

return result

Running time:

O(n logm) =O(n log 22

t)

dlog log he∑t=0

O(n log 22t) = O(n)

dlog log he∑t=0

O(2t)

≤ O(n) · O(2log log h)

29

Page 151: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What to do with m?

FullChanHull(P )

for t = 0, 1, 2, . . . do

m =← minn, 22tresult ← ChanHull(P , m)if result 6= failure then break

return result

Running time:

O(n logm) =O(n log 22

t)

dlog log he∑t=0

O(n log 22t) = O(n)

dlog log he∑t=0

O(2t)

≤ O(n) · O(2log log h) = O(n) · O(log h)

29

Page 152: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What to do with m?

FullChanHull(P )

for t = 0, 1, 2, . . . do

m =← minn, 22tresult ← ChanHull(P , m)if result 6= failure then break

return result

Running time:

O(n logm) =O(n log 22

t)

dlog log he∑t=0

O(n log 22t) = O(n)

dlog log he∑t=0

O(2t)

≤ O(n) · O(2log log h) = O(n) · O(log h)= O(n log h)

29

Page 153: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

What to do with m?

FullChanHull(P )

for t = 0, 1, 2, . . . do

m =← minn, 22tresult ← ChanHull(P , m)if result 6= failure then break

return result

Theorem 3: The convex hull CH(P ) of n points P in R2 canbe computed in O(n log h) time with Chan’sAlgorithm, where h = |CH(P )|.

29

Page 154: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Discussion

Is it possible to compute faster than O(n log n) or O(n log h) time?

30

Page 155: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Discussion

Is it possible to compute faster than O(n log n) or O(n log h) time?

Generally not! An algorithm to compute the convex hull can also sort(exercise!) ⇒ lower bound Ω(n log n).

30

Page 156: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Discussion

Is it possible to compute faster than O(n log n) or O(n log h) time?

Generally not! An algorithm to compute the convex hull can also sort(exercise!) ⇒ lower bound Ω(n log n).

What happens in Graham’s Scan when sorting P is not unique?

30

Page 157: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Discussion

Is it possible to compute faster than O(n log n) or O(n log h) time?

Generally not! An algorithm to compute the convex hull can also sort(exercise!) ⇒ lower bound Ω(n log n).

What happens in Graham’s Scan when sorting P is not unique?

Use lexicographic order!

30

Page 158: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Discussion

Is it possible to compute faster than O(n log n) or O(n log h) time?

Generally not! An algorithm to compute the convex hull can also sort(exercise!) ⇒ lower bound Ω(n log n).

What happens in Graham’s Scan when sorting P is not unique?

Use lexicographic order!

What happens with collinear points in CH(P )?

30

Page 159: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Discussion

Is it possible to compute faster than O(n log n) or O(n log h) time?

Generally not! An algorithm to compute the convex hull can also sort(exercise!) ⇒ lower bound Ω(n log n).

What happens in Graham’s Scan when sorting P is not unique?

Use lexicographic order!

What happens with collinear points in CH(P )?

Graham: Forms no right turn, so an interior point is deleted.Jarvis: Choose farthest point

30

Page 160: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Discussion

Is it possible to compute faster than O(n log n) or O(n log h) time?

Generally not! An algorithm to compute the convex hull can also sort(exercise!) ⇒ lower bound Ω(n log n).

What happens in Graham’s Scan when sorting P is not unique?

Use lexicographic order!

What happens with collinear points in CH(P )?

Graham: Forms no right turn, so an interior point is deleted.Jarvis: Choose farthest point

What about the robustness of the algorithms?

30

Page 161: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Discussion

Is it possible to compute faster than O(n log n) or O(n log h) time?

Generally not! An algorithm to compute the convex hull can also sort(exercise!) ⇒ lower bound Ω(n log n).

What happens in Graham’s Scan when sorting P is not unique?

Use lexicographic order!

What happens with collinear points in CH(P )?

Graham: Forms no right turn, so an interior point is deleted.Jarvis: Choose farthest point

What about the robustness of the algorithms?

Regarding robustness: imprecision of floating-point arithmeticFirstConvexHull possibly produces a valid polygonGraham and Jarvis always provide a polygon, but it may have minordefects

30

Page 162: Introduction & Convex Hulls - KIT...Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization Exercises Every second Wednesday

Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls

Designing Geometric Algorithms–Guidelines

1.) Eliminate degenerate cases (→ general position)unique x-coordinatesno three collinear points. . .

2.) Adjust degenerate inputsintegrate into existing solutions(e.g., compute lexicographic order if x-coordinates are notunique)may require special treament

3.) Implementationprimitive operations (available in libraries?)robustness

31