Sunday, July 26, 2009

Convex hull

convhull

Convex hull

Syntax

*

K = convhull(x,y)
[K,a] = convhull(x,y)

Description

K = convhull(x,y) returns indices into the x and y vectors of the points on the convex hull.

[K,a] = convhull(x,y) also returns the area of the convex hull.

Visualization


Use plot to plot the output of convhull.

Examples

*

xx = -1:.05:1; yy = abs(sqrt(xx));
[x,y] = pol2cart(xx,yy);
k = convhull(x,y);
plot(x(k),y(k),'r-',x,y,'b+')







convhulln

n-D convex hull

Syntax

*

K = convhulln(X)
[K,v] = convhulln(X)

Description


K = convhulln(X) returns the indices K of the points in X that comprise the facets of the convex hull of X. X is an m-by-n array representing m points in n-D space. If the convex hull has p facets then K is p-by-n.

[K,v] = convhulln(X) also returns the volume v of the convex hull.

Visualization

Plotting the output of convhulln depends on the value of n:

* For n = 2, use plot as you would for convhull.
* For n = 3, you can use trisurf to plot the output. The calling sequence is
o

K = convhulln(X);
trisurf(K,(X(:,1),X(:,2),X(:,3))

* For more control over the color of the facets, use patch to plot the output. For an example, see Tessellation and Interpolation of Scattered Data in Higher Dimensions in the MATLAB documentation.

* You cannot plot convhulln output for n > 3.

Algorithm


convhulln is based on Qhull [2]. It uses the Qhull joggle option ('QJ'). For information about qhull, see http://www.geom.umn.edu/software/qhull/. For copyright information, see http://www.geom.umn.edu/software/download/COPYING.html.

No comments:

Post a Comment