Convex hull smallest convex set containing all the points.
-
Upload
jeffry-ellis -
Category
Documents
-
view
251 -
download
1
Transcript of Convex hull smallest convex set containing all the points.
Convex hull smallest convex setcontaining all the points
Convex hull smallest convex setcontaining all the points
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
Jarvis march
find the left-most point
(assume no 3 points colinear)
s
Jarvis march
find the point that appears most to the right looking from s
(assume no 3 points colinear)
s
Jarvis march (assume no 3 points colinear)
s
p
find the point that appears most to the right looking from p
Jarvis march (assume no 3 points colinear)
Jarvis march (assume no 3 points colinear)
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
Jarvis march (assume no 3 points colinear)
Running time = O(n.h)
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
Graham scan (assume no 3 points colinear)
Graham scan (assume no 3 points colinear)
Graham scan (assume no 3 points colinear)
Graham scan (assume no 3 points colinear)
Graham scan (assume no 3 points colinear)
Graham scan (assume no 3 points colinear)
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)
Closest pair of points
Closest pair of points
Closest pair of points
2T(n/2) min(left,right)
Closest pair of points
2T(n/2) min(left,right)
Closest pair of points
2T(n/2) min(left,right)
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
Smallest enclosing disc
Smallest enclosing disc
Smallest enclosing disc
The smallest enclosing disc is unique.Claim #1:
Smallest enclosing disc
The smallest enclosing disc is unique.Claim #1:
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)
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)
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)
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)
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)
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)
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)
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)
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})
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
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