Skip to content

convhull

geometry · scripts/geometry/convhull.m

: k = convhull (x, y)
: k = convhull (x, y, z)
: k = convhull (p)
: k = convhull (…, "Simplify", tf)
: [k, v] = convhull (…)

Compute the convex hull of a 2-D or 3-D point set.

The points are given as coordinate arrays of identical size or as the rows of p (two or three columns).

In two dimensions k is a column of point indices running counter-clockwise around the hull and closed (first index repeated at the end). In three dimensions k has one triangular facet per row, oriented with the normal pointing out of the hull. The second output v is the area (2-D) or volume (3-D) of the hull.

The name-value pair "Simplify", tf controls whether vertices that do not contribute to the area or volume are dropped. tf defaults to false: collinear edge points (2-D) and coplanar face points including face interiors (3-D) stay on the hull. When tf is true, only vertices that change the area or volume are kept. A trailing character or cell array option list is accepted and ignored (Qhull-style options).

Fewer than three (four in 3-D) points, or points that are collinear (coplanar), are an error, as are NaN and Inf coordinates.