]> Creatis software - CreaPhase.git/blob - octave_packages/m/geometry/voronoin.m
update packages
[CreaPhase.git] / octave_packages / m / geometry / voronoin.m
1 ## Copyright (C) 2000-2012 Kai Habel
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING.  If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn  {Function File} {[@var{C}, @var{F}] =} voronoin (@var{pts})
21 ## @deftypefnx {Function File} {[@var{C}, @var{F}] =} voronoin (@var{pts}, @var{options})
22 ## Compute N-dimensional Voronoi facets.  The input matrix @var{pts}
23 ## of size [n, dim] contains n points in a space of dimension dim.
24 ## @var{C} contains the points of the Voronoi facets.  The list @var{F}
25 ## contains, for each facet, the indices of the Voronoi points.
26 ##
27 ## An optional second argument, which must be a string or cell array of strings,
28 ## contains options passed to the underlying qhull command.
29 ## See the documentation for the Qhull library for details
30 ## @url{http://www.qhull.org/html/qh-quick.htm#options}.
31 ## @seealso{voronoi, convhulln, delaunayn}
32 ## @end deftypefn
33
34 ## Author: Kai Habel <kai.habel@gmx.de>
35 ## First Release: 20/08/2000
36
37 ## 2003-12-14 Rafael Laboissiere <rafael@laboissiere.net>
38 ## Added optional second argument to pass options to the underlying
39 ## qhull command
40
41 function [C, F] = voronoin (pts, options)
42
43   if (nargin != 1 && nargin != 2)
44     print_usage ();
45   endif
46
47   [np, dim] = size (pts);
48
49   if (np <= dim)
50     error ("voronoin: number of points must be greater than their dimension");
51   endif
52
53   caller = "voronoin";
54
55   if (nargin == 1)
56     [C, F] = __voronoi__ (caller, pts);
57   else
58     [C, F] = __voronoi__ (caller, pts, options);
59   endif
60
61 endfunction
62
63
64 %% FIXME: Need functional tests
65
66 %% FIXME: Need input validation tests
67