<html lang="en"> <head> <title>Convex Hull - GNU Octave</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GNU Octave"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Geometry.html#Geometry" title="Geometry"> <link rel="prev" href="Voronoi-Diagrams.html#Voronoi-Diagrams" title="Voronoi Diagrams"> <link rel="next" href="Interpolation-on-Scattered-Data.html#Interpolation-on-Scattered-Data" title="Interpolation on Scattered Data"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Convex-Hull"></a> <p> Next: <a rel="next" accesskey="n" href="Interpolation-on-Scattered-Data.html#Interpolation-on-Scattered-Data">Interpolation on Scattered Data</a>, Previous: <a rel="previous" accesskey="p" href="Voronoi-Diagrams.html#Voronoi-Diagrams">Voronoi Diagrams</a>, Up: <a rel="up" accesskey="u" href="Geometry.html#Geometry">Geometry</a> <hr> </div> <h3 class="section">30.3 Convex Hull</h3> <p>The convex hull of a set of points is the minimum convex envelope containing all of the points. Octave has the functions <code>convhull</code> and <code>convhulln</code> to calculate the convex hull of 2-dimensional and N-dimensional sets of points. <!-- convhull scripts/geometry/convhull.m --> <p><a name="doc_002dconvhull"></a> <div class="defun"> — Function File: <var>H</var> = <b>convhull</b> (<var>x, y</var>)<var><a name="index-convhull-2809"></a></var><br> — Function File: <var>H</var> = <b>convhull</b> (<var>x, y, options</var>)<var><a name="index-convhull-2810"></a></var><br> <blockquote><p>Compute the convex hull of the set of points defined by the vectors <var>x</var> and <var>y</var>. The hull <var>H</var> is an index vector into the set of points and specifies which points form the enclosing hull. <p>An optional third argument, which must be a string or cell array of strings, contains options passed to the underlying qhull command. See the documentation for the Qhull library for details <a href="http://www.qhull.org/html/qh-quick.htm#options">http://www.qhull.org/html/qh-quick.htm#options</a>. The default option is <code>{"Qt"}</code>. <p>If <var>options</var> is not present or <code>[]</code> then the default arguments are used. Otherwise, <var>options</var> replaces the default argument list. To append user options to the defaults it is necessary to repeat the default arguments in <var>options</var>. Use a null string to pass no arguments. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dconvhulln.html#doc_002dconvhulln">convhulln</a>, <a href="doc_002ddelaunay.html#doc_002ddelaunay">delaunay</a>, <a href="doc_002dvoronoi.html#doc_002dvoronoi">voronoi</a>. </p></blockquote></div> <!-- convhulln src/DLD-FUNCTIONS/convhulln.cc --> <p><a name="doc_002dconvhulln"></a> <div class="defun"> — Loadable Function: <var>h</var> = <b>convhulln</b> (<var>pts</var>)<var><a name="index-convhulln-2811"></a></var><br> — Loadable Function: <var>h</var> = <b>convhulln</b> (<var>pts, options</var>)<var><a name="index-convhulln-2812"></a></var><br> — Loadable Function: [<var>h</var>, <var>v</var>] = <b>convhulln</b> (<var><small class="dots">...</small></var>)<var><a name="index-convhulln-2813"></a></var><br> <blockquote><p>Compute the convex hull of the set of points <var>pts</var> which is a matrix of size [n, dim] containing n points in a space of dimension dim. The hull <var>h</var> is an index vector into the set of points and specifies which points form the enclosing hull. <p>An optional second argument, which must be a string or cell array of strings, contains options passed to the underlying qhull command. See the documentation for the Qhull library for details <a href="http://www.qhull.org/html/qh-quick.htm#options">http://www.qhull.org/html/qh-quick.htm#options</a>. The default options depend on the dimension of the input: <ul> <li>2D, 3D, 4D: <var>options</var> = <code>{"Qt"}</code> <li>5D and higher: <var>options</var> = <code>{"Qt", "Qx"}</code> </ul> <p>If <var>options</var> is not present or <code>[]</code> then the default arguments are used. Otherwise, <var>options</var> replaces the default argument list. To append user options to the defaults it is necessary to repeat the default arguments in <var>options</var>. Use a null string to pass no arguments. <p>If the second output <var>v</var> is requested the volume of the enclosing convex hull is calculated. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dconvhull.html#doc_002dconvhull">convhull</a>, <a href="doc_002ddelaunayn.html#doc_002ddelaunayn">delaunayn</a>, <a href="doc_002dvoronoin.html#doc_002dvoronoin">voronoin</a>. </p></blockquote></div> <p>An example of the use of <code>convhull</code> is <pre class="example"> x = -3:0.05:3; y = abs (sin (x)); k = convhull (x, y); plot (x(k), y(k), "r-", x, y, "b+"); axis ([-3.05, 3.05, -0.05, 1.05]); </pre> <p class="noindent">The output of the above can be seen in <a href="fig_003aconvhull.html#fig_003aconvhull">fig:convhull</a>. <div class="float"> <a name="fig_003aconvhull"></a><div align="center"><img src="convhull.png" alt="convhull.png"></div> <p><strong class="float-caption">Figure 30.5: The convex hull of a simple set of points</strong></p></div> </body></html>