6823
|
1 ## Copyright (C) 1999,2000 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 2, or (at your option) |
|
8 ## 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, write to the Free |
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
6846
|
21 ## @deftypefn {Function File} {@var{T} =} delaunay3 (@var{x}, @var{y}, @var{z}) |
|
22 ## @deftypefnx {Function File} {@var{T} =} delaunay3 (@var{x}, @var{y}, @var{z}, @var{opt}) |
6823
|
23 ## A matrix of size [n, 4] is returned. Each row contains a |
|
24 ## set of tetrahedron which are |
|
25 ## described by the indices to the data point vectors (x,y,z). |
|
26 ## |
|
27 ## A fourth optional argument, which must be a string or cell array of strings, |
|
28 ## contains extra options passed to the underlying qhull command. See the |
|
29 ## documentation for the Qhull library for details. |
|
30 ## @seealso{delaunay,delaunayn} |
|
31 ## @end deftypefn |
|
32 |
6826
|
33 ## Author: Kai Habel <kai.habel@gmx.de> |
6823
|
34 |
6826
|
35 function tetr = delaunay3 (x, y, z, opt) |
6823
|
36 |
6826
|
37 if (nargin != 3 && nargin != 4) |
6823
|
38 print_usage (); |
|
39 endif |
|
40 |
6826
|
41 if (isvector (x) && isvector (y) &&isvector (z) |
|
42 && length (x) == length (y) && length(x) == length (z)) |
6823
|
43 if (nargin == 3) |
6826
|
44 tetr = delaunayn ([x(:), y(:), z(:)]); |
|
45 elseif (ischar (opt) || iscell (opt)) |
|
46 tetr = delaunayn ([x(:), y(:), z(:)], opt); |
6823
|
47 else |
6826
|
48 error ("delaunay3: fourth argument must be a string or cell array of strings"); |
6823
|
49 endif |
|
50 else |
6826
|
51 error ("delaunay3: first three input arguments must be vectors of same size"); |
6823
|
52 endif |
|
53 |
|
54 endfunction |
|
55 |
|
56 %!test |
|
57 %! x = [-1, -1, 1, 0, -1]; y = [-1, 1, 1, 0, -1]; z = [0, 0, 0, 1, 1]; |
|
58 %! assert (sortrows (sort (delaunay3 (x, y, z), 2)), [1,2,3,4;1,2,4,5]) |
|
59 |