## DistMesh Function Reference

Back

### boundedges

Syntax: e=boundedges(p,t) Find all the boundary edges e in triangular mesh p,t. Useful for implementation of boundary conditions for PDE solvers. See surftri for 3-D version.

### circumcenter

Syntax: [pc,r]=circumcenter(p,t) Compute the circumcenters pc and the circumradii r for all triangles in the mesh p,t. Not vectorized.

### dcircle

Syntax: d=dcircle(p,xc,yc,r) Compute signed distance function for circle centered at xc,yc with radius r.

### ddiff

Syntax: d=ddiff(d1,d2) Compute signed distance function for set difference of two regions described by signed distance functions d1,d2. Not exactly the true signed distance function for the difference, for example around corners.

### dellipse

Syntax: d=dellipse(p,axes) Compute distance from points p to the ellipse centered at the origin with axes=[a,b]. C++ code, uses LAPACK for eigenvalue problem.

### dellipsoid

Syntax: d=dellipsoid(p,axes) Compute distance from points p to the ellipsoid centered at the origin with axes=[a,b,c]. C++ code, uses LAPACK for eigenvalue problem.

### dexpr

Syntax: d=dexpr(p,fin,nit,alpha) Compute signed distance function for general implicit expression fin. The parameters nit and alpha have the default values 20 and 0.1. 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) Compute signed distance function for set intersection of two regions described by signed distance functions d1,d2. 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) 2-D Mesh Generator. See other documentation for details on usage.

### distmeshnd

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

### distmeshsurface

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

### dmatrix

Syntax: d=dmatrix(p,xx,yy,dd) Compute signed distance function by interpolation of the values dd on the Cartesian grid xx,yy. xx,yy can be created with meshgrid.

### dmatrix3d

Syntax: d=dmatrix3d(p,xx,yy,zz,dd) Compute signed distance function by interpolation of the values dd on the Cartesian grid xx,yy,zz. xx,yy,zz can be created with ndgrid.

### dpoly

Syntax: d=dpoly(p,pv) Compute signed distance function for polygon with vertices pv. 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) Compute signed distance function for rectangle with corners (x1,y1), (x2,y1), (x1,y2), (x2,y2). Incorrect distance to the four corners, see drectangle0 for a true distance function.

### drectangle0

Syntax: d=drectangle0(p,x1,x2,y1,y2) Compute signed distance function for rectangle with corners (x1,y1), (x2,y1), (x1,y2), (x2,y2). See drectangle for simpler version ignoring corners.

### dsegment

Syntax: ds=dsegment(p,pv) Compute distance from points p to the line segments in pv. C++ code, used by dpoly.

### dsphere

Syntax: d=dsphere(p,xc,yc,zc,r) Compute signed distance function for sphere centered at xc,yc,zc with radius r.

### dunion

Syntax: d=dunion(d1,d2) Compute signed distance function for set union of two regions described by signed distance functions d1,d2. Not exactly the true signed distance function for the union, for example around corners.

### fixmesh

Syntax: [p,t]=fixmesh(p,t) Remove duplicated and unused nodes from p and update t correspondingly. Also make all elements orientations equal.

### hmatrix

Syntax: h=hmatrix(p,xx,yy,dd,hh) Compute mesh size function by interpolation of the values hh on the Cartesian grid xx,yy. 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) Compute mesh size function by interpolation of the values hh on the Cartesian grid xx,yy,zz. 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) Implements the trivial uniform mesh size function h=1.

### meshdemo2d

Syntax: meshdemo2d Demonstration of distmesh2d.

### meshdemond

Syntax: meshdemond Demonstration of distmeshnd.

### mkt2t

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

### protate

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

### pshift

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

### simpplot

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

### simpqual

Syntax: q=simpqual(p,t,type) 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.

### simpvol

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

### surftri

Syntax: tri=surftri(p,t) Find all the surface triangles tri in tetrahedral mesh p,t. Used by simpplot. Also useful for implementation of boundary conditions for PDE solvers. See boundedges for 2-D version.

### uniformity

Syntax: u=uniformity(p,t,fh,fparams) Computes "uniformity measure", that is, how close the element sizes in the mesh p,t are to the desired mesh size function fh.