# Creation of Efficient 3D Convex Hull

## Question:

In the 2D convex hull problem, you are given a set of 2D points, and you must compute the smallest convex polygon containing all the given points.

The problem in 3D is completely analogous. You are given 3D points, and you must compute the smallest convex polyhedron containing all the given points. Similarly, a polyhedron is convex if for any two points and inside the polyhedron, the line segment is also inside the polyhedron.

In the 2D case, it is more obvious what the output is. We can simply output a circular list of vertices on the boundary of the polygon. But how do we represent a polyhedron? Well, we can represent it as a list of triangular faces. A non-triangular face can always be divided into triangles, so this requirement isn’t limiting.

From here, I dont know where to proceed. What algorithm should I use to comput the smallest convex polyhedron for a set of 3D points?

I tried a brute force algorithm in **O(n^4).**

We could simply consider every triplet of three points ( ⃗ , ⃗ , ⃗ ), and check if they create a triangular face on the convex hull. In order for it to be a face, the remaining points must "see" the same side of the triangle. In other words, if we consider the plane containing this triangle, the remaining points should lie on the same side of the plane. To compute which side of a plane a point ⃗ is on, we can first take a vector ⃗ =( ⃗ − ⃗ )×( ⃗ − ⃗ )orthogonal to the plane.

Then the sign of ( ⃗ − ⃗ )⋅ ⃗ tells us the side of the plane. In particular, a result of 0 tells us that ⃗ lies on the plane.

For each triplet, we perform this check with all points, so the total time complexity is ( 4). Is there a more practical algorithm I could use?

## Answers:

Here is an O(n^2) algorithm that may help:

Our objective is to build the convex hull for the first i points, as i increments from 1 to . The only thing we need to do is to figure out how to update the convex hull in order to add one more new point.

If a point is already inside the polyhedron, we do not do anything. Else, we delete all faces the new point can view. Now we need to add something to the polyhedron. We have already left the polyhedron with a connected set of faces removed. This reveals a cycle of edges. For each of these revealed edges, we create a new face with the new point and that edge. Essentially, we create a cone of faces to fix the opening.

**Time Complexity**

For each iteration, we process all of the faces of the hull in that iteration. It is proven that the number of faces is at most O(n). For the proof, we are able to use Euler’s Formula. It says that for any polyhedron with V vertices, E edges, and F faces, V-E+F=2. All of the faces are triangles, so we can substitute E=3F/2 because each face has 3 edges, and we count each edge 2 times for the 2 faces it touches. Then we have V−F/2=2

and F=2V−4=O(n). Since we have O(n) faces in O(n) iterations, the overall time complexity is O(n^2).