convhulln

Computes the ND convex hull.

Syntax

h = convhulln(pts)

h = convhulln(pts,options)

[h,v] = convhulln(...)

Inputs

pts
The coordinate matrix.
Each row contains the coordinates of a point.
Type: double
Dimension: 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.
Defaults:
  • 'Qt': for less than five dimensions.
  • 'Qt Qx': for five or more dimensions. See Comments.

Outputs

h
Each row contains the indices of a facet of the convex hull.
Dimension: matrix
v
The volume of the convex hull.
Type: double
Dimension: scalar

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]);


Figure 1. convhull figure 1
Figure 2. convhull figure 1

Comments

convhulln uses the Qhull package. For details, see:

http://www.qhull.org/html/qh-quick.htm http://www.qhull.org/html/qh-optq.htm

Using options overwrites the defaults, so the defaults must be repeated if they are to be included.