Assignment: 3d hull

In this assignment you will write code to find the convex hull of a set of points (in 3D) using either gift wrapping, or the incremental algorithm. You will receive starter code on Github which contains two versions: one in c and and one in cpp. The code should compile as is, and provides the graphical interface.

Representing the hull: The first question you will need to answer is how to store the hull. For simplicity, do not worry about storing the topology of the hull, that is, the neighboring information for its faces, edges and vertices. Store the hull as a list/array/vector of the faces on the hull. Ideally the faces use pointers to the points, rather than duplicating the points and their coordinates. For example, in C style:

typedef struct _face3d {
   point3d *p1, *p2, *p3;  //the vertices on this face (in ccw as looking from outside)
} face3d; 

Starting naive: It's a good idea to start by implementing the naive algorithm. This will be quick and vizualizing the 3d hull should provide a nice motivation for getting the basics working. For simplicity, do not worry about handling degeneracies. To test, generate points randomly on the sphere, and compute their hull.

Going from naive to gift wrapping or incremental

In addition to the hull faces, you may need to keep track of what vertices are on the hull. For gift wrapping, you'll need to keep track of what edges are on the hull and whether an edge has found both its adjacent faces or only one of them. Come up with structures to keep track of these. Consider using hash tables and maps and trees. As mentioned, avoid storing a topological structure for the hull (to avoid the complexity or programming).

For gift wrapping, for example, you'll want to keep a queue/stack that stores all the edges that are on the frontier of the search (in other words: all edges that have found only one adjacent face so far). When you add a face between an edge e=(p1, p2) on the frontier of the hull, and a new vertex p, this will create two edges (p1,p) and (p2,p). This may be edges already on the frontier of the hull, or new edges. Therefore you'll need to be able to search the frontier of the hull efficiently; that is, the structure you use to store the frontier of the hull should support search.

For incremental:you'll want to find all faces that are visible from the next point, p. Doing a linear search through the faces of the hull and checking visibility is totally fine.

Orienting a face: All faces on the hull should be oriented so that the normal to the face points outside the hull; that is, all points p in P are behind the face. Given a face (a,b,c), you can orient it as (a,b,c) or (a,c,b). How do you know which one to choose? Consider an arbitrary point p in P, different than a,b,c. If p is behind face (a,b,c) then (a,b,c) is the correct orientation. Otherwise, the correct orientation is (a,c,b).

Degeneracies: If there exist sets of 4 or more points that are co-planar, it is possible that faces in the hull are not triangular. Whichever algorithm you implement, consider how it can be extended to handle degeneracies. Ideas: keep non-triangular faces; or, split non-triangular faces into triangles.

Base code: Base code is provided with the assignment's GitHub repository. The code should compile as is, but it does not do anything besides the interface. You need to add a function that computes the hull (and a function that renders the faces of the hull).

Test cases: Please provide one interesting test case (configuration of points) on which to compute the hull. Post your special test case on Slack, so that everyone can see it. Include at least three of your classmates test cases in your code.

Share! Use Slack! Share anything that you stumble on, and anything you learn while working on the project. And if it's late at night and you got a bug and your code does not compile, feel free to ramble --we're in this together.

Extra features: Some ideas:

Additional resources: If you want to check out details of the algorithms, the first source is the chapter on 3d hulls in the textbook by O'Rourke. Note that it has a complete implementation of the incremental algorithm. Since it's the textbook, it's fine if you use as little or as much of this implementation as you want.

For gift wrapping, the only part we didn't spell out is how to find the first face on the hull. Feel free to search and reach out to me if you cannot find an answer.

Work in style: As usual, you need to strive to write not merely code, but simple, elegant and easy to understand code. Furthermore, you need tow strive to do this out of habit, as you start programming, and not only at the end. Writing good code has to become your second nature. Write good code not because you have to, but because you don't know anyt other way.

What and how to turn in:o You will receive the assignment on GitHub, including the startup code. You are encouraged to do pair-programming, but feel free to work alone. Push your code into your github repository for this assignment. Provide a README that describe the state of your code (does it work on all test cases, do you know of any bugs, any extra features).

Enjoy!


Last modified: Tue Oct 5 22:58:19 EDT 2021