Mercurial > hg > octave-nkf
comparison scripts/geometry/voronoin.m @ 13746:7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
* NEWS : Document new options being passed to Qhull
* convhull.m, delaunay.m, delaunay3.m, delaunayn.m, voronoi.m, voronoin.m:
Update docstrings. Put input validation first. Use same variable names
as Matlab. Restore random state altered in demos.
* __delaunayn__.cc: Use common syntax for parsing OPTIONS input.
Add 'Qz' option to qhull command for 2D,3D data. Correctly free
all Qhull memory and avoid segfault with non-simplicial facets.
* __voronoi__.cc: Use common syntax for parsing OPTIONS input.
Correctly free all Qhull memory.
* convhulln.cc: Use common syntax for parsing OPTIONS input.
Use Matlab-compatible options for qhull command.
Correctly free all Qhull memory. Allow return of non-simplicial
facets without causing a segfault.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 25 Oct 2011 10:17:23 -0700 |
parents | b6aba5b4edb1 |
children | 440d7914cf01 |
comparison
equal
deleted
inserted
replaced
13745:3c3b74677fa0 | 13746:7ff0bdc3dc4c |
---|---|
18 | 18 |
19 ## -*- texinfo -*- | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {[@var{C}, @var{F}] =} voronoin (@var{pts}) | 20 ## @deftypefn {Function File} {[@var{C}, @var{F}] =} voronoin (@var{pts}) |
21 ## @deftypefnx {Function File} {[@var{C}, @var{F}] =} voronoin (@var{pts}, @var{options}) | 21 ## @deftypefnx {Function File} {[@var{C}, @var{F}] =} voronoin (@var{pts}, @var{options}) |
22 ## Compute N-dimensional Voronoi facets. The input matrix @var{pts} | 22 ## Compute N-dimensional Voronoi facets. The input matrix @var{pts} |
23 ## of size [n, dim] contains n points of dimension dim. | 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} | 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. | 25 ## contains, for each facet, the indices of the Voronoi points. |
26 ## | 26 ## |
27 ## A second optional argument, which must be a string, contains extra options | 27 ## An optional second argument, which must be a string or cell array of strings, |
28 ## passed to the underlying qhull command. See the documentation for the | 28 ## contains options passed to the underlying qhull command. |
29 ## Qhull library for details. | 29 ## See the documentation for the Qhull library for details |
30 ## @seealso{voronoin, delaunay, convhull} | 30 ## @url{http://www.qhull.org/html/qh-quick.htm#options}. |
31 ## @seealso{voronoi, convhulln, delaunayn} | |
31 ## @end deftypefn | 32 ## @end deftypefn |
32 | 33 |
33 ## Author: Kai Habel <kai.habel@gmx.de> | 34 ## Author: Kai Habel <kai.habel@gmx.de> |
34 ## First Release: 20/08/2000 | 35 ## First Release: 20/08/2000 |
35 | 36 |
41 | 42 |
42 if (nargin != 1 && nargin != 2) | 43 if (nargin != 1 && nargin != 2) |
43 print_usage (); | 44 print_usage (); |
44 endif | 45 endif |
45 | 46 |
46 [np, dims] = size (pts); | 47 [np, dim] = size (pts); |
47 if (np > dims) | |
48 if (nargin == 1) | |
49 [C, F, infi] = __voronoi__ (pts); | |
50 elseif (ischar (options) || iscellstr (options)) | |
51 [C, F, infi] = __voronoi__ (pts, options); | |
52 else | |
53 error ("voronoin: second argument must be a string or cell array of strings"); | |
54 endif | |
55 | 48 |
49 if (np <= dim) | |
50 error ("voronoin: number of points must be greater than their dimension"); | |
51 elseif (nargin == 2 && ! (ischar (options) || iscellstr (options))) | |
52 error ("voronoin: OPTIONS argument must be a string or cell array of strings"); | |
53 endif | |
54 | |
55 if (nargin == 1) | |
56 [C, F] = __voronoi__ (pts); | |
56 else | 57 else |
57 error ("voronoin: number of points must be greater than their dimension"); | 58 [C, F] = __voronoi__ (pts, options); |
58 endif | 59 endif |
60 | |
59 endfunction | 61 endfunction |
62 | |
63 | |
64 %% FIXME: Need functional tests | |
65 | |
66 %% FIXME: Need input validation tests | |
67 |