DistMesh Function Reference
Back
boundedges
Syntax: 
e=boundedges(p,t) 
Description: 
Find all the boundary edges e in triangular mesh p,t. 
Comments: 
Useful for implementation of boundary
conditions for PDE solvers. See surftri for 3D version. 
circumcenter
Syntax: 
[pc,r]=circumcenter(p,t) 
Description: 
Compute the circumcenters pc and the circumradii r
for all triangles in the mesh p,t. 
Comments: 
Not vectorized. 
dcircle
Syntax: 
d=dcircle(p,xc,yc,r) 
Description: 
Compute signed distance function for circle centered at xc,yc with
radius r. 
Comments: 

ddiff
Syntax: 
d=ddiff(d1,d2) 
Description: 
Compute signed distance function for set difference of two regions
described by signed distance functions d1,d2. 
Comments: 
Not exactly the true signed distance function for the difference,
for example around corners. 
dellipse
Syntax: 
d=dellipse(p,axes) 
Description: 
Compute distance from points p to the ellipse centered at the origin
with axes=[a,b]. 
Comments: 
C++ code, uses LAPACK for eigenvalue problem. 
dellipsoid
Syntax: 
d=dellipsoid(p,axes) 
Description: 
Compute distance from points p to the ellipsoid centered at the origin
with axes=[a,b,c]. 
Comments: 
C++ code, uses LAPACK for eigenvalue problem. 
dexpr
Syntax: 
d=dexpr(p,fin,nit,alpha) 
Description: 
Compute signed distance function for general implicit expression fin.
The parameters nit and alpha have the default values 20 and 0.1. 
Comments: 
Requires the Symbolic Toolbox, although easy to rewrite to
accept derivatives of fin as inputs. The performance is poor,
a simple C implementation makes a big difference. 
dintersect
Syntax: 
d=dintersect(d1,d2) 
Description: 
Compute signed distance function for set intersection of two regions
described by signed distance functions d1,d2. 
Comments: 
Not exactly the true signed distance function for the intersection,
for example around corners. 
distmesh2d
Syntax: 
[p,t]=distmesh2d(fd,fh,h0,bbox,pfix,fparams) 
Description: 
2D Mesh Generator. See other documentation for details on usage. 
Comments: 

distmeshnd
Syntax: 
[p,t]=distmeshnd(fd,fh,h0,bbox,pfix,fparams) 
Description: 
3D Mesh Generator. See other documentation for details on usage. 
Comments: 

distmeshsurface
Syntax: 
[p,t]=distmeshsurface(fd,fh,h0,bbox,fparams) 
Description: 
3D Surface Mesh Generator. See other documentation for details on usage. 
Comments: 

dmatrix
Syntax: 
d=dmatrix(p,xx,yy,dd) 
Description: 
Compute signed distance function by interpolation of the values dd on
the Cartesian grid xx,yy. 
Comments: 
xx,yy can be created with meshgrid. 
dmatrix3d
Syntax: 
d=dmatrix3d(p,xx,yy,zz,dd) 
Description: 
Compute signed distance function by interpolation of the values dd on
the Cartesian grid xx,yy,zz. 
Comments: 
xx,yy,zz can be created with ndgrid. 
dpoly
Syntax: 
d=dpoly(p,pv) 
Description: 
Compute signed distance function for polygon with vertices pv. 
Comments: 
Uses dsegment and inpolygon. It is usually good to provide pv
as fix points to distmesh2d. 
drectangle
Syntax: 
d=drectangle(p,x1,x2,y1,y2) 
Description: 
Compute signed distance function for rectangle with corners (x1,y1),
(x2,y1), (x1,y2), (x2,y2). 
Comments: 
Incorrect distance to the four corners, see drectangle0 for a true
distance function. 
drectangle0
Syntax: 
d=drectangle0(p,x1,x2,y1,y2) 
Description: 
Compute signed distance function for rectangle with corners (x1,y1),
(x2,y1), (x1,y2), (x2,y2). 
Comments: 
See drectangle for simpler version ignoring corners. 
dsegment
Syntax: 
ds=dsegment(p,pv) 
Description: 
Compute distance from points p to the line segments in pv. 
Comments: 
C++ code, used by dpoly. 
dsphere
Syntax: 
d=dsphere(p,xc,yc,zc,r) 
Description: 
Compute signed distance function for sphere centered at xc,yc,zc with
radius r. 
Comments: 

dunion
Syntax: 
d=dunion(d1,d2) 
Description: 
Compute signed distance function for set union of two regions
described by signed distance functions d1,d2. 
Comments: 
Not exactly the true signed distance function for the union,
for example around corners. 
fixmesh
Syntax: 
[p,t]=fixmesh(p,t) 
Description: 
Remove duplicated and unused nodes from p and update t correspondingly. Also make all elements orientations equal. 
Comments: 

hmatrix
Syntax: 
h=hmatrix(p,xx,yy,dd,hh) 
Description: 
Compute mesh size function by interpolation of the values hh on
the Cartesian grid xx,yy. 
Comments: 
xx,yy can be created with meshgrid. The parameter dd is not used,
but included to get a syntax consistent with dmatrix. 
hmatrix3d
Syntax: 
h=hmatrix3d(p,xx,yy,zz,dd,hh) 
Description: 
Compute mesh size function by interpolation of the values hh on
the Cartesian grid xx,yy,zz. 
Comments: 
xx,yy,zz can be created with ndgrid. The parameter dd is not used,
but included to get a syntax consistent with dmatrix. 
huniform
Syntax: 
h=huniform(p) 
Description: 
Implements the trivial uniform mesh size function h=1. 
Comments: 

meshdemo2d
Syntax: 
meshdemo2d 
Description: 
Demonstration of distmesh2d. 
Comments: 

meshdemond
Syntax: 
meshdemond 
Description: 
Demonstration of distmeshnd. 
Comments: 

mkt2t
Syntax: 
[t2t,t2n]=mkt2t(t) 
Description: 
Compute element connectivities from element indices. 
Comments: 

protate
Syntax: 
p=protate(p,phi) 
Description: 
Rotate points p the angle phi around origin. 
Comments: 

pshift
Syntax: 
p=pshift(p,x0,y0) 
Description: 
Move points p by (x0,y0). 
Comments: 

simpplot
Syntax: 
simpplot(p,t,expr,bcol,icol) 
Description: 
Plot 2D or 3D mesh p,t. The parameters expr, bcol, icol
are only used in 3D and they have default values. 
Comments: 

simpqual
Syntax: 
q=simpqual(p,t,type) 
Description: 
Compute qualities of triangular or tetrahedral elements in
the mesh p,t. If type==1 (default) the inradius/outradius expression
is used. If type==2 a slightly different expression is used. 
Comments: 

simpvol
Syntax: 
v=simpvol(p,t) 
Description: 
Compute the signed volumes of the simplex elements in the mesh p,t. 
Comments: 

surftri
Syntax: 
tri=surftri(p,t) 
Description: 
Find all the surface triangles tri in tetrahedral mesh p,t. 
Comments: 
Used by simpplot. Also useful for implementation of boundary
conditions for PDE solvers. See boundedges for 2D version. 
uniformity
Syntax: 
u=uniformity(p,t,fh,fparams) 
Description: 
Computes "uniformity measure", that is, how close the element sizes
in the mesh p,t are to the desired mesh size function fh. 
Comments: 

PerOlof Persson Department of Mathematics, MIT
"lastname"@math.mit.edu

