An Efficient Convex Hull Algorithm for a Planer Set of Points

33
An Efficient Convex Hull Algorithm for a Planer Set of Points Kasun Ranga Wijeweera ([email protected])

Transcript of An Efficient Convex Hull Algorithm for a Planer Set of Points

Page 1: An Efficient Convex Hull Algorithm for a Planer Set of Points

An Efficient Convex Hull Algorithm for a Planer Set of Points

Kasun Ranga Wijeweera

([email protected])

Page 2: An Efficient Convex Hull Algorithm for a Planer Set of Points

This Presentation is Based on Following Research Paper

K. R. Wijeweera, U. A. J. Pinidiyaarachchi (2013), An Efficient Convex Hull Algorithm for a Planer Set of Points, Ceylon Journal of Science (Physical Sciences), Volume 17, pp. 9-17.

Page 3: An Efficient Convex Hull Algorithm for a Planer Set of Points

Definitions(Convex Set)

• A set S is convex if x in S and y in S implies that the segment xy is a subset of S

• Example in 2D:

Page 4: An Efficient Convex Hull Algorithm for a Planer Set of Points

Definitions(Convex Hull of a Set of Points)

• The convex hull of a set S of points is the smallest convex set containing all the points in S

• Example in 2D:

Page 5: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Introduction)

• This algorithm is based on gradient in coordinate geometry• Achieves parallelism• Achieves data reduction• Manages coincident points• Deals with collinear points • Outputs hull points in boundary traversal order• Low computational cost

Page 6: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Inputs and Outputs)

• Input: A non-empty set of points

S = {P1, P2, . . . , Pn}

• Output: A non-empty set that contains all the points of the convex hull of S

H = {Q1, Q2, . . . , Qm}

Page 7: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Example Data Set)

x

y

Page 8: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Step 1)

Calculate following values from the set S

minx // minimum value of x-coordinates

y_minx // y-coordinate corresponding to minx

maxx // maximum value of x-coordinates

y_maxx // y-coordinate corresponding to maxx

miny // minimum value of y-coordinates

x_miny // x-coordinate corresponding to miny

maxy // maximum value of y-coordinates

x_maxy // x-coordinate corresponding to maxy

Page 9: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Basic Four Points on the Convex Hull)

(x_maxy, maxy)

(minx, y_minx) (maxx, y_maxx)

(x_miny, miny)

Page 10: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Step 2)

Define following subsets of S

A = { ( x, y) in S | ( x <= x_maxy ) AND ( y >= y_minx )}

B = { ( x, y) in S | ( x >= x_maxy ) AND ( y >= y_maxx )}

C = { ( x, y) in S | ( x >= x_miny ) AND ( y <= y_maxx )}

D = { ( x, y) in S | ( x <= x_miny ) AND ( y <= y_minx )}

Page 11: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Partitioning the Data Set into Four Regions)

A B

C D

Page 12: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Step 3)

• Find the convex hull parts belong to each of the sets A, B, C, and D in parallel

• Merge those hull parts to derive the set H

Page 13: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (After Processing and Merging Hull Parts)

A B

C D

Page 14: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Processing Each Set: Gradient)

x

y

M (mx, my)

N (nx, ny)

m = ( ny – my ) / ( nx – mx )

Page 15: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Processing Each Set: Modified Gradient)

A B

C D

Page 16: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Processing Each Set: Modified Gradient)

Region Diagram Modified Gradient Begin Point End Point

A ( ay[i] – hully ) / ( ax[i] – hullx ) x = minxy = y_minx

x = x_maxyy = maxy

B ( bx[i] – hullx ) / (hully - by[i] ) x = x_maxyy = maxy

x = maxxy = y_maxx

C ( hully - cy[i] ) / ( hullx - cx[i] ) x = maxxy = y_maxx

x = x_minyy = miny

D ( hullx – dx[i] ) / ( dy[i] – hully ) x = x_minyy = miny

x = minxy =y_minx

Page 17: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Processing Set A: General Case)

Page 18: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Processing Set A: General Case)

Page 19: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Processing Set A: General Case)

Page 20: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Processing Set A: General Case)

Page 21: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Processing Set A: General Case)

Page 22: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Processing Set A: Collinear Case)

Page 23: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Processing Set A: Indeterminate Case)

Page 24: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Processing Sets B, C, and D)

• Using similar method B, C, and D sets can also be processed• Using the same algorithm used for A to process B, C, and D

needs additional computational cost• Therefore four separate algorithms are used to process each of

four sets with modified gradient

Page 25: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Interior Points Algorithm)

Based on the following Lemma

A point is non-extreme if and only if it is inside some (closed) triangle whose vertices are points of the set and is not itself a corner of that triangle

Page 26: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Interior Points Algorithm)

Algorithm: INTERIOR POINTS

for each i do

for each j != i do

for each k != i != j do

for each l != k != i != j do

if p(l) in Triangle{ p(i), p(j), p(k) }

then p(l) is non-extreme

Page 27: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Proposed Algorithm vs. Interior Points Algorithm)

• Both of the algorithms were implemented using C++ programming language

• Following hardware and software resources were used– Computer: Intel(R) Pentium(R) Dual CPU; E2180 @ 2.00 GHz; 2.00

GHz, 0.98 GB of RAM;– IDE: Turbo C++; Version 3.0; Copyright(c) 1990, 1992 by Borland

International, Inc;

Page 28: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Proposed Algorithm vs. Interior Points Algorithm)

• First, n number of random points were generated in the range 0 – 399 using randomize() function and written them to a text file

• Such text files were generated for different n• Number of clock cycles taken to process each data file k times

was counted using clock() function

Page 29: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Proposed Algorithm vs. Interior Points Algorithm)

Case Proposed Algorithm (1000)

Interior Points Algorithm (1000)

Average Ratio (IPA : PA)

n = 10; k = 32000; 5.53 37.11 6.71

n = 20; k = 1000; 10.60 693.80 65.45

n = 30; k = 500; 15.20 3881.6 255.36

n = 40; k = 100; 17.00 12769.00 751.11

n = 50; k = 50; 24.00 32554.00 1356.41

Page 30: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Proposed Algorithm vs. Interior Points Algorithm)

Case 1 Case 2 Case 3 Case 4 Case 50

5000

10000

15000

20000

25000

30000

35000

A(1000)B(1000)

Page 31: An Efficient Convex Hull Algorithm for a Planer Set of Points

A 2D Convex Hull Algorithm (Drawbacks of the Proposed Algorithm)

• It cannot be easily extended to higher dimensions• The notion of gradient causes the problem• Need to solve partial differential equations in order to derive

the gradient• Because of this higher dimensional extension is not cost

effective• The entire data set is needed from the beginning

– The algorithm is static

Page 32: An Efficient Convex Hull Algorithm for a Planer Set of Points

Any Questions?

Page 33: An Efficient Convex Hull Algorithm for a Planer Set of Points

Thank You!