1## Copyright (C) 1999, 2000, 2007, 2008, 2009 Kai Habel
3## This file is part of Octave.
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.
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.
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/>.
20## @deftypefn {Function File} {@var{T} =} delaunay3 (@var{x}, @var{y}, @var{z})
21## @deftypefnx {Function File} {@var{T} =} delaunay3 (@var{x}, @var{y}, @var{z}, @var{opt})
22## A matrix of size [n, 4] is returned. Each row contains a
23## set of tetrahedron which are
24## described by the indices to the data point vectors (x,y,z).
26## A fourth optional argument, which must be a string or cell array of strings,
27## contains extra options passed to the underlying qhull command. See the
28## documentation for the Qhull library for details.
29## @seealso{delaunay,delaunayn}
32## Author: Kai Habel <kai.habel@gmx.de>
34function tetr = delaunay3 (x, y, z, opt)
36 if (nargin != 3 && nargin != 4)
40 if (isvector (x) && isvector (y) &&isvector (z)
41 && length (x) == length (y) && length(x) == length (z))
43 tetr = delaunayn ([x(:), y(:), z(:)]);
44 elseif (ischar (opt) || iscell (opt))
45 tetr = delaunayn ([x(:), y(:), z(:)], opt);
47 error ("delaunay3: fourth argument must be a string or cell array of strings");
50 error ("delaunay3: first three input arguments must be vectors of same size");
56%! x = [-1, -1, 1, 0, -1]; y = [-1, 1, 1, 0, -1]; z = [0, 0, 0, 1, 1];
57%! assert (sortrows (sort (delaunay3 (x, y, z), 2)), [1,2,3,4;1,2,4,5])