.. highlightlang:: us .. _poly_hull: poly_hull ========= .. index:: poly_hull .. us.tag poly_hull NOTREADYENGLISH base_graph New363 Changed400 :ref:`poly_hull` calculates the convex hull in the x/y plane. .. function:: rvIdx = poly_hull(x, y) rvIdx = poly_hull(x, y, opt) .. us.return **Return Value** *rvIdx* are the hull indices. In case of an error *rvIdx* is a string vector with two elements. The first element identifies the error, the second element is the error text. .. us.params **Parameters** .. uparam:: x *x* is a vector with x coordinates. The vector must have the same number of elements as the vector *y*. .. uparam:: y *y* is a vector with y coordinates. The vector must have the same number of elements as the vector *x*. At least 4 elements are necessary. .. uparam:: opt If *opt* is set to 1, points on the edge of the hull will not be ignored. If set to 0 (default value) points on the edge of the hull will be ignored. .. us.example **Example** :: * poly_hull([0,1,1,0,0], [0,0,1,1,0]) 1.0000 2.0000 3.0000 4.0000 1.0000 :: * poly_hull(rand(1,1000), rand(1,1000)) 443.0000 970.0000 939.0000 591.0000 526.0000 776.0000 584.0000 92.0000 536.0000 877.0000 580.0000 238.0000 50.0000 875.0000 338.0000 230.0000 44.0000 288.0000 243.0000 443.0000 :: * poly_hull([1,1,1],[1,1,1]) 2,x-poly-error Singular Input Data (e.g. Points form a line) .. image:: S:/uniplot-obj/images/poly_hull.* :: idx = poly_hull(x = rand(1,1000), y = rand(1,1000)) if (type(idx) == "string") { MessageBoxError("Error: " + idx[1] + "\n\n + idx[2]); return 0; } h = plot(x[idx], y[idx]) h2 = plot(x, y, h[2]) XYShowMarker(h2[3], TRUE) XYShowLine(h2[3], FALSE) LayerSetAxisMinMaxDelta(h2[2], "X", -0.1, 1.1, 0.1) LayerSetAxisMinMaxDelta(h2[2], "Y", -0.1, 1.1, 0.1) LayerShowGrid(h2[2], "X", FALSE, FALSE) LayerShowGrid(h2[2], "Y", FALSE, FALSE) LayerSetAxisTitle(h2[2], "X", "") LayerSetAxisTitle(h2[2], "Y", "") PageReplot(h2[1]) .. seealso:: :ref:`poly_triangulate` This function uses the qhull algorithm see: Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., "The Quickhull algorithm for convex hulls," ACM Trans. on Mathematical Software, Dec 1996. http://www.qhull.org/. .. code-block:: none Qhull, Copyright (c) 1993-2002 The National Science and Technology Research Center for Computation and Visualization of Geometric Structures (The Geometry Center) University of Minnesota 400 Lind Hall 207 Church Street S.E. Minneapolis, MN 55455 USA email: qhull@geom.umn.edu This software includes Qhull from The Geometry Center. Qhull is copyrighted as noted above. Qhull is free software and may be obtained via http from www.geom.umn.edu. It may be freely copied, modified, and redistributed under the following conditions: 1. All copyright notices must remain intact in all files. 2. A copy of this text file must be distributed along with any copies of Qhull that you redistribute; this includes copies that you have modified, or copies of programs or other software products that include Qhull. 3. If you modify Qhull, you must include a notice giving the name of the person performing the modification, the date of modification, and the reason for such modification. 4. When distributing modified versions of Qhull, or other software products that include Qhull, you must provide notice that the original source code may be obtained as noted above. 5. There is no warranty or other guarantee of fitness for Qhull, it is provided solely "as is". Bug reports or fixes may be sent to qhull_bug@geom.umn.edu; the authors may or may not act on them as they desire. :sub:`id-749714`