Presentation is loading. Please wait.

Presentation is loading. Please wait.

Convex hulls in 3D Maciej Kot. Finding convex hull Given a set of points, find a convex hull that contains all of them and is minimal.

Similar presentations


Presentation on theme: "Convex hulls in 3D Maciej Kot. Finding convex hull Given a set of points, find a convex hull that contains all of them and is minimal."— Presentation transcript:

1 Convex hulls in 3D Maciej Kot

2 Finding convex hull Given a set of points, find a convex hull that contains all of them and is minimal.

3 Convex hull in 2D In 2D it seems to be easy. There are almost as many Convex Hull algorithms as sorting algorithms! Known algorithms: Brute force O(n 3 ) Incremental O(n 2 ) Jarvis’ march (gift wrapping) O(nh) Divide and Conquer O(n logn) Graham’s scan O(n logn) h is a number of points in the hull

4 Line pruning O(n 3 ) Point pruning O(n 2 ) QuickHull O(n logn ) Marriage before conquestO(n log h) Chan’s algorithmO(n log h) Monotone chainO(n logn) Many randomized algorithms O(n logn) O(n log h) Seidel’s shellingO(n 2 + h logn)

5 Can it be extended to higher dimensions ? Incremental Gift wrapping Divide and conquer QuickHull The problem of course can, but what about solutions? Some of them...and many others, but not all of them

6 Convex hull in 3D Similar as in 2D. Given set of points find a convex polyhedron that contains all of them. Picture from wikipedia

7 Convex hulls in 3d A line between every two points from the hull is always inside the hull (or at the border). For every face of the hull (triangle in 3d, edge in 2d) all the points that don’t lay on the face are either on the left or right side of that face. The problem in 3D seems to be more complicated. Is there a simple (and fast) solution? Look at the simple properties of convex hulls, maybe you’ll find a simple solution! Every point from our set has to be on the left side of every face of the hull....or on the right, depending on orientation of the hull

8 Incremental algorithm For each point we haven’t checked yet: Check if it’s inside the hull. How? - check if it can see any faces, if not - it’s inside (it’s on the left side of every face of the hull.) We are in the middle of algorithm. We have looked at some points and we have a hull that contains them (and is minimal). If it’s inside, life is good, don’t change it. If it’s outside, rebuild the hull so it will contain our point. //Lets assume, that point can see the face if it’s //on the right side of the face.

9 Incremental algorithm We have a hull, and a point that is outside. Delete all the faces that this point see. Add a cone that will repair it. For every edge of the hole add a triangle containing this edge and our point. This means that it can see some faces. There is a hole in the hull now. Rebuilding the hull. 2D3D

10 Incremental algorithm notes, summary We’ve already said what is the loop invariant: We have looked at some points and we have a hull that contains them (and is minimal). Establishing the loop invariant: Pick 4 random points and build a hull on them. Maintaining the loop invariant: Rebuilding the hull maintains the loop invariant. Exit condition: We have looked at all points.

11 Incremental algorithm Complexity For each point Look at every face in temporary hull and check if point can see it then Leave the hull unchanged or Remove some faces, add some new faces. n x O(n) =O(n 2 ) Can we do better? +

12 The best algorithm in 2D has O(n logh). Can we do it as fast in 3D? n logn sounds like recursion Divide your set of points in 2 groups. Let your friend compute a hull for first group, another friend for second group and then join them. But your friends are lazy. They may not want to compute anything for you. This algorithm is very hard to implement in higher dimensions.

13 Look at the incremental algorithm again.... When choosing first few points for the hull pick max(x), max(y), min(x) and min(y) points. These 4 points have to be in the final hull. Build a first temporary hull on them. Discard all points that are inside. In typical case, there won’t be many points left to look at now. This trick can speed up almost every convex hull algorithm.

14 QuickHull Speed of incremental algorithm depends on the order in which we are looking at our points. So each time pick the point that looks best! If we don’t know anything about input set, then the point that is furthest away gives us the biggest chance of catching other points into the hull. Furthest away from what? Center of the hull? Border of the hull. Is is a better idea. Checking if point can see a face, can give us distance between them. We have to do this check anyway. Face that point can see. It may not be easy to compute and we are lazy, right? - OK, but where is it?

15 QuickHull Loop: We are in the middle of algorithm. We have looked at some points and we have a hull that contains them (and is minimal). and Every unprocessed point is associated with a face that it can see (doesn’t matter which face). Select a face of the hull. Pick the furthest point associated with it. Add it to the hull. (rebuild the hull so it will contain this point) If there were no points associated with selected face, select the next face. If there is no next face - exit. The main idea: For each face of the hull pick the point that is furthest away from it and add it to the hull.

16 QuickHull Rebuilding the hull / maintaining the loop invariant. Similar as in incremental algorithm. We have a hull, and a point that is outside. Delete all the faces that this point see. There is a hole in the hull now. Add a cone that will repair it. For every edge of the hole add a triangle containing this edge and our point. Except this time, when adding new face, the points that were assigned to deleted faces are being reassigned to this new face if they can see it. If all needed faces are added, but there are still some points not assigned to any face, you can discard them - they can’t see any of newly added faces which means that they are inside the hull.

17 QuickHull Running time In typical cases it’s O(n log n) (in 2d and in 3D) Every point we are adding will be in the final hull. We discard all the points that won’t be in the final hull. Worst case scenario - All points from the input set will be in the hull (sphere). Then it’s O(n 2 ) worst case.

18 approximation of shapes collision detection shadow renderers Why did we do that? Where are convex hulls used? Problems that can be reduced to convex hull: halfspace intersection Delaunay triangulation Voronoi diagrams power diagrams http://www.virtualworldlets.net/Resources/Hosted/Resource.php?Name=ConvexHullSim

19 The end


Download ppt "Convex hulls in 3D Maciej Kot. Finding convex hull Given a set of points, find a convex hull that contains all of them and is minimal."

Similar presentations


Ads by Google