convex hull 2012/10/23. convex vs. concave a polygon p is convex if for every pair of points x and y...
DESCRIPTION
3 The convex hull problem The convex hull of a set of planar points is the smallest convex polygon containing all of the points. concave polygon:convex polygon:TRANSCRIPT
![Page 1: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/1.jpg)
Convex Hull
2012/10/23
![Page 2: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/2.jpg)
Convex vs. Concave
• A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is called concave.
x yP x yP
convexconcave
![Page 3: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/3.jpg)
3
The convex hull problem
• The convex hull of a set of planar points is the smallest convex polygon containing all of the points.
concave polygon: convex polygon:
![Page 4: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/4.jpg)
Graham’s Scan
• Start at point guaranteed to be on the hull. (the point with the minimum y value)
• Sort remaining points by polar angles of vertices relative to the first point.
• Go through sorted points, keeping vertices of points that have left turns and dropping points that have right turns.
![Page 5: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/5.jpg)
Graham’s Scan
![Page 6: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/6.jpg)
Graham’s Scan
![Page 7: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/7.jpg)
Graham’s Scan
![Page 8: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/8.jpg)
Graham’s Scan
![Page 9: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/9.jpg)
Graham’s Scan
![Page 10: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/10.jpg)
Graham’s Scan
![Page 11: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/11.jpg)
Graham’s Scan
![Page 12: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/12.jpg)
Graham’s Scan
![Page 13: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/13.jpg)
Graham’s Scan
![Page 14: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/14.jpg)
Graham’s Scan
![Page 15: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/15.jpg)
Graham’s Scan
![Page 16: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/16.jpg)
Graham’s Scan
![Page 17: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/17.jpg)
Graham’s Scan
![Page 18: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/18.jpg)
Graham’s Scan
![Page 19: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/19.jpg)
Graham’s Runtime
• Graham’s scan is O(n log n) due to initial sort of angles.
![Page 20: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/20.jpg)
A more detailed algorithm
![Page 21: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/21.jpg)
![Page 22: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/22.jpg)
![Page 23: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/23.jpg)
Convex Hullby Divide-and-Conquer
• First, sort all points by their x coordinate.– ( O(n log n) time)
• Then divide and conquer:– Find the convex hull of the left half of points.– Find the convex hull of the right half of
points.– Merge the two hulls into one.
![Page 24: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/24.jpg)
5
Hull of S by exhaustive search;
![Page 25: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/25.jpg)
![Page 26: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/26.jpg)
![Page 27: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/27.jpg)
![Page 28: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/28.jpg)
![Page 29: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/29.jpg)
Lower Tangent Example•Initially, T=(4, 7) is only a lower tangent for A. The A loop does not execute, but the B loop increments b to 11.•But now T=(4, 11) is no longer a lower tangent for A, so the A loop decrements a to 0.•T=(0, 11) is not a lower tangent for B, so b is incremented to 12.• T=(0, 12) is a lower tangent for both A and B, and T is returned.
![Page 30: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/30.jpg)
![Page 31: Convex Hull 2012/10/23. Convex vs. Concave A polygon P is convex if for every pair of points x and y in P, the line xy is also in P; otherwise, it is](https://reader030.vdocuments.mx/reader030/viewer/2022020301/5a4d1b617f8b9ab0599adcb2/html5/thumbnails/31.jpg)
Q&A