Skip to Main Content Skip to Search
Product Documentation

convhull - Convex hull

Syntax

K = convhull(X,Y)
K = convhull(X,Y,Z)
K = convhull(X)
K = convhull(...,'simplify', logicalvar)
[K,V] = convhull(...)

Definitions

convhull returns the convex hull of a set of points in 2-D or 3-D space.

Description

K = convhull(X,Y) returns the 2-D convex hull of the points (X,Y), where X and Y are column vectors. The convex hull K is expressed in terms of a vector of point indices arranged in a counterclockwise cycle around the hull.

K = convhull(X,Y,Z) returns the 3-D convex hull of the points (X,Y,Z), where X, Y, and Z are column vectors. K is a triangulation representing the boundary of the convex hull. K is of size mtri-by-3, where mtri is the number of triangular facets. That is, each row of K is a triangle defined in terms of the point indices.

K = convhull(X) returns the 2-D or 3-D convex hull of the points X. This variant supports the definition of points in matrix format. X is of size mpts-by-ndim, where mpts is the number of points and ndim is the dimension of the space where the points reside, 2 ≦ ndim ≦ 3. The output facets are equivalent to those generated by the 2-input or 3-input calling syntax.

K = convhull(...,'simplify', logicalvar) provides the option of removing vertices that do not contribute to the area/volume of the convex hull, the default is false. Setting 'simplify' to true returns the topology in a more concise form.

[K,V] = convhull(...) returns the convex hull K and the corresponding area/volume V bounded by K.

Visualization

Use plot to plot the output of convhull in 2-D. Use trisurf or trimesh to plot the output of convhull in 3-D.

Examples

Example 1

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+')

See Also

convhulln | delaunay | DelaunayTri/convexHull | DelaunayTri/voronoiDiagram | polyarea | voronoi

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS