## How it works

Level Sets is a surface reconstruction technique that embeds a set of input points in a higher dimension to eliminate interface tracking. Taking the input points, lines, and surfaces, the algorithm computes the scalar distance function on a uniform three dimensional grid. Using the scalar distance function, you calculate the gradient of the distance function at all grid points. After these preprocessing steps, the algorithm creates an initial surface that is a bounding surface of the input set. This bounding surface can be any bounding surface, but in my implementation I chose to use the distance == epsilon point set as the initial surface.

Once we have our initial surface, the remaining portion of the algorithm iterates over the following steps until all points in the interface have reached the final surface:

- Calculate the signed distance function, phi, and normal field, N, in a narrow band around the current interface.
- Update the phi funtion using a gradient descent method. In practice, the update function TIME_STEP*dot(gradient, normal) works well.
- Extract the updated interface from the new phi function. This is done by finding all zero crossings in phi.

Once the interface reaches the final surface, the interface can be used to create a signed distance function on the three dimensioanl grid. Using marching cubes, we can extract the zero isosurface from the volume to create a final mesh.