Top Banner
Dr. Tamara Mchedlidze · Dr. Darren Strash · Computational Geometry Lecture Introduction & Convex Hulls Chih-Hung Liu · Tamara Mchedlidze Computational Geometry · Lecture INSTITUT F ¨ UR THEORETISCHE INFORMATIK · FAKULT ¨ AT F ¨ UR INFORMATIK Introduction & Convex Hulls 18.4.2018 1
158

Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

Jun 13, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Chih-Hung Liu · Tamara Mchedlidze

Computational Geometry · Lecture

INSTITUT FUR THEORETISCHE INFORMATIK · FAKULTAT FUR INFORMATIK

Introduction & Convex Hulls

18.4.2018

1

Page 2: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

AlgoGeom-Team

Lecturers

• Tamara Mchedlidze• [email protected]• Room 307• Office hours: by

appointment

• Chih-Hung Liu• [email protected]• ETH Zurich• Office hours: by

appointment

2

Page 3: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

AlgoGeom-Team

Lecturers

Exercise Leader

• Guido Bruckner• [email protected]• Room 317• Office hours: by appointment

• Tamara Mchedlidze• [email protected]• Room 307• Office hours: by

appointment

• Chih-Hung Liu• [email protected]• ETH Zurich• Office hours: by

appointment

2

Page 4: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

AlgoGeom-Team

Lecturers

Exercise Leader

• Guido Bruckner• [email protected]• Room 317• Office hours: by appointment

Schedule

• Lecture: Wed. 14:00 – 15:30 SR 301• Exercises: Mon. 15:45 – 17:15, SR 236 (starting ?)

• Tamara Mchedlidze• [email protected]• Room 307• Office hours: by

appointment

• Chih-Hung Liu• [email protected]• ETH Zurich• Office hours: by

appointment

2

Page 5: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Organization

Websitehttp://i11www.iti.kit.edu/teaching/sommer2018/compgeom/• Course Information• Lecture Slides• Exercises• Additional Material

3

Page 6: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Organization

Websitehttp://i11www.iti.kit.edu/teaching/sommer2018/compgeom/• Course Information• Lecture Slides• Exercises• Additional 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

Prior Knowledge: Algorithms and Elementary Geometry3

Page 7: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Organization

Exercises• Every second Monday starting 27.04• Exercise problems posted at least one week before an

exercise session.• Reinforce lecture material, help prepare for exam.

What will the exercises involve?• Independent or group preparation• Weekly meetings in class• Active participation in class is expected - we expect that

you present at least one solution on the board• Can hand in exercises for feedback

4

Page 8: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 definitions• understand the discussed algorithms, and explain and analyze them• select and adapt appropriate algorithms and data structures• analyze new geometric problems and develop efficient solutions

5

Page 9: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 definitions• understand the discussed algorithms, and explain and analyze them• select and adapt appropriate algorithms and data structures• analyze new geometric problems and develop efficient solutions

5

Page 10: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 definitions• understand the discussed algorithms, and explain and analyze them• select and adapt appropriate algorithms and data structures• analyze new geometric problems and develop efficient solutions

Course Time Breakdown:• Time in lectures and exercise sessions• Preparation and review• Working on exercises• Exam preparation

ca. 35h

5LP = 150h

ca. 45hca. 30hca. 30h

5

Page 11: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

6

Page 12: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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!

6

Page 13: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

What is Computational Geometry?

7

Page 14: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

7

Page 15: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 Processing• Visualization• Geographic 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...

7

Page 16: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 Processing• Visualization• Geographic Information Systems (GIS)• Robotics• . . .

Central Themes• Geometric algorithms and data structures• Discrete 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...

7

Page 17: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

8

Page 18: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

8

Page 19: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

!

8

Page 20: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 in Natural sciences, Geometry, Informatics,Health, Engeneering,...

8

Page 21: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

9

Page 22: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

9

Page 23: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

9

Page 24: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

10

Page 25: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

10

Page 26: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

10

Page 27: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 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?

(Line Segment Intersections)

10

Page 28: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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.

11

Page 29: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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.(Point Location)

11

Page 30: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

12

Page 31: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

12

Page 32: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

12

Page 33: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Topics

We will cover the following topics:• Convex Hulls• Line Segment Intersection• Polygon Triangulation• Geometric Linear Programming• Data Structures for Range Queries• Data Structure for Point Location Queries• Voronoi Diagrams and Delaunay Triangulation• Duality of Points and Lines• Quadtrees• Well-Separated Pair Decompositions• Visibility Graphs

13

Page 34: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Convex Hulls

14

Page 35: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

15

Page 36: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

15

Page 37: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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!

15

Page 38: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

15

Page 39: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

15

Page 40: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

15

Page 41: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

15

Page 42: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

15

Page 43: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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.

15

Page 44: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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.

15

Page 45: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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, line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

16

Page 46: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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, line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

16

Page 47: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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, line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

In mathematics:• define CH(S) =

⋂C⊇S : C convex

C

16

Page 48: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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, line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

In physics:• put a large rubber band

around all points

In mathematics:• define CH(S) =

⋂C⊇S : C convex

C

16

Page 49: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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, line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

In physics:• put a large rubber band

around all points• and let it go!

In mathematics:• define CH(S) =

⋂C⊇S : C convex

C

16

Page 50: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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, line pq ∈ S.The convex hull CH(S) of S is the smallest convexregion containing S.

In physics:• put a large rubber band

around all points• and let it go!

unfortunately none help algorithmically

In mathematics:• define CH(S) =

⋂C⊇S : C convex

C

16

Page 51: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 .

17

Page 52: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

17

Page 53: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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, q• strictly right of the oriented line −→pq or• on the line segment pq

p q

−→pq

17

Page 54: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

18

Page 55: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

18

Page 56: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

18

Page 57: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

19

Page 58: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

)

19

Page 59: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

19

Page 60: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

19

Page 61: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

19

Page 62: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

19

Page 63: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

19

Page 64: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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.

19

Page 65: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

19

Page 66: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

20

Page 67: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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!

20

Page 68: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

20

Page 69: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

?

20

Page 70: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 L20

Page 71: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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!

20

Page 72: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

21

Page 73: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

21

Page 74: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

?

21

Page 75: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 once• A point in L is removed at most once from L• ⇒ Running time of the for loop including the while loop is O(n)

21

Page 76: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 once• A 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

)

21

Page 77: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 once• A 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.

21

Page 78: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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.

22

Page 79: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

22

Page 80: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 81: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 82: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 83: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 84: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 85: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 86: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 87: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 88: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 89: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 90: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 91: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 92: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 93: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

22

Page 94: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

22

Page 95: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

22

Page 96: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

22

Page 97: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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!

22

Page 98: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Comparison

Which algorithm is better?

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

23

Page 99: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Comparison

Which algorithm is better?

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

It depends on how large CH(P ) is!

23

Page 100: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Comparison

Which algorithm is better?

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

It depends on how large CH(P ) is!

Idea: Combine the two approaches into an optimal algorithm!

23

Page 101: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

24

Page 102: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

24

Page 103: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

24

Page 104: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

25

Page 105: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

25

Page 106: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

25

Page 107: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

25

Page 108: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

25

Page 109: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

25

Page 110: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

25

Page 111: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 112: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 113: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 114: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 115: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 116: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 117: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 118: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 119: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 120: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 121: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 122: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 123: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 124: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 125: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 126: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Example

n = 16

GrahamScan

Gift Wrapping25

Page 127: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

26

Page 128: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

26

Page 129: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

26

Page 130: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

26

Page 131: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

)

26

Page 132: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

)

26

Page 133: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

26

Page 134: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

)

26

Page 135: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Page 136: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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!

26

Page 137: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

26

Page 138: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Page 139: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Page 140: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Page 141: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

What to do with m?

Suggestions?

28

Page 142: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

28

Page 143: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

28

Page 144: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

28

Page 145: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

28

Page 146: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

28

Page 147: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

28

Page 148: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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)

28

Page 149: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

28

Page 150: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

29

Page 151: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

29

Page 152: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

29

Page 153: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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!

29

Page 154: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

29

Page 155: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

29

Page 156: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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?

29

Page 157: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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 arithmetic• FirstConvexHull possibly produces a valid polygon• Graham and Jarvis always provide a polygon, but it may have minor

defects29

Page 158: Introduction & Convex Hulls Computational Geometry Lecture · 2018-04-18 · Dr. Tamara Mchedlidze Dr. Darren Strash Computational Geometry Lecture Introduction & Convex Hulls Organization

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

Designing Geometric Algorithms–Guidelines

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

2.) Adjust degenerate inputs• integrate into existing solutions

(e.g., compute lexicographic order if x-coordinates are notunique)• may require special treament

3.) Implementation• primitive operations (available in libraries?)• robustness

30