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

    %% Find Critical Alpha Values of 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

%%
% Create an alpha shape using the default alpha radius.
shp = alphaShape(x,y);

%%
% Compute the smallest alpha radius that produces an alpha shape enclosing
% all of the points and plot the corresponding alpha shape.
pc = criticalAlpha(shp,'all-points');
shp.Alpha = pc;
plot(shp)

%%
% Compute the smallest alpha radius that produces an alpha shape
% enclosing all of the points and having only one region.
shp = alphaShape(x,y);
pc = criticalAlpha(shp,'one-region');
shp.Alpha = pc;
plot(shp)