Mercurial > hg > octave-lyh
annotate scripts/geometry/voronoin.m @ 13203:b6aba5b4edb1
voronoin: accept options as a cell array of character strings
* __voronoi__.cc (F__voronoi__): Accept options as cell array of
character strings. Use std::string for buffer. Don't use fixed size
for char* buffer that is passed to qh_new_qhull.
* voronoin.m: Accept options as cell array of character strings.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 23 Sep 2011 15:03:29 -0400 |
parents | fd0a3ac60b0e |
children | 7ff0bdc3dc4c |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2000-2011 Kai Habel |
6823 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6823 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6823 | 18 |
19 ## -*- texinfo -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10791
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{C}, @var{F}] =} voronoin (@var{pts}) |
6823 | 21 ## @deftypefnx {Function File} {[@var{C}, @var{F}] =} voronoin (@var{pts}, @var{options}) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
22 ## Compute N-dimensional Voronoi facets. The input matrix @var{pts} |
6823 | 23 ## of size [n, dim] contains n points of dimension dim. |
10791
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
9051
diff
changeset
|
24 ## @var{C} contains the points of the Voronoi facets. The list @var{F} |
3140cb7a05a1
Add spellchecker scripts for Octave and run spellcheck of documentation
Rik <octave@nomad.inbox5.com>
parents:
9051
diff
changeset
|
25 ## contains for each facet the indices of the Voronoi points. |
6823 | 26 ## |
27 ## A second optional argument, which must be a string, contains extra options | |
28 ## passed to the underlying qhull command. See the documentation for the | |
29 ## Qhull library for details. | |
30 ## @seealso{voronoin, delaunay, convhull} | |
31 ## @end deftypefn | |
32 | |
33 ## Author: Kai Habel <kai.habel@gmx.de> | |
34 ## First Release: 20/08/2000 | |
35 | |
36 ## 2003-12-14 Rafael Laboissiere <rafael@laboissiere.net> | |
37 ## Added optional second argument to pass options to the underlying | |
38 ## qhull command | |
39 | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
40 function [C, F] = voronoin (pts, options) |
6823 | 41 |
6826 | 42 if (nargin != 1 && nargin != 2) |
6823 | 43 print_usage (); |
44 endif | |
45 | |
46 [np, dims] = size (pts); | |
47 if (np > dims) | |
48 if (nargin == 1) | |
49 [C, F, infi] = __voronoi__ (pts); | |
13203
b6aba5b4edb1
voronoin: accept options as a cell array of character strings
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
50 elseif (ischar (options) || iscellstr (options)) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
51 [C, F, infi] = __voronoi__ (pts, options); |
6823 | 52 else |
13203
b6aba5b4edb1
voronoin: accept options as a cell array of character strings
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
53 error ("voronoin: second argument must be a string or cell array of strings"); |
6823 | 54 endif |
55 | |
56 else | |
8664 | 57 error ("voronoin: number of points must be greater than their dimension"); |
6823 | 58 endif |
59 endfunction |