Presentation is loading. Please wait.

Presentation is loading. Please wait.

Convex Hull Computation ● Applications of Convex Hull Computation ● Definitions ● Basic Math Functions ● Algorithms Algorithm Speed Discovered By Brute.

Similar presentations


Presentation on theme: "Convex Hull Computation ● Applications of Convex Hull Computation ● Definitions ● Basic Math Functions ● Algorithms Algorithm Speed Discovered By Brute."— Presentation transcript:

1 Convex Hull Computation ● Applications of Convex Hull Computation ● Definitions ● Basic Math Functions ● Algorithms Algorithm Speed Discovered By Brute ForceO(n 4 )[Anon, the dark ages] Gift WrappingO(nh)[Chand & Kapur, 1970] Graham ScanO(n log n)[Graham, 1972] Jarvis MarchO(nh)[Jarvis, 1973] QuickHullO(nh)[Eddy, 1977], [Bykat, 1978] Divide-and-ConquerO(n log n)[Preparata & Hong, 1977] Monotone ChainO(n log n)[Andrew, 1979] IncrementalO(n log n)[Kallay, 1984] Marriage-before-ConquestO(n log h)[Kirkpatrick & Seidel, 1986] http://geometryalgorithms.com/Archive/algorithm_0109/algorithm_0109.htm

2 What is a convex hull ● For a given series of points, the convex hull is the smallest convex set which contains the points. ● It is like a string that wraps around the points. It only touches the outermost points http://www.cs.princeton.edu/~ah/alg_anim/version1/ConvexHull.html

3 ● Find all lines through two points with all points on one side of the line ● Find all lines through the points (n 2 ) (line AB) ● For AB, find all line segments CD (n 2 ) such that the line AB does not intersect the line segment CD Brute Force Algorithm

4 Some basic math functions ● Starting with Descartes and Fermat, we know that the area of a parallelogram can be computed by taking the magnitude of the cross product of 2 edge vectors ● The area of a triangle will be half that of a parallelogram v w v w

5 Computing the area of a triangle ● Area = 1212 v x w v w V0V0 V2V2 V1V1 ● For a triangle defined in 3D space, this produces the following matrix x1x2x3x1x2x3 y1y2y3y1y2y3 z1z2z3z1z2z3 http://geometryalgorithms.com/Archive/algorithm_0101/ http://www.btinternet.com/~se16/hgb/triangle.htm

6 ● For a triangle defined in 2D space, this produces the following matrix 1 x1x2x3x1x2x3 y1y2y3y1y2y3 1 1 Computing the area of a triangle ● To solve this matrix, we take the cross product of its components v w x 1,y 1 x 3,y 3 x 2,y 2 Area = ((x 2 y 1 – x 1 y 2 ) + (x 3 y 2 – x 2 y 3 ) + (x 1 y 3 – x 3 y 1 )) / 2

7 ● There is an interesting side effect by using this method to compute the area of a triangle ● The area calculation is signed ● If the area is positive, then that means the points V 1, V 2, V 3 were defined in a counter-clockwise direction (around the triangle) ● If the area is negative, then that means the points V 1, V 2, V 3 were defined in a clockwise direction (around the triangle) ● Website demonstration Determining the order of the points http://www.cse.unsw.edu.au/~lambert/java/3d/triangle.html

8 ● The algorithm is as follows ● Start at an extreme point (min or max, x or y component) ● Scan through all of the points and find the point that gives you the next most counter-clockwise point. ● By calculating the area of triangles formed by these points, we can determine the ordering of points and, as a result, compute the next point (in a counter-clockwise direction) on the convex hull. ● O (nh) ● n – number of points ● h – number of points in hull ● Has best performance when convex hull is a triangle ● Has worst performance when all points lie on the hull Gift Wrap Algorithm http://www.cs.princeton.edu/~ah/alg_anim/version1/JarvisMarch.html

9 ● The algorithm is as follows ● Identify a pivot point (min or max, x or y component) ● Sort the points in order of increasing angle with the pivot. ● Connect the sorted points (star shaped polygon) ● March around hull. ● Add edges when a left turn is made ● Remove edges when a right turn is made ● O (n log n) ● n – number of points ● Performs better than Gift wrap algorithm when there are more points on the hull ● Sorting time can have an impact on this algorithm Graham's Scan http://www.cs.princeton.edu/~ah/alg_anim/version0/Graham.html

10 ● Similar to quick sort. Recursive and divides points. ● The algorithm is as follows ● Identify 2 points on the hull (called a chord AB) ● Left most and right most or highest and lowest ● Create “partition” ● Find the farthest point from AB (Called C) ● All points within this triangle (ABC) cannot be on the convex hull. ● Place in set called S0 ● Place points outside AC in S1 and outside BC in S2 ● Recuse on partitions AC with S1 and on parition BC with S2 ● O (nh) ● Creating S0 can remove a large number of points. S0 must be large. ● Works very well on random data. Quick Hull http://www.cs.princeton.edu/~ah/alg_anim/version1/QuickHull.html

11 ● Similar to merge sort ● The algorithm is as follows: ● Sort the points ● Recursively group points until brute force hull computation is O(1) ● Merge Adjacent hulls together ● To merge hulls: ● Choose rightmost point of left hull and leftmost point of right hull ● Traverse points on left hull in counter-clockwise direction and on rightmost hull in clockwise direction. ● Find vector which is the upper tangent of both hulls ● Repeat (in reverse) for lower tangent ● Because the merge is O(n) the total time is O(n log n) ● This algorithm can be used in conjunction with other algorithms to provide optimal performance. Divide and Conquer


Download ppt "Convex Hull Computation ● Applications of Convex Hull Computation ● Definitions ● Basic Math Functions ● Algorithms Algorithm Speed Discovered By Brute."

Similar presentations


Ads by Google