8.38 smoothcontour3

This module, written by Charles Staats, draws implicitly defined surfaces with smooth appearance. The purpose of this module is similar to that of contour3: given a real-valued function f(x,y,z), construct the surface described by the equation f(x,y,z) = 0. The smoothcontour3 module generally produces nicer results than contour3, but takes longer to compile. Additionally, the algorithm assumes that the function and the surface are both smooth; if they are not, then contour3 may be a better choice.

To construct the null surface of a function f(triple) or ff(real,real,real) over box(a,b), use the routine

surface implicitsurface(real f(triple)=null,
                        real ff(real,real,real)=null,
                        triple a,
                        triple b,
                        int n=nmesh,
                        bool keyword overlapedges=false,
                        int keyword nx=n,
                        int keyword ny=n,
                        int keyword nz=n,
                        int keyword maxdepth=8,
                        bool usetriangles=true);

The optional parameter overlapedges attempts to compensate for an artifact that can cause the renderer to “see through” the boundary between patches. Although it defaults to false, it should usually be set to true. The example genustwo.asy illustrates the use of this function. Additional examples, together with a more in-depth explanation of the module’s usage and pitfalls, are available at https://github.com/charlesstaats/smoothcontour3.