SlideShare a Scribd company logo
7
Most read
13
Most read
15
Most read
CONVEX HULL
Yitian Huang & Zhe Yang
Apr 22, 2016
1
Definition Of Convex HULL
Simply, given a set of points P in a plane, the convex hull of this set is the smallest convex polygon that
contains all points of it.
(A set of points and its convex hull)
2
We will introduce an O(nlogh) algorithm known as Chan’s
Algorithm, where h refers the number of points in the hull.
However, Chan’s Algorithm is based on other two
algorithms known as Jarvis’s Algorithm O(nh) and Graham’s
Algorithm O(nlogn).
So, we will talk about these two algorithms first.
3
Before Start…
• Counterclockwise and Clockwise
• It’s relative
• In this presentation
• Use function orient(p, q, i) to calculate the
relationship of pq and pi.
• Obviously, orient(p, q, i) = - orient(p, i, q)
• Extreme points
• There will be four extreme points
• All of them MUST be in the hull lastly
• Most algorithm choose to start with one of the
extreme points.
• In this presentation
• All algorithms will start will the left most point.
4
Jarvis’s Algorithm
5
Jarvis’s Algorithm
• Perhaps the simplest algorithm for computing Convex Hull
• In the two-dimensional case the algorithm is also known as Jarvis march, after R. A. Jarvis, who
published it in 1973.
• It has a more visual name: ‘Gift Wrapping’.
6
HOW IT WORKS?
1. Start with the left most point, l.
2. Let p = l, find out the point q that
appears to be furthest to the
right to someone standing at p
and looking at other points. (by
comparing all others points)
That’s is: orient(p, q, i) < 0 is always
true for all other points.
3. Set q as p, and use p as the start
point and use the same method
to find the next q.
4. Keep doing step 3, until q is equal
to l.
O(n)
O(h)
Total: O(nh)
O(n)
7
GRAHAM’S ALGORITHM
8
GRAHAM’S ALGORITHM
• It is named after Ronald Graham, who published the original algorithm in 1972.
• Also know as Graham’s scan, first explicitly sorts the points and then scanning algorithm to finish
building the hull.
• Basically, sort + scan.
9
HOW IT WORKS?
1. Start with the left most point, l.
2. Sorts all other points in
counterclockwise order around l.
That’s is: orient(l, i, i+1) > 0 is always
true for all points i.
3. Start with l, let p = l, q = l +1, i = l +
2.
4. Check orient(p, q, i)
• If < 0, move forward, let p = q, q =i, i =
i +1;
• If > 0, remove q, let p = p-1, q = p ;
5. Keep doing step 4, until all points
have been checked.
O(nlogn)
O(n)
Total: O(nlogn)
O(n)
SORTSCAN
10
CHAN’S ALGORITHM
11
Chan’s Algorithm = Jarvis's + Graham’s + ...
• It was discovered by Timothy Chan in 1993.
• It’s a combination of divide-and-conquer, gift-wrapping and graham’s scan.
• it’s output-sensitive, which means its running time depends on the size of its output (or input).
12
HOW IT WORKS?
1. Find a magic value of ‘m’, which
divides all points into n/m subsets,
and each subset has m points,
approximately.
2. To each subset, use Graham’s
algorithm to compute its sub-hull.
3. To all sub-hulls, use Jarvis’s
algorithm to compute the final
convex hull.
• Choose one extreme point as the start
point, and compare the right tangents
of all sub-hulls.
• Choose the rightest one as the next
point.
• Start with the next point, and do it
again, until the next point is equal to
the start point
13
Find Magic ‘m’
• The core of Chan’s algorithm is how to figure out the value of m. (The object is to make m very close to
h, or equal)
• Chan proposed a amazing trick here:
• We set a parameter t = 1 and set m = 2^(2^t).
• Then use this m to execute Chan’s Algorithm, in step 3, we set a counter for the output number of points in the
hull. Once the counter reaches value m, it terminate the algorithm and increment t by 1, re-calculate the value
m, and do it again!
• By doing this, the time for running this algorithm will always be less than O(nlogm).
14
TIME COMPLEXITY
• We divided points into n/m parts, so each part has m
points.
• Since the algorithm will be terminated when it number
of output reaches m, so this step will at most cost
O(nlogm), when m is small.
• For step 2
• It’s O((n/m) * mlogm) = O(nlogm)
• For step 3
• Finding one extreme point, O(n).
• tangents
• Finding the right tangents of one sub-hull, O(logm).
• There are n/m sub-hulls, so O((n/m)logm)
• There are h points in the hull. O(h*(n/m)logm) = O(nlogh)
when h=m.
• Totally, it’s O(nlogh).
1. Find a magic value of ‘m’, which
divides all points into n/m subsets,
and each subset has m points,
approximately.
2. To each subset, use Graham’s
algorithm to compute its sub-hull.
3. To all sub-hulls, use Jarvis’s
algorithm to compute the final
convex hull.
• Choose one extreme point as the start
point, and compare the right tangents
of all sub-hulls.
• Choose the rightest one as the next
point.
• Start with the next point, and do it
again,until the next point is equal to
the start point
15
16
REFERENCES
• [1]. https://en.wikipedia.org/wiki/Chan%27s_algorithm
• [2]. http://tomswitzer.net/2010/12/2d-convex-hulls-chans-algorithm/
• [3]. http://jeffe.cs.illinois.edu/teaching/373/notes/x05-convexhull.pdf
• [4]. http://www.utdallas.edu/~daescu/convexhull.pdf
• [5]. http://www.geeksforgeeks.org/convex-hull-set-1-jarviss-algorithm-or-wrapping/
• [6]. http://www.geeksforgeeks.org/convex-hull-set-2-graham-scan/
17
THANK YOU!
QUESTIONS?
An example for Gift-wrapping
NOT Chan’s Algorithm!
18

