%% Convex Hull Computation Using alphaShape
% This example shows how to compute the convex hull of a 2-D point set using the alphaShape function.
% alphaShape computes a regularized alpha shape from a set of 2-D or 3-D points. You can specify the alpha radius, which determines how tightly or loosely the alpha shape envelops the point set. When the alpha radius is set to Inf, the resulting alpha shape is the convex hull of the point set.
%
% Create a set of 2-D points.

X = [-1.5 3.2; 1.8 3.3; -3.7 1.5; -1.5 1.3; 0.8 1.2; ...
      3.3 1.5; -4.0 -1.0; -2.3 -0.7; 0 -0.5; 2.0 -1.5; ...
      3.7 -0.8; -3.5 -2.9; -0.9 -3.9; 2.0 -3.5; 3.5 -2.25];

%
% Compute and plot the convex hull of the point set using an alpha shape with alpha radius equal to Inf.

shp = alphaShape(X,Inf);
plot(shp)

% Copyright 2015 The MathWorks, Inc.