www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/BoundaryOf3DAlphaShapeExample.m

    %% Find Boundary of 3-D Alpha Shape
% Create a set of 3-D points.   

% Copyright 2015 The MathWorks, Inc.

[x1, y1, z1] = sphere(24);
x1 = x1(:);
y1 = y1(:);
z1 = z1(:);
x2 = x1+5;
P = [x1 y1 z1; x2 y1 z1];
P = unique(P,'rows');

%%
% Create and plot an alpha shape using an alpha radius of 1.5.
shp = alphaShape(P,1.5);
plot(shp)
axis equal

%%
% Compute and plot only the boundary of the alpha shape.
[tri, xyz] = boundaryFacets(shp);
trisurf(tri,xyz(:,1),xyz(:,2),xyz(:,3),...
    'FaceColor','cyan','FaceAlpha',0.3) 
axis equal