More Related Content

PPTX
Convex Hull Algorithms
PPTX
convex hull
PPT
Shading
PDF
Applied numerical methods lec8
PPT
Window to viewport transformation
PPTX
convex hull
PPTX
Coin Change : Greedy vs Dynamic Programming
PDF
Travelling SalesMan Problem(TSP)
Convex Hull Algorithms
convex hull
Shading
Applied numerical methods lec8
Window to viewport transformation
convex hull
Coin Change : Greedy vs Dynamic Programming
Travelling SalesMan Problem(TSP)

What's hot (20)

PPTX
Generating code from dags
PPT
Computational Learning Theory
PDF
Convex hull
PPT
Heuristc Search Techniques
PPTX
Visible surface determination
PPTX
Lecture 21 problem reduction search ao star search
PDF
Cauchy riemann equations
PPT
PPTX
Computer Graphic - Lines, Circles and Ellipse
PPT
Map projection
PPT
Hidden surfaces
PDF
Knowledge based agent
PPTX
N queen problem
DOC
Unit 3 daa
PDF
Controlled dropout: a different dropout for improving training speed on deep ...
PPTX
Reinforcement learning:policy gradient (part 1)
PPTX
Longest Common Subsequence
PPTX
Scan line method
PPT
Three dimensional concepts - Computer Graphics
Generating code from dags
Computational Learning Theory
Convex hull
Heuristc Search Techniques
Visible surface determination
Lecture 21 problem reduction search ao star search
Cauchy riemann equations
Computer Graphic - Lines, Circles and Ellipse
Map projection
Hidden surfaces
Knowledge based agent
N queen problem
Unit 3 daa
Controlled dropout: a different dropout for improving training speed on deep ...
Reinforcement learning:policy gradient (part 1)
Longest Common Subsequence
Scan line method
Three dimensional concepts - Computer Graphics
Ad

Similar to Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and Zhe Yang (20)

PDF
Convex hulls & Chan's algorithm
PPT
Discrete Computaional Geometry
PDF
Unit ii divide and conquer -4
PPT
convexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHulls
PPT
Mba admission in india
PDF
20 convex hull last 7
PPT
5.2 divede and conquer 03
PPT
5.2 divede and conquer 03
PDF
A New Approach to Output-Sensitive Voronoi Diagrams and Delaunay Triangulations
PPTX
Brute Force and Divide & Conquer Technique
PDF
Convex hull in 3D
PPTX
An Efficient Convex Hull Algorithm for a Planer Set of Points
PPT
A Tutorial on Computational Geometry
PPTX
A sweepline algorithm for Voronoi Diagrams
PPTX
DYNAMIC PROGRAMMING AND GREEDY TECHNIQUE
PPTX
LU-17 Closest pair and convex hull using divide and conquer.pptx
PPT
Lec12
PDF
Output-Sensitive Voronoi Diagrams and Delaunay Triangulations
Convex hulls & Chan's algorithm
Discrete Computaional Geometry
Unit ii divide and conquer -4
convexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHulls
Mba admission in india
20 convex hull last 7
5.2 divede and conquer 03
5.2 divede and conquer 03
A New Approach to Output-Sensitive Voronoi Diagrams and Delaunay Triangulations
Brute Force and Divide & Conquer Technique
Convex hull in 3D
An Efficient Convex Hull Algorithm for a Planer Set of Points
A Tutorial on Computational Geometry
A sweepline algorithm for Voronoi Diagrams
DYNAMIC PROGRAMMING AND GREEDY TECHNIQUE
LU-17 Closest pair and convex hull using divide and conquer.pptx
Lec12
Output-Sensitive Voronoi Diagrams and Delaunay Triangulations
Ad

