Mercurial > octave-nkf
annotate scripts/geometry/delaunay.m @ 20654:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | 9fc020886ae9 |
children |
rev | line source |
---|---|
19731
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19630
diff
changeset
|
1 ## Copyright (C) 1999-2015 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 -*- | |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
20 ## @deftypefn {Function File} {@var{tri} =} delaunay (@var{x}, @var{y}) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
21 ## @deftypefnx {Function File} {@var{tetr} =} delaunay (@var{x}, @var{y}, @var{z}) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{tri} =} delaunay (@var{x}) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
23 ## @deftypefnx {Function File} {@var{tri} =} delaunay (@dots{}, @var{options}) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
24 ## Compute the Delaunay triangulation for a 2-D or 3-D set of points. |
13746
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
25 ## |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
26 ## For 2-D sets, the return value @var{tri} is a set of triangles which |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
27 ## satisfies the Delaunay circum-circle criterion, i.e., only a single data |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
28 ## point from [@var{x}, @var{y}] is within the circum-circle of the defining |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
29 ## triangle. The set of triangles @var{tri} is a matrix of size [n, 3]. Each |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
30 ## row defines a triangle and the three columns are the three vertices of the |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
31 ## triangle. The value of @code{@var{tri}(i,j)} is an index into @var{x} and |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
32 ## @var{y} for the location of the j-th vertex of the i-th triangle. |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
33 ## |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
34 ## For 3-D sets, the return value @var{tetr} is a set of tetrahedrons which |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
35 ## satisfies the Delaunay circum-circle criterion, i.e., only a single data |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
36 ## point from [@var{x}, @var{y}, @var{z}] is within the circum-circle of the |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
37 ## defining tetrahedron. The set of tetrahedrons is a matrix of size [n, 4]. |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
38 ## Each row defines a tetrahedron and the four columns are the four vertices of |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
39 ## the tetrahedron. The value of @code{@var{tetr}(i,j)} is an index into |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
40 ## @var{x}, @var{y}, @var{z} for the location of the j-th vertex of the i-th |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
41 ## tetrahedron. |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
42 ## |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
43 ## The input @var{x} may also be a matrix with two or three columns where the |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
44 ## first column contains x-data, the second y-data, and the optional third |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
45 ## column contains z-data. |
6823 | 46 ## |
16928
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
47 ## The optional last argument, which must be a string or cell array of strings, |
13746
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
48 ## contains options passed to the underlying qhull command. |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
49 ## See the documentation for the Qhull library for details |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
50 ## @url{http://www.qhull.org/html/qh-quick.htm#options}. |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
51 ## The default options are @code{@{"Qt", "Qbb", "Qc", "Qz"@}}. |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
52 ## |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
53 ## If @var{options} is not present or @code{[]} then the default arguments are |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
54 ## used. Otherwise, @var{options} replaces the default argument list. |
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
55 ## To append user options to the defaults it is necessary to repeat the |
13746
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
56 ## default arguments in @var{options}. Use a null string to pass no arguments. |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
57 ## |
6823 | 58 ## @example |
59 ## @group | |
6826 | 60 ## x = rand (1, 10); |
13746
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
61 ## y = rand (1, 10); |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
62 ## tri = delaunay (x, y); |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
63 ## triplot (tri, x, y); |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
64 ## hold on; |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
65 ## plot (x, y, "r*"); |
6826 | 66 ## axis ([0,1,0,1]); |
6823 | 67 ## @end group |
68 ## @end example | |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
69 ## @seealso{delaunayn, convhull, voronoi, triplot, trimesh, tetramesh, trisurf} |
6823 | 70 ## @end deftypefn |
71 | |
6826 | 72 ## Author: Kai Habel <kai.habel@gmx.de> |
6823 | 73 |
16928
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
74 function tri = delaunay (varargin) |
6823 | 75 |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
76 if (nargin < 1 || nargin > 4) |
6823 | 77 print_usage (); |
78 endif | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
79 |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
80 z = []; |
16928
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
81 options = []; |
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
82 |
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
83 switch (nargin) |
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
84 |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
85 case 1 |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
86 if (! ismatrix (varargin{1}) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
87 || (columns (varargin{1}) != 2 && columns (varargin{1}) != 3)) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
88 error ("delaunay: X must be a matrix with 2 or 3 columns"); |
16928
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
89 else |
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
90 x = varargin{1}(:,1); |
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
91 y = varargin{1}(:,2); |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
92 if (columns (varargin{1}) == 3) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
93 z = varargin{1}(:,3); |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
94 endif |
16928
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
95 endif |
19627
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
96 |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
97 case 2 |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
98 if (isnumeric (varargin{2})) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
99 x = varargin{1}; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
100 y = varargin{2}; |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
101 elseif (! (ischar (varargin{2}) || iscellstr (varargin{2}))) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
102 error ("delaunay: OPTIONS must be a string or cell array of strings"); |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
103 else |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
104 options = varargin{2}; |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
105 ncols = columns (varargin{1}); |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
106 |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
107 if (! ismatrix (varargin{1}) || (ncols != 2 && ncols != 3)) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
108 error ("delaunay: X must be a matrix with 2 or 3 columns"); |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
109 else |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
110 x = varargin{1}(:,1); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
111 y = varargin{1}(:,2); |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
112 if (ncols == 3) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
113 z = varargin{1}(:,3); |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
114 endif |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
115 endif |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
116 endif |
16928
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
117 |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
118 case 3 |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
119 if (isnumeric (varargin{3})) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
120 x = varargin{1}; |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
121 y = varargin{2}; |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
122 z = varargin{3}; |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
123 elseif (! (ischar (varargin{3}) || iscellstr (varargin{3}))) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
124 error ("delaunay: OPTIONS must be a string or cell array of strings"); |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
125 else |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
126 x = varargin{1}; |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
127 y = varargin{2}; |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
128 options = varargin{3}; |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
129 endif |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
130 |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
131 case 4 |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
132 x = varargin{1}; |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
133 y = varargin{2}; |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
134 z = varargin{3}; |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
135 options = varargin{4}; |
16928
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
136 |
17174
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
137 if (! (ischar (options) || iscellstr (options))) |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
138 error ("delaunay: OPTIONS must be a string or cell array of strings"); |
c3c1ebfaa7dc
maint: Use common indentation for switch statement.
Rik <rik@octave.org>
parents:
17132
diff
changeset
|
139 endif |
16928
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
140 |
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
141 endswitch |
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
142 |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
143 if (isempty (z)) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
144 if (! size_equal (x, y)) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
145 error ("delaunay: X and Y must be the same size"); |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
146 endif |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
147 tri = delaunayn ([x(:), y(:)], options); |
6823 | 148 else |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
149 if (! size_equal (x, y, z)) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
150 error ("delaunay: X, Y, and Z must be the same size"); |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
151 endif |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
152 tri = delaunayn ([x(:), y(:), z(:)], options); |
6823 | 153 endif |
13746
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
154 |
6823 | 155 endfunction |
156 | |
13746
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
157 |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
158 %!demo |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
159 %! old_state = rand ("state"); |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
160 %! restore_state = onCleanup (@() rand ("state", old_state)); |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
161 %! rand ("state", 1); |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
162 %! x = rand (1,10); |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
163 %! y = rand (1,10); |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
164 %! tri = delaunay (x,y); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
165 %! clf; |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
166 %! triplot (tri, x, y); |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
167 %! hold on; |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
168 %! plot (x, y, "r*"); |
13746
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
169 %! axis ([0,1,0,1]); |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
170 |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
171 %!testif HAVE_QHULL |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
172 %! x = [-1, 0, 1, 0]; |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
173 %! y = [0, 1, 0, -1]; |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
174 %! assert (sortrows (sort (delaunay (x, y), 2)), [1,2,4;2,3,4]); |
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
175 |
8153
ec0a13863eb7
Only run tests that depend on HDF5 and QHull if Octave was actually
Soren Hauberg <hauberg@gmail.com>
parents:
7017
diff
changeset
|
176 %!testif HAVE_QHULL |
16928
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
177 %! x = [-1, 0, 1, 0]; |
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
178 %! y = [0, 1, 0, -1]; |
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
179 %! assert (sortrows (sort (delaunay ([x(:) y(:)]), 2)), [1,2,4;2,3,4]); |
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
180 |
7c4a6197e020
delaunay.m: Accept a single matrix as input.
Rik <rik@octave.org>
parents:
14541
diff
changeset
|
181 %!testif HAVE_QHULL |
6823 | 182 %! x = [-1, 0, 1, 0, 0]; |
183 %! y = [0, 1, 0, -1, 0]; | |
13746
7ff0bdc3dc4c
Revamp geometry functions dependent on Qhull (Bug #34604, Bug #33346)
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
184 %! assert (sortrows (sort (delaunay (x, y), 2)), [1,2,5;1,4,5;2,3,5;3,4,5]); |
6823 | 185 |
17132
f72ffae1fcc3
delaunay.m: Fixed matlab compatibility and input check for single matrix (bug #39644)
Andreas Weber <andreas.weber@hs-offenburg.de>
parents:
16932
diff
changeset
|
186 %!testif HAVE_QHULL |
f72ffae1fcc3
delaunay.m: Fixed matlab compatibility and input check for single matrix (bug #39644)
Andreas Weber <andreas.weber@hs-offenburg.de>
parents:
16932
diff
changeset
|
187 %! x = [-1, 0; 0, 1; 1, 0; 0, -1; 0, 0]; |
f72ffae1fcc3
delaunay.m: Fixed matlab compatibility and input check for single matrix (bug #39644)
Andreas Weber <andreas.weber@hs-offenburg.de>
parents:
16932
diff
changeset
|
188 %! assert (sortrows (sort (delaunay (x), 2)), [1,2,5;1,4,5;2,3,5;3,4,5]); |
f72ffae1fcc3
delaunay.m: Fixed matlab compatibility and input check for single matrix (bug #39644)
Andreas Weber <andreas.weber@hs-offenburg.de>
parents:
16932
diff
changeset
|
189 |
f72ffae1fcc3
delaunay.m: Fixed matlab compatibility and input check for single matrix (bug #39644)
Andreas Weber <andreas.weber@hs-offenburg.de>
parents:
16932
diff
changeset
|
190 %!testif HAVE_QHULL |
f72ffae1fcc3
delaunay.m: Fixed matlab compatibility and input check for single matrix (bug #39644)
Andreas Weber <andreas.weber@hs-offenburg.de>
parents:
16932
diff
changeset
|
191 %! x = [1 5 2; 5 6 7]; |
f72ffae1fcc3
delaunay.m: Fixed matlab compatibility and input check for single matrix (bug #39644)
Andreas Weber <andreas.weber@hs-offenburg.de>
parents:
16932
diff
changeset
|
192 %! y = [5 7 8; 1 2 3]; |
f72ffae1fcc3
delaunay.m: Fixed matlab compatibility and input check for single matrix (bug #39644)
Andreas Weber <andreas.weber@hs-offenburg.de>
parents:
16932
diff
changeset
|
193 %! assert (sortrows (sort (delaunay (x, y), 2)), [1,2,4;1,3,4;1,3,5;3,4,6]); |
f72ffae1fcc3
delaunay.m: Fixed matlab compatibility and input check for single matrix (bug #39644)
Andreas Weber <andreas.weber@hs-offenburg.de>
parents:
16932
diff
changeset
|
194 |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
195 ## Test 3-D input |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
196 %!testif HAVE_QHULL |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
197 %! x = [-1, -1, 1, 0, -1]; y = [-1, 1, 1, 0, -1]; z = [0, 0, 0, 1, 1]; |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
198 %! assert (sortrows (sort (delaunay (x, y, z), 2)), [1,2,3,4;1,2,4,5]) |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17174
diff
changeset
|
199 |
19867
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19731
diff
changeset
|
200 ## Input validation tests |
19198
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
201 %!error delaunay () |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
202 %!error delaunay (1,2,3,4,5) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
203 %!error <X must be a matrix with 2 or 3 columns> delaunay (ones (2,4)) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
204 %!error <OPTIONS must be a string or cell array> delaunay (ones (2,2), struct()) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
205 %!error <X must be a matrix with 2 or 3 columns> delaunay (ones (2,4), "") |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
206 %!error <OPTIONS must be a string or cell array> delaunay (ones (2,2), ones (2,2), struct()) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
207 %!error <OPTIONS must be a string or cell array> delaunay (ones (2,2), ones (2,2), ones (2,2), struct()) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
208 %!error <X and Y must be the same size> delaunay (1, [1 2]) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
209 %!error <X, Y, and Z must be the same size> delaunay (1, [1 2], [1 2]) |
ba167badef9f
Deprecate delaunay3 and extend delaunay to 3-D inputs.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
210 |