concept-collection / numbl-distmesh
numbl-distmesh / ex04_ellipse.m
13 lines · 447 BBlameHistoryRaw
1% ex04_ellipse.m — Uniform mesh on an ellipse.
2%
3% The distance function here is only approximate (x^2/4 + y^2 - 1), but
4% DistMesh still converges to a good mesh: boundary points are projected
5% back onto the level set d = 0 at every step.
7mip load --install distmesh
9fd=@(p) p(:,1).^2/2^2+p(:,2).^2/1^2-1;
10[p,t]=distmesh2d(fd,@huniform,0.2,[-2,-1;2,1],[]);
12title('Ellipse');
13fprintf('mesh: %d nodes, %d triangles\n', size(p,1), size(t,1));