Linear interpolation on Plane (Marching Cubes)

545 Views Asked by At

Let's assume I have the following cube.

enter image description here

Let's assume the isovalue = 0. I would like to draw the resulting triangles of the isosurface.

I know that first I define which values are inside or outside comparing them to the given isovalue and after that we correspond to a particular list of edges.

After that, we have somehow to linearly interpolate the points. I have read on an article that using this formula $P = P_1 + \frac{(iso -v_1)(P_2-P_1)}{V_2-V_1}$ we can get the interpolated values.

Can someone demonstrate to me how I can interpolate the points in this case ?

1

There are 1 best solutions below

0
On

Paul Bourke's 'Polygonising a scalar field' shows how to interpolate between the vertices. The page is at:

http://paulbourke.net/geometry/polygonise/

Look at the code, especially the function VertexInterp. It is linear interpolation:

https://en.wikipedia.org/wiki/Linear_interpolation

The Paul Bourke code works well when you use doubles. However, if you're forced to use floats, then you will run into problems with cracks in the output mesh. If you try to Taubin smooth the mesh, these cracks become gaping holes. So, what you need to do before you do interpolation is to sort the two input vertex positions/density values using an overloaded < operator. This causes the cracks to go away, because the adjacent triangles' vertices always match in terms of location.

I have a whole Marching Cubes code, based on Paul Bourke's implementation:

https://github.com/sjhalayka/marching_cubes/blob/89990697a06af288e936aeba79bb522352b5d894/marching_cubes.cpp#L305

Note: I use an isovalue of 4.0 in my code; it's a quaternion Julia set thing.