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