Computational Geometry 2D Convex Hulls continued - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Computational Geometry 2D Convex Hulls continued

Description:

Maintain a stack representing (left-turning) CH so far ... Qhull, Brad Barber (used within MATLAB) a. b. c. S. B. A. Worst-case: O(n2 ) Avg: O(n) ... – PowerPoint PPT presentation

Number of Views:144
Avg rating:3.0/5.0
Slides: 10
Provided by: S698
Category:

less

Transcript and Presenter's Notes

Title: Computational Geometry 2D Convex Hulls continued


1
Computational Geometry2D Convex Hulls
(continued)
Joseph S. B. Mitchell Stony Brook University
2
O(n log n) Graham Scan
  • Idea Sorting helps!
  • Start with vlowest (min-y), a known vertex
  • Sort S by angle about vlowest
  • Graham scan
  • Maintain a stack representing (left-turning) CH
    so far
  • If pi is left of last edge of stack, then PUSH
  • Else, POP stack until it is left, charging work
    to popped points

O(n)
O(n log n)
O(n)
CH so far
vlowest
Demo applet
3
CH of Simple Chains/Polygons
  • Input ordered list of points that form a simple
    chain/cycle
  • Importance of simplicity (noncrossing, Jordan
    curve) as a means of sorting (vs. sorting in x,
    y)
  • Melkmans Algorithm O(n) (vs. O(n log n) or
    O(n log h))

1
2
n
4
Melkmans Algorithm
  • Keep hull in DEQUE lt vb ,vb1 ,,vt-1 ,vt vb gt
  • While Left(vb ,vb1 ,vi ) and Left(vt-1 ,vt ,vi )
  • i ? i1
  • Remove vb1 , vb2 ,
  • and vt-1 , vt-2 ,
  • until convexity restored
  • New vb vt vi
  • Claim Simplicity assures that the only way for
    the chain to exit the current hull is via pockets
    vb vb1 or vt-1 vt .

vt-1
vt
vt-1
vb
vi
vi
vt
vb
vb1
vb1
Simplicity helps!
Time O(n), since O(1) per insertion
5
2D Convex Hull Algorithms
  • O(n4) simple, brute force (but finite!)
  • O(n3) still simple, brute force
  • O(nh) simple, output-sensitive
  • h output size ( vertices)
  • O(n log n) worst-case optimal (as fcn of n)
  • Graham scan
  • Divide and conquer
  • Incremental construction
  • QuickHull good in practice, simple, O(n2)
    worst-case
  • O(n log h) ultimate time bound (as fcn of
    n,h)
  • Randomized incremental expected O(n log n)
  • Lower bound ?(n log n)

Simple, elegant
y x2
(xi ,xi2 )
From SORTING
Note Even if the output of CH is not required to
be an ordered list of vertices (e.g., just the
of vertices), ?(n log n) holds
xi
6
QuickHull
  • QuickHull(a,b,S) to compute upperhull(S)
  • If S?, return ()
  • Else return (QuickHull(a,c,A), c,
    QuickHull(c,b,B))

c point furthest from ab
c
Discard points in ?abc
B
A
Worst-case O(n2 ) Avg O(n)
b
a
Works well in higher dimensions too!
S
Qhull website
Qhull, Brad Barber (used within MATLAB)
7
O(n log n) Randomized Incremental
  • Add points in random order
  • Keep current Qi CH(v1 ,v2 ,,vi )
  • Add vi1
  • If vi1 ? Qi , do nothing
  • Else insert vi1 by
  • finding tangencies,
  • updating the hull
  • Expected cost of insertion O(log n)

8
  • Each uninserted vj ? Qi (jgti1) points to the
    bucket (cone) containing it each cone points to
    the list of uninserted vj ? Qi within it (with
    its conflict edge)
  • Add vi1 ? Qi
  • Start from conflict edge e, and walk cw/ccw to
    establish new tangencies from vi1 , charging
    walk to deleted vertices
  • Rebucket points in affected cones
  • (update lists for each bucket)
  • Total work O(n) rebucketing work
  • E(rebucket cost for vj at step i)
  • O(1) ? P(rebucket) ? O(1) ? (2/i ) O(1/i )
  • E(total rebucket cost for vj ) ? O(1/i )
    O(log n)
  • Total expected work O(n log n)

e
vi1
Backwards Analysis vj was just rebucketed iff
the last point inserted was one of the 2
endpoints of the (current) conflict edge, e, for
vj
9
More Demos
  • Various 2D and 3D algorithms in an applet
Write a Comment
User Comments (0)
About PowerShow.com