convhull

Computes the 2D convex hull.

Syntax

h = convhull(x,y)

h = convhull(x,y,options)

[h,a] = convhull(...)

Inputs

x
The x coordinates.
Type: double
Dimension: vector
y
The y coordinates.
Type: double
Dimension: vector
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.
Default: 'Qt'

Outputs

h
The indices of the convex hull vertices.
Dimension: vector
a
The area of the convex hull.
Type: double
Dimension: scalar

Example

ang = [1:1:60] * (2*pi/60);
x = 8 .* (1 + 0.1*cos(8*ang)) .* cos(ang);
y = 6 .* (1 + 0.1*cos(8*ang)) .* sin(ang);
h = convhull(x, y);
plot(x,y);
hold on;
plot(x(h),y(h));
legend('shape', 'hull');
Figure 1. convhull figure 1


Comments

convhulln uses the Qhull package. For details, see:

http://www.qhull.org/html/qh-quick.htm http://www.qhull.org/html/qh-optq.htm

Using options overwrites the default, so the default must be repeated if it is to be included.