More from Amrinder Arora (20)

PPTX
NP-Completeness - II
PPTX
Graph Traversal Algorithms - Breadth First Search
PPTX
Graph Traversal Algorithms - Depth First Search Traversal
PDF
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
PDF
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet Mahana
PDF
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
PDF
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
PDF
Proof of Cook Levin Theorem (Presentation by Xiechuan, Song and Shuo)
PPTX
Online algorithms in Machine Learning
PPTX
NP completeness
PPTX
Algorithmic Puzzles
PPTX
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
PPTX
Dynamic Programming - Part II
PPTX
Dynamic Programming - Part 1
PPTX
Greedy Algorithms
PPTX
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
PPTX
Divide and Conquer - Part 1
PPTX
Asymptotic Notation and Data Structures
PPTX
Introduction to Algorithms and Asymptotic Notation
PPTX
Set Operations - Union Find and Bloom Filters
NP-Completeness - II
Graph Traversal Algorithms - Breadth First Search
Graph Traversal Algorithms - Depth First Search Traversal
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet Mahana
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Proof of Cook Levin Theorem (Presentation by Xiechuan, Song and Shuo)
Online algorithms in Machine Learning
NP completeness
Algorithmic Puzzles
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Dynamic Programming - Part II
Dynamic Programming - Part 1
Greedy Algorithms
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Divide and Conquer - Part 1
Asymptotic Notation and Data Structures
Introduction to Algorithms and Asymptotic Notation
Set Operations - Union Find and Bloom Filters

Recently uploaded (20)

PPTX
Introduction and Scope of Bichemistry.pptx
PDF
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
PPTX
How to Manage Bill Control Policy in Odoo 18
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
IMMUNIZATION PROGRAMME pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
Introduction and Scope of Bichemistry.pptx
What Is Coercive Control? Understanding and Recognizing Hidden Abuse
Insiders guide to clinical Medicine.pdf
Cardiovascular Pharmacology for pharmacy students.pptx
How to Manage Bill Control Policy in Odoo 18
human mycosis Human fungal infections are called human mycosis..pptx
IMMUNIZATION PROGRAMME pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Electrolyte Disturbances and Fluid Management A clinical and physiological ap...
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
O7-L3 Supply Chain Operations - ICLT Program
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Open Quiz Monsoon Mind Game Prelims.pptx
Renaissance Architecture: A Journey from Faith to Humanism
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
How to Manage Loyalty Points in Odoo 18 Sales
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf

Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and Zhe Yang

  • 1. CONVEX HULL Yitian Huang & Zhe Yang Apr 22, 2016 1
  • 2. Definition Of Convex HULL Simply, given a set of points P in a plane, the convex hull of this set is the smallest convex polygon that contains all points of it. (A set of points and its convex hull) 2
  • 3. We will introduce an O(nlogh) algorithm known as Chan’s Algorithm, where h refers the number of points in the hull. However, Chan’s Algorithm is based on other two algorithms known as Jarvis’s Algorithm O(nh) and Graham’s Algorithm O(nlogn). So, we will talk about these two algorithms first. 3
  • 4. Before Start… • Counterclockwise and Clockwise • It’s relative • In this presentation • Use function orient(p, q, i) to calculate the relationship of pq and pi. • Obviously, orient(p, q, i) = - orient(p, i, q) • Extreme points • There will be four extreme points • All of them MUST be in the hull lastly • Most algorithm choose to start with one of the extreme points. • In this presentation • All algorithms will start will the left most point. 4
  • 6. Jarvis’s Algorithm • Perhaps the simplest algorithm for computing Convex Hull • In the two-dimensional case the algorithm is also known as Jarvis march, after R. A. Jarvis, who published it in 1973. • It has a more visual name: ‘Gift Wrapping’. 6
  • 7. HOW IT WORKS? 1. Start with the left most point, l. 2. Let p = l, find out the point q that appears to be furthest to the right to someone standing at p and looking at other points. (by comparing all others points) That’s is: orient(p, q, i) < 0 is always true for all other points. 3. Set q as p, and use p as the start point and use the same method to find the next q. 4. Keep doing step 3, until q is equal to l. O(n) O(h) Total: O(nh) O(n) 7
  • 9. GRAHAM’S ALGORITHM • It is named after Ronald Graham, who published the original algorithm in 1972. • Also know as Graham’s scan, first explicitly sorts the points and then scanning algorithm to finish building the hull. • Basically, sort + scan. 9
  • 10. HOW IT WORKS? 1. Start with the left most point, l. 2. Sorts all other points in counterclockwise order around l. That’s is: orient(l, i, i+1) > 0 is always true for all points i. 3. Start with l, let p = l, q = l +1, i = l + 2. 4. Check orient(p, q, i) • If < 0, move forward, let p = q, q =i, i = i +1; • If > 0, remove q, let p = p-1, q = p ; 5. Keep doing step 4, until all points have been checked. O(nlogn) O(n) Total: O(nlogn) O(n) SORTSCAN 10
  • 12. Chan’s Algorithm = Jarvis's + Graham’s + ... • It was discovered by Timothy Chan in 1993. • It’s a combination of divide-and-conquer, gift-wrapping and graham’s scan. • it’s output-sensitive, which means its running time depends on the size of its output (or input). 12
  • 13. HOW IT WORKS? 1. Find a magic value of ‘m’, which divides all points into n/m subsets, and each subset has m points, approximately. 2. To each subset, use Graham’s algorithm to compute its sub-hull. 3. To all sub-hulls, use Jarvis’s algorithm to compute the final convex hull. • Choose one extreme point as the start point, and compare the right tangents of all sub-hulls. • Choose the rightest one as the next point. • Start with the next point, and do it again, until the next point is equal to the start point 13
  • 14. Find Magic ‘m’ • The core of Chan’s algorithm is how to figure out the value of m. (The object is to make m very close to h, or equal) • Chan proposed a amazing trick here: • We set a parameter t = 1 and set m = 2^(2^t). • Then use this m to execute Chan’s Algorithm, in step 3, we set a counter for the output number of points in the hull. Once the counter reaches value m, it terminate the algorithm and increment t by 1, re-calculate the value m, and do it again! • By doing this, the time for running this algorithm will always be less than O(nlogm). 14
  • 15. TIME COMPLEXITY • We divided points into n/m parts, so each part has m points. • Since the algorithm will be terminated when it number of output reaches m, so this step will at most cost O(nlogm), when m is small. • For step 2 • It’s O((n/m) * mlogm) = O(nlogm) • For step 3 • Finding one extreme point, O(n). • tangents • Finding the right tangents of one sub-hull, O(logm). • There are n/m sub-hulls, so O((n/m)logm) • There are h points in the hull. O(h*(n/m)logm) = O(nlogh) when h=m. • Totally, it’s O(nlogh). 1. Find a magic value of ‘m’, which divides all points into n/m subsets, and each subset has m points, approximately. 2. To each subset, use Graham’s algorithm to compute its sub-hull. 3. To all sub-hulls, use Jarvis’s algorithm to compute the final convex hull. • Choose one extreme point as the start point, and compare the right tangents of all sub-hulls. • Choose the rightest one as the next point. • Start with the next point, and do it again,until the next point is equal to the start point 15
  • 16. 16
  • 17. REFERENCES • [1]. https://en.wikipedia.org/wiki/Chan%27s_algorithm • [2]. http://tomswitzer.net/2010/12/2d-convex-hulls-chans-algorithm/ • [3]. http://jeffe.cs.illinois.edu/teaching/373/notes/x05-convexhull.pdf • [4]. http://www.utdallas.edu/~daescu/convexhull.pdf • [5]. http://www.geeksforgeeks.org/convex-hull-set-1-jarviss-algorithm-or-wrapping/ • [6]. http://www.geeksforgeeks.org/convex-hull-set-2-graham-scan/ 17
  • 18. THANK YOU! QUESTIONS? An example for Gift-wrapping NOT Chan’s Algorithm! 18

Editor's Notes

  • #5: Two concepts