Flat surface from irregular data

I am making a filled contour or surface plot from a scattered dataset.

The main difference from other Qs is that the data is not convex.

[r,th] = meshgrid(10:15,0:180);
[x,y] = deal(r.*sind(th), r.*cosd(th));
z = x.^2+y.^2;
scatter(x(:),y(:),[],z(:),'fill'); axis equal off;

      

The inner circle is null.

enter image description here

I use

tri = delaunay(x,y);
trisurf(tri,x,y,z);  view(2); axis equal off;

      

to make a patch of the surface.

However, as you can see, the inner circle is full.

enter image description here

+3


source to share


1 answer


Instead of using Delaunay triangulation, which results in a convex hull, you will want to use alphaShape

with which you can impose a constraint on the length of the resulting surface edges.

You can specify a property Alpha

(by specifying a third input) that is the inverse of the maximum edge length. For your example, I chose Alpha

from 1.

A = alphaShape(x(:), y(:), 1);

      

Then you can get the triangulation using alphaTriangulation

your object's method alphaSurface

.



[faces, vertices] = A.alphaTriangulation();
zvalue = sum(vertices.^2, 2);

      

Or you can use plot

object methodalphaShape

plot(A, 'FaceColor', 'interp', 'CData', zvalue)

      

enter image description here

+5


source







All Articles