Download - Convex hull
![Page 1: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/1.jpg)
Convex hull smallest convex setcontaining all the points
![Page 2: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/2.jpg)
Convex hull smallest convex setcontaining all the points
![Page 3: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/3.jpg)
Convex hull smallest convex setcontaining all the points
representation = circular doubly-linked list of pointson the boundary of the convex hull
1
2
3
4
1.next = 2 = 3.prev2.next = 3 = 4.prev3.next = 4 = 1.prev4.next = 1 = 2.prev
start = 1
![Page 4: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/4.jpg)
Jarvis march
find the left-most point
(assume no 3 points colinear)
s
![Page 5: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/5.jpg)
Jarvis march
find the point that appears most to the right looking from s
(assume no 3 points colinear)
s
![Page 6: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/6.jpg)
Jarvis march (assume no 3 points colinear)
s
p
find the point that appears most to the right looking from p
![Page 7: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/7.jpg)
Jarvis march (assume no 3 points colinear)
![Page 8: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/8.jpg)
Jarvis march (assume no 3 points colinear)
![Page 9: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/9.jpg)
Jarvis march (assume no 3 points colinear)
s point with smallest x-coordp srepeat PRINT(p) q point other than p for i from 1 to n do if i p and point i to the right of line (p,q) then q i p quntil p = s
![Page 10: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/10.jpg)
Jarvis march (assume no 3 points colinear)
Running time = O(n.h)
![Page 11: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/11.jpg)
Graham scan (assume no 3 points colinear)
start with a simple polygon containing all the pointsfix it in time O(n)
O(n log n)homework
![Page 12: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/12.jpg)
Graham scan (assume no 3 points colinear)
![Page 13: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/13.jpg)
Graham scan (assume no 3 points colinear)
![Page 14: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/14.jpg)
Graham scan (assume no 3 points colinear)
![Page 15: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/15.jpg)
Graham scan (assume no 3 points colinear)
![Page 16: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/16.jpg)
Graham scan (assume no 3 points colinear)
![Page 17: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/17.jpg)
Graham scan (assume no 3 points colinear)
![Page 18: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/18.jpg)
Graham scan (assume no 3 points colinear)
A startB next(A)C next(B)
repeat 2n times if C is to the right of AB then A.next C; C.prev A B A A prev(A) else A B B C C next(C)
![Page 19: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/19.jpg)
Closest pair of points
![Page 20: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/20.jpg)
Closest pair of points
![Page 21: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/21.jpg)
Closest pair of points
2T(n/2) min(left,right)
![Page 22: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/22.jpg)
Closest pair of points
2T(n/2) min(left,right)
![Page 23: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/23.jpg)
Closest pair of points
2T(n/2) min(left,right)
![Page 24: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/24.jpg)
Closest pair of points
X sort the points by x-coordinateY sort the points by y-coordinate
pre-processing
Closest-pair(S) if |S|=1 then return if |S|=2 then return the distance of the pair split S into S1 and S2 by the X-coord 1 Closest-pair(S1), 2 Closest-pair(S2) min(1,2) for points x in according to Y check 12 points around x, update if a closer pair found
![Page 25: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/25.jpg)
Smallest enclosing disc
![Page 26: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/26.jpg)
Smallest enclosing disc
![Page 27: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/27.jpg)
Smallest enclosing disc
The smallest enclosing disc is unique.Claim #1:
![Page 28: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/28.jpg)
Smallest enclosing disc
The smallest enclosing disc is unique.Claim #1:
![Page 29: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/29.jpg)
Smallest enclosing disc
SED(S) pick a random point x S (c,r) SED(S-{x}) if xDisc(c,r) then return (c,r) else return SED-with-point(S,x)
![Page 30: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/30.jpg)
Smallest enclosing discSED(S) pick a random point x S (c,r) SED(S-{x}) if xDisc(c,r) then return (c,r) else return SED-with-point(S,x)
SED-with-point(S,y) pick a random point x S (c,r) SED-with-point(S-{x},y) if xDisc(c,r) then return (c,r) else return SED-with-2-points(S,y,x)
![Page 31: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/31.jpg)
Smallest enclosing discSED(S) pick a random point x S (c,r) SED(S-{x}) if xDisc(c,r) then return (c,r) else return SED-with-point(S,x)
SED-with-2-point(S,y,z) pick a random point x S (c,r) SED-with-2-points(S-{x},y,z) if xDisc(c,r) then return (c,r) else return circle given by x,y,z
SED-with-point(S,y) pick a random point x S (c,r) SED-with-point(S-{x},y) if xDisc(c,r) then return (c,r) else return SED-with-2-points(S,y,x)
![Page 32: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/32.jpg)
Running time ?SED(S) pick a random point x S (c,r) SED(S-{x}) if xDisc(c,r) then return (c,r) else return SED-with-point(S,x)
SED-with-2-point(S,y,z) pick a random point x S (c,r) SED-with-2-points(S-{x},y,z) if xDisc(c,r) then return (c,r) else return circle given by x,y,z
SED-with-point(S,y) pick a random point x S (c,r) SED-with-point(S-{x},y) if xDisc(c,r) then return (c,r) else return SED-with-2-points(S,y,x)
![Page 33: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/33.jpg)
Running time ?SED(S) pick a random point x S (c,r) SED(S-{x}) if xDisc(c,r) then return (c,r) else return SED-with-point(S,x)
SED-with-2-point(S,y,z) pick a random point x S (c,r) SED-with-2-points(S-{x},y,z) if xDisc(c,r) then return (c,r) else return circle given by x,y,z
SED-with-point(S,y) pick a random point x S (c,r) SED-with-point(S-{x},y) if xDisc(c,r) then return (c,r) else return SED-with-2-points(S,y,x)
O(n)
![Page 34: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/34.jpg)
Running time ?SED(S) pick a random point x S (c,r) SED(S-{x}) if xDisc(c,r) then return (c,r) else return SED-with-point(S,x)
SED-with-point(S,y) pick a random point x S (c,r) SED-with-point(S-{x},y) if xDisc(c,r) then return (c,r) else return SED-with-2-points(S,y,x)
T(n) = T(n-1) + 2
nSED-with-2-points
T(n) = O(n)
O(n)
![Page 35: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/35.jpg)
Running time ?SED(S) pick a random point x S (c,r) SED(S-{x}) if xDisc(c,r) then return (c,r) else return SED-with-point(S,x)
T(n) = T(n-1) + 2
nSED-with-point
T(n) = O(n)
O(n)
![Page 36: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/36.jpg)
Smallest enclosing disc
Claim #2:
md(I,B) = smallest enclosing disc with B on the boundary and I inside
if x is inside md(I,B) then md(I {x},B) = md(I,B)
![Page 37: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/37.jpg)
Smallest enclosing disc
Claim #3:
md(I,B) = smallest enclosing disc with B on the boundary and I inside
if x is outside of md(I,B) then md(I {x},B) = md(I,B {x})
![Page 38: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/38.jpg)
Smallest enclosing disc
Claim #3:
md(I,B) = smallest enclosing disc with B on the boundary and I inside
if x is outside of md(I,B) then md(I {x},B) = md(I,B {x})
md(I,B) md(l {x},B)
x
![Page 39: Convex hull](https://reader035.vdocument.in/reader035/viewer/2022081721/56813ab2550346895da2b34a/html5/thumbnails/39.jpg)
Smallest enclosing disc
Claim #3:
md(I,B) = smallest enclosing disc with B on the boundary and I inside
if x is outside of md(I,B) then md(I {x},B) = md(I,B {x})
Claim #2:if x is inside md(I,B) then md(I {x},B) = md(I,B)
Claim #1:md(I,B) is unique