1% ex03_polygon.m — A polygon given by its vertices.
2%
3% dpoly is the signed distance to a polygon defined by the vertex list pv
4% (first vertex repeated at the end to close it). pv is passed both as the
5% distance-function parameter and as the set of fixed points, so the mesh
6% boundary follows the polygon edges exactly.
8mip load --install distmesh
10pv=[-0.4 -0.5;0.4 -0.2;0.4 -0.7;1.5 -0.4;0.9 0.1;
11 1.6 0.8;0.5 0.5;0.2 1;0.1 0.4;-0.7 0.7;-0.4 -0.5];
12[p,t]=distmesh2d(@dpoly,@huniform,0.1,[-1,-1; 2,1],pv,pv);
14title('Polygon');
15fprintf('mesh: %d nodes, %d triangles\n', size(p,1), size(t,1));