Editing Convex hull

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 65: Line 65:
  
 
==Three-dimensional convex hull==
 
==Three-dimensional convex hull==
Computing a convex hull in <math>\mathbb{R}^3</math> is significantly more challenging. It is a task which will most likely never be given on competitions such as the [[IOI]], and it is not recommended that high school students learn it. However, there is a fairly simple <math>O(n^2)</math> algorithm, which works as follows: first project all of the points onto the xy-plane, and find an edge that is definitely on the hull by selecting the point with highest y-coordinate and then doing one iteration of gift wrapping to determine the other endpoint of the edge. This is the first part of the incomplete hull. We then build the hull iteratively. Consider this first edge; now find another point in order to form the first triangular face of the hull. We do this by picking the point such that all the other points lie to the right of this triangle, when viewed appropriately (just as in the gift-wrapping algorithm, in which we picked an edge such that all other points lay to the right of that edge). Now there are three edges in the hull; to continue, we pick one of them arbitrarily, and again scan through all the points to find another point to build a new triangle with this edge, and repeat this until there are no edges left. (When we create a new triangular face, we add two edges to the pool; however, we have to first check if they have ''already'' been added to the hull, in which case we ignore them.) There are <math>O(n)</math> faces, and each iteration takes <math>O(n)</math> time since we must scan all of the remaining points, giving <math>O(n^2)</math>. (If you feel like coding this, you might try {{SPOJ|CH3D|CH3D@SPOJ}}.) It is possible to speed up this algorithm significantly by initially discarding a large number of points we know not to be in the hull; one easy way that performs quite well is to find both extremal points with respect to each of the three coordinate axes, and discard all points in the interior of the octahedron they form.
+
Computing a convex hull in <math>\mathbb{R}^3</math> is significantly more challenging. It is a task which will most likely never be given on competitions such as the [[IOI]], and it is not recommended that high school students learn it. However, there is a fairly simple <math>O(n^2)</math> algorithm, which works as follows: first project all of the points onto the xy-plane, and find an edge that is definitely on the hull by selecting the point with highest y-coordinate and then doing one iteration of gift wrapping to determine the other endpoint of the edge. This is the first part of the incomplete hull. We then build the hull iteratively. Consider this first edge; now find another point in order to form the first triangular face of the hull. We do this by picking the point such that all the other points lie to the right of this triangle, when viewed appropriately (just as in the gift-wrapping algorithm, in which we picked an edge such that all other points lay to the right of that edge). Now there are three edges in the hull; to continue, we pick one of them arbitrarily, and again scan through all the points to find another point to build a new triangle with this edge, and repeat this until there are no edges left. (When we create a new triangular face, we add two edges to the pool; however, we have to first check if they have ''already'' been added to the hull, in which case we ignore them.) There are <math>O(n)</math> faces, and each iteration takes <math>O(n)</math> time since we must scan all of the remaining points, giving <math>O(n^2)</math>. (If you feel like coding this, you might try {{SPOJ|CH3D|CH3D@SPOJ}}.) It is possible to speed up this algorithm significantly by initially discarding a large number of points we know not to be in the hull; one easy way that performs quite well is to find both extremal points with respect to each of the three coordinate axes, and discard all points in the interior of the tetrahedron they form.
  
 
It is possible to compute a 3D convex hull in <math>O(n \log n)</math> time using a divide-and-conquer algorithm, but this is extremely difficult.
 
It is possible to compute a 3D convex hull in <math>O(n \log n)</math> time using a divide-and-conquer algorithm, but this is extremely difficult.

Please note that all contributions to PEGWiki are considered to be released under the Attribution 3.0 Unported (see PEGWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)