You are on page 1of 1

Chapter 8: Base modules 163

for(int i=0; i < np; ++i)


points.push((r(),r()));

int[][] trn=triangulate(points);

for(int i=0; i < trn.length; ++i) {


draw(points[trn[i][0]]--points[trn[i][1]]);
draw(points[trn[i][1]]--points[trn[i][2]]);
draw(points[trn[i][2]]--points[trn[i][0]]);
}

for(int i=0; i < np; ++i)


dot(points[i],red);

The example Gouraudcontour.asy illustrates how to produce color density images


over such irregular triangular meshes. Asymptote uses a robust version of Paul Bourke’s
Delaunay triangulation algorithm based on the public-domain exact arithmetic predicates
written by Jonathan Shewchuk.

8.36 contour3
This module draws surfaces described as the null space of real-valued functions of (x, y, z)
or real[][][] matrices. Its usage is illustrated in the example file magnetic.asy.

8.37 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

You might also like