Contour Plots of Distance Function

DIST_PLOT is a MATLAB program which creates a color contour plot of the distance function, as used in Strang and Persson's DISTMESH program.


dist_plot ( p, t, @fd )


DIST_PLOT is based in part on DISTMESH, which is Copyright (C) 2004 Per-Olof Persson.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

If you use DISTMESH in any program or publication, please acknowledge its authors by citing the reference.


DIST_PLOT is available in a MATLAB version.

Related Data and Programs:

DISTMESH, a MATLAB program which is Strang and Persson's code for generating meshes over regions with an associated distance function.


LEVELS, a MATLAB library which makes a contour plot, choosing the contour levels using random sampling.

TABLE_IO, a MATLAB library which reads and writes files using the TABLE format; these routines are used by DIST_PLOT_DEMO when reading the input files.

TEST_TRIANGULATION, a MATLAB library which defines some test regions for triangulation.

TRIANGULATION_ORDER3, a data directory which discusses order 3 triangulations; The node and triangle files input to DIST_PLOT are an example of such triangulations.

TRIANGULATION_PLOT, a MATLAB program which can make a plot of a triangulation.

TRIANGLE, a C program which can triangulate a region.


  1. http://math.mit.edu/~persson/mesh Per-Olof Persson's web site.
  2. Per-Olof Persson, Gilbert Strang,
    A Simple Mesh Generator in MATLAB,
    SIAM Review,
    Volume 46, Number 2, June 2004, pages 329-345.

Source Code:

Last revised on 08 January 2019