Main Content

convexHull

(Not recommended) Convex hull of Delaunay triangulation

convexHull(DelaunayTri) is not recommended. Use convexHull(delaunayTriangulation) instead.

DelaunayTri is not recommended. Use delaunayTriangulation instead.

Description

example

K = convexHull(DT) returns the indices into the array of points DT.X that correspond to the vertices of the convex hull.

example

[K,AV] = convexHull(DT) returns the convex hull and the area or volume bounded by the convex hull.

Examples

collapse all

Compute the convex hull of a set of random points located within a unit square in 2-D space.

rng default
x = rand(10,1);
y = rand(10,1);
dt = DelaunayTri(x,y);
k = convexHull(dt);

Plot the points and convex hull.

plot(dt.X(:,1),dt.X(:,2),'.','MarkerSize',10)
hold on
plot(dt.X(k,1),dt.X(k,2),'r')
hold off

Compute the convex hull of a set of random points located within a unit cube in 3-D space. Specify two outputs with convexHull to also compute the volume bounded by the convex hull.

rng default
X = rand(25,3);
dt = DelaunayTri(X);
[ch,v] = convexHull(dt)
ch = 30×3

     2     9    13
     2    12    18
     2    13    12
     2    14    25
     2    18    14
     2    23     9
     2    25    23
     5     7    22
     5    10     7
     5    18    10
      ⋮

v = 0.3943

Plot the convex hull.

trisurf(ch,dt.X(:,1),dt.X(:,2),dt.X(:,3),'FaceColor','cyan')

Input Arguments

collapse all

Delaunay triangulation representation, specified as a DelaunayTri object.

Output Arguments

collapse all

Indices of convex hull vertices, returned as a column vector or matrix. K contains indices into the array of points DT.X. If the points lie in 2-D space, K is a column vector of length numf. Otherwise K is a matrix of size numf-by-ndim, numf being the number of facets in the convex hull, and ndim the dimension of the space where the points reside.

Area or volume of convex hull, returned as a scalar. AV contains the area (for 2-D triangulations) or volume (for 3-D triangulations) bounded by the convex hull.

More About

collapse all

Convex Hull

The convex hull of a set of points X is the smallest convex region containing all of the points of X.

Extended Capabilities

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

Version History

Introduced in R2009a