convhulln
Computes the ND convex hull.
Syntax
h = convhulln(pts)
h = convhulln(pts,options)
[h,v] = convhulln(...)
Inputs
- pts
- The coordinate matrix.
- options
- The Qhull options. A string with options separated by spaces, or a cell of strings. Omit or use [] for the default. For no options, use an empty string.
Outputs
- h
- Each row contains the indices of a facet of the convex hull.
- v
- The volume of the convex hull.
Example
n = 40;
theta = [1:1:n]/n*(2*pi);
theta = repmat(theta,n/2,1);
phi = [1:1:n/2]'/(n/2)*pi;
phi = repmat(phi,1,n);
xx = 10*(1 + 0.4*cos(8*theta).*cos(8*phi)).*(cos(theta).*cos(phi));
yy = 8*(1 + 0.4*cos(8*theta).*cos(8*phi)).*(cos(theta).*sin(phi));
zz = 6*(1 + 0.4*cos(8*theta).*cos(8*phi)).*sin(theta);
surf(xx,yy,zz);
xlim([-15, 15]);
ylim([-15, 15]);
zlim([-15, 15]);
P = [xx(:), yy(:), zz(:)];
h = convhulln(P);
figure;
surf(xx(h), yy(h), zz(h));
xlim([-15, 15]);
ylim([-15, 15]);
zlim([-15, 15]);
Comments
convhulln uses the Qhull package. For details, see:
http://www.qhull.org/html/qh-quick.htm http://www.qhull.org/html/qh-optq.htmUsing options overwrites the defaults, so the defaults must be repeated if they are to be included.