This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Input: a set P of points in IR2
Output: C H(P )
1. E ←P 2
2. for all (p, q , r) ∈ P 3 such that r ∈ {p, q }
/
3.
if C C W (p, q , r ) ≤ 0
4.
then remove (p, q ) from E
5. Write the remaining edges of E into L in
counterclockwise order
6. Return L CONVEX HULL  Divide & Conquer ding p itself, and the p oints to the right of p, by comparing xcoordinates. Recurs
the convex hulls of L and R. Finally, merge the two convex hulls into the ﬁnal outp
erge step requires a little explanation. We start by connecting the two hulls with a
✦ een the re tmost po in x the hull of L an Spl t P t to t o o se hu
b etwCo mputighme dian int of co ordinate withdthe leiftmosinp ointwf the ts ll
e ✦oints p and q , resp ectively. (Yes, it’s the same p.) Actually, let’s add two cop
p
Compute Left an d Right Hulls recursively
ent pq and call them bridges. Since p and q can ‘see’ each other, this creates a so
shap ed rglegon, which isHunlsx except p ossibly at the endp oints oﬀ the bridges.
✦...
View
Full
Document
 Fall '08
 UNGOR
 Algorithms, Data Mining, Databases

Click to edit the document details