# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1327688610 18000 # Node ID 527ed2a51d5458a5d675e43fef7244988d491224 # Parent 37ca58f9a88779b918ef3e882c32a263b1657d13 convhull.m: Allow non-vector arguments, for Matlab compatibility diff --git a/scripts/geometry/convhull.m b/scripts/geometry/convhull.m --- a/scripts/geometry/convhull.m +++ b/scripts/geometry/convhull.m @@ -20,7 +20,7 @@ ## @deftypefn {Function File} {@var{H} =} convhull (@var{x}, @var{y}) ## @deftypefnx {Function File} {@var{H} =} convhull (@var{x}, @var{y}, @var{options}) ## Compute the convex hull of the set of points defined by the -## vectors @var{x} and @var{y}. The hull @var{H} is an index vector into +## arrays @var{x} and @var{y}. The hull @var{H} is an index vector into ## the set of points and specifies which points form the enclosing hull. ## ## An optional third argument, which must be a string or cell array of strings, @@ -45,17 +45,24 @@ print_usage (); endif - if (! (isvector (x) && isvector (y) && length (x) == length (y)) - && ! size_equal (x, y)) - error ("convhull: X and Y must be the same size"); + if (! isvector(x)) + x = x(:); + endif + + if (! isvector(y)) + y = y(:); + endif + + if (length (x) != length (y)) + error ("convhull: X and Y must have the same size"); elseif (nargin == 3 && ! (ischar (options) || iscellstr (options))) error ("convhull: OPTIONS must be a string or cell array of strings"); endif if (nargin == 2) - i = convhulln ([x(:), y(:)]); + i = convhulln ([x, y]); else - i = convhulln ([x(:), y(:)], options); + i = convhulln ([x, y], options); endif n = rows (i);