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

    %% Alpha Shape from 2-D Point Cloud
% Create and plot a set of 2-D points.

% Copyright 2015 The MathWorks, Inc.

th = (pi/12:pi/12:2*pi)';
x1 = [reshape(cos(th)*(1:5), numel(cos(th)*(1:5)),1); 0];
y1 = [reshape(sin(th)*(1:5), numel(sin(th)*(1:5)),1); 0];
x = [x1; x1+15];
y = [y1; y1];
plot(x,y,'.')
axis equal

%%
% Compute an alpha shape for the point set using the default alpha
% radius.
shp = alphaShape(x,y);
plot(shp)

%%
% Check the value of the default alpha radius.
shp.Alpha

%%
% The default alpha radius results in an alpha shape with a
% jagged boundary.  To better capture the boundary of the point set, try a
% larger alpha radius.

%%
% Compute an alpha shape using an alpha value of 2.5.
shp.Alpha = 2.5;
plot(shp)