Professional Documents
Culture Documents
Geometry
Code: CSEB 604
Pritha Banerjee
Resources
Books:
Computational Geometry : Algorithms and
Applications, Mark De Berg, Marc van Kreveld, Mark
Overmars, Otfried Schwarzkopf, Springer
Computational Geometry in C, Joseph O. Rourke,
Cambridge
Lecture notes of David Mount from the web
Convex Hull
Input : a set of points P = {p1, p2, p3pn} on
a plane
Output : CH(P) , Find an unique convex
polygon whose vertices are points from P &
contains all points of P.
CH(P): List the vertices of convex polygon in
clockwise order.
Incremental algorithm
Take help of Incremental algorithm : std.
design technique
Add points one at a time in the Polygon ,
updating solution after each addition
Construct upper and lower hull and join them
Sort on x coordinate
Take points from left to right constructing
upper hull
Take points right to left to construct lower
hull
10
8
4
3
14
11
7
6
15
13
9
12
1, 2
Elective III : CG
10
8
4
3
14
11
7
6
15
13
9
12
1, 2, 3,
1,2,3,
Elective III : CG
10
8
4
3
14
11
7
6
15
13
9
12
1, 2, 3, 4
1, 2, 4
Elective III : CG
10
8
11
7
3
1
14
15
13
9
12
1,2,4
1, 2, 4, 5,
1,2,5
Elective III : CG
10
8
11
7
3
1
14
15
13
9
12
1, 2, 5
1, 2, 5, 6
1, 2, 5, 6, 7
Elective III : CG
10
8
11
7
3
1
14
15
13
9
12
1, 2, 5,6
1, 2, 5, 6, 7
1, 2, 5, 7
Elective III : CG
10
8
11
7
3
1
14
15
13
9
12
1, 2, 5, 7
1, 2, 5, 7, 8
1, 2, 5, 8
Elective III : CG
10
8
11
7
3
1
15
13
1, 2, 5, 8
1, 2, 5, 8, 9
12
1, 2, 5, 8, 9
1, 2, 5, 8, 9, 10
1, 2, 5, 8, 10
14
Elective III : CG
10
8
11
7
3
1
14
15
13
1, 2, 5, 8, 10
12
1, 2, 5, 10
Elective III : CG
10
8
11
7
3
1
14
15
13
1, 2, 5, 10
1, 2, 5, 10, 11
1, 2, 5, 10, 11
1, 2, 5, 10, 11, 12
1, 2, 5, 10, 11, 12, 13
12
Elective III : CG
10
8
11
7
3
1
14
15
13
1, 2, 5, 10, 11, 13
12
Elective III : CG
10
8
11
7
3
1
14
15
13
1, 2, 5, 10, 11, 13
1, 2, 5, 10, 13
1, 2, 5, 10, 13, 14
12
Elective III : CG
10
8
11
7
3
1
14
15
13
1, 2, 5, 10, 14
12
1, 2, 5, 10, 14, 15
1, 2, 5, 10, 14, 15
10
8
11
7
3
1
14
15
13
9
12
Complexity:
Sorting : O(n log n)
What data structure we use ? Stack
How many times an element is inserted or
deleted from stack for constructing L_upper?
Only once=> over the for loop : O(n)
Similarly for L_lower
Total : O(n) + O(n log n) => O(n log n)
7
3
6
9
10
8
4
3
14
11
7
6
15
13
9
12
10
8
4
3
14
11
7
6
15
13
9
12
10
8
4
3
14
11
7
6
15
13
9
12
10
8
4
3
14
11
7
6
15
13
9
12
10
8
4
3
14
11
7
6
15
9
13
12
Complexity :
Finding one of the extreme point : O(n)
Finds next Hull vertex by rotation=> O(n)
There are h hull vertex=> O(hn)
Time complexity : O(nh), If h is O(log n) => same as Graham Scan
Convex Hull
Input : a set of points P = {p1, p2, p3pn} on
a plane
Output : CH(P) , Find an unique convex
polygon whose vertices are points from P &
contains all points of P.
CH(P): List the vertices of convex polygon in
clockwise order.
Resources
Books:
Computational Geometry in C, Joseph O. Rourke,
Cambridge, Pages: 91-95, Section 3.8 and Pages: 6972, Section 3.4
Lecture notes of David Mount from the web, Pages: 1417
32
HB
Lower
tangent
Find upper and lower tangent for both HA and HB disregarding all other
points lying between lower and upper tangents
p2
p3
HB
HA
a-1 a+1
a
b-1
b+1
b
4
3
HA
HB
6
0
1
0
a = right most point of left Hull A
b = left most point of right Hull B
While T = ab is not lower tangent to both A and B
while T not lower tangent to A then a = a-1
while T not lower tangent to B then b = b + 1
Return ab
Time complexity
Elective III : CG