annotate scripts/plot/draw/isocolors.m @ 30236:628f26e122d9

maint: use rows() or columns() instead of size(__, 1 | 2) for clarity. * ccolamd.cc, colamd.cc, Map.m, material.m, isocolors.m, isonormals.m, isosurface.m, light.m, reducepatch.m, reducevolume.m, movfun.m, ilu.m, __alltohandles__.m, dump_demos.m, mk-sparse-tst.sh: Use rows() or columns() instead of size(__, 1 | 2) for clarity.
author Rik <rik@octave.org>
date Mon, 11 Oct 2021 20:09:59 -0700
parents 7854d5752dd2
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27978
diff changeset
3 ## Copyright (C) 2009-2021 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
7 ##
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
8 ## This file is part of Octave.
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
14 ##
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 ##
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
25
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
26 ## -*- texinfo -*-
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
27 ## @deftypefn {} {@var{cdat} =} isocolors (@var{c}, @var{v})
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
28 ## @deftypefnx {} {@var{cdat} =} isocolors (@var{x}, @var{y}, @var{z}, @var{c}, @var{v})
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
29 ## @deftypefnx {} {@var{cdat} =} isocolors (@var{x}, @var{y}, @var{z}, @var{r}, @var{g}, @var{b}, @var{v})
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
30 ## @deftypefnx {} {@var{cdat} =} isocolors (@var{r}, @var{g}, @var{b}, @var{v})
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
31 ## @deftypefnx {} {@var{cdat} =} isocolors (@dots{}, @var{p})
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
32 ## @deftypefnx {} {} isocolors (@dots{})
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
33 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
34 ## Compute isosurface colors.
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
35 ##
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
36 ## If called with one output argument, and the first input argument @var{c}
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
37 ## is a three-dimensional array that contains indexed color values, and the
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
38 ## second input argument @var{v} are the vertices of an isosurface geometry,
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
39 ## then return a matrix @var{cdat} with color data information for the geometry
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
40 ## at computed points @code{[x, y, z] = meshgrid (1:l, 1:m, 1:n)}. The output
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
41 ## argument @var{cdat} can be used to manually set the
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
42 ## @qcode{"FaceVertexCData"} property of an isosurface patch object.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
43 ##
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
44 ## If called with additional input arguments @var{x}, @var{y} and @var{z} which
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
45 ## are three-dimensional arrays of the same size as @var{c} then the
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
46 ## color data is taken at those specified points.
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
47 ##
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
48 ## Instead of indexed color data @var{c}, @code{isocolors} can also be called
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
49 ## with RGB values @var{r}, @var{g}, @var{b}. If input arguments @var{x},
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
50 ## @var{y}, @var{z} are not given then @code{meshgrid} computed values are
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
51 ## used.
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
52 ##
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
53 ## Optionally, a patch handle @var{p} can be given as the last input argument
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
54 ## to all function call variations and the vertex data will be extracted
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
55 ## from the isosurface patch object. Finally, if no output argument is given
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
56 ## then the colors of the patch given by the patch handle @var{p} are changed.
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
57 ##
12529
0579a13f29a1 Add isocolors, isonormals, isosurface functions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
58 ## @seealso{isosurface, isonormals}
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
59 ## @end deftypefn
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
60
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
61 function cdat = isocolors (varargin)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
62
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
63 calc_rgb = false;
11120
a44f979a35ce style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents: 11104
diff changeset
64 switch (nargin)
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
65 case 2
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
66 c = varargin{1};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
67 vp = varargin{2};
30236
628f26e122d9 maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents: 29359
diff changeset
68 x = 1:columns (c);
628f26e122d9 maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents: 29359
diff changeset
69 y = 1:rows (c);
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
70 z = 1:size (c, 3);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
71 case 4
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
72 calc_rgb = true;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
73 R = varargin{1};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
74 G = varargin{2};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
75 B = varargin{3};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
76 vp = varargin{4};
30236
628f26e122d9 maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents: 29359
diff changeset
77 x = 1:rows (R);
628f26e122d9 maint: use rows() or columns() instead of size(__, 1 | 2) for clarity.
Rik <rik@octave.org>
parents: 29359
diff changeset
78 y = 1:columns (R);
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
79 z = 1:size (R, 3);
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
80 case 5
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
81 x = varargin{1};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
82 y = varargin{2};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
83 z = varargin{3};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
84 c = varargin{4};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
85 vp = varargin{5};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
86 case 7
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
87 calc_rgb = true;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
88 x = varargin{1};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
89 y = varargin{2};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
90 z = varargin{3};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
91 R = varargin{4};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
92 G = varargin{5};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
93 B = varargin{6};
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
94 vp = varargin{7};
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
95 otherwise
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
96 print_usage ();
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
97 endswitch
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
98
19700
00e31f316a3a Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 19697
diff changeset
99 if (isnumeric (vp) && columns (vp) == 3)
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
100 pa = [];
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
101 v = vp;
24423
1d52db450db4 Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents: 24188
diff changeset
102 elseif (isgraphics (vp, "patch"))
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
103 pa = vp;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
104 v = get (pa, "Vertices");
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
105 else
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
106 error ("isocolors: last argument must be a vertex list or patch handle");
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
107 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
108
11120
a44f979a35ce style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents: 11104
diff changeset
109 if (calc_rgb)
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
110 new_colors = zeros (rows (v), 3);
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
111 new_colors(:,1) = __interp_cube__ ("isocolors", x, y, z, R, v, "values");
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
112 new_colors(:,2) = __interp_cube__ ("isocolors", x, y, z, G, v, "values");
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
113 new_colors(:,3) = __interp_cube__ ("isocolors", x, y, z, B, v, "values");
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
114 else
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
115 new_colors = __interp_cube__ ("isocolors", x, y, z, c, v, "values");
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
116 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
117
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
118 if (nargout == 0)
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
119 if (! isempty (pa))
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
120 set (pa, "FaceVertexCData", new_colors);
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
121 endif
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
122 else
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
123 cdat = new_colors;
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
124 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
125
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
126 endfunction
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
127
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
128
22790
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
129 %!demo
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
130 %! function isofinish (p)
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
131 %! set (gca, "PlotBoxAspectRatioMode", "manual", ...
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
132 %! "PlotBoxAspectRatio", [1 1 1]);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
133 %! set (p, "FaceColor", "interp");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
134 %! set (p, "FaceLighting", "flat");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
135 %! light ("Position", [1 1 5]);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
136 %! endfunction
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
137 %!
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
138 %! N = 15; # Increase number of vertices in each direction
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
139 %! iso = .4; # Change isovalue to .1 to display a sphere
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
140 %! lin = linspace (0, 2, N);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
141 %! [x, y, z] = meshgrid (lin, lin, lin);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
142 %! c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2);
24188
1253132e2173 Use "clf;" at beginning of all plot demos.
Rik <rik@octave.org>
parents: 23220
diff changeset
143 %! clf;
22790
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
144 %!
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
145 %! subplot (2,2,1);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
146 %! view (-38, 20);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
147 %! [f, v] = isosurface (x, y, z, c, iso);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
148 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
149 %! cdat = rand (size (c)); # Compute random color data
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
150 %! isocolors (x, y, z, cdat, p); # Directly set colors of patch
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
151 %! title ("random colors for patch handle");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
152 %! isofinish (p);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
153 %!
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
154 %! subplot (2,2,2);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
155 %! view (-38, 20);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
156 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
157 %! [r, g, b] = meshgrid (lin, 2-lin, 2-lin);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
158 %! cdat = isocolors (x, y, z, c, v); # Compute color data vertices
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
159 %! set (p, "FaceVertexCData", cdat); # Set color data manually
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
160 %! title ('random colors for "FaceVertexCData"');
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
161 %! isofinish (p);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
162 %!
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
163 %! subplot (2,2,3);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
164 %! view (-38, 20);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
165 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
166 %! cdat = isocolors (r, g, b, c, p); # Compute color data for patch
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
167 %! set (p, "FaceVertexCData", cdat); # Set color data manually
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
168 %! title ('random RGB colors for "FaceVertexCData"');
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
169 %! isofinish (p);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
170 %!
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
171 %! subplot (2,2,4);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
172 %! view (-38, 20);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
173 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
174 %! r = g = b = repmat ([1:N] / N, [N, 1, N]); # Black to white
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
175 %! cdat = isocolors (x, y, z, r, g, b, v);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
176 %! set (p, "FaceVertexCData", cdat);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
177 %! title ('gray shades for "FaceVertexCData"');
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
178 %! isofinish (p);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
179
9110
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
180 %!test
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
181 %! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
182 %! c = (x-.5).^2 + (y-.5).^2 + (z-.5).^2;
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
183 %! [f, v] = isosurface (x, y, z, c, .4);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
184 %! cdat = isocolors (x, y, z, c, v);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
185 %! assert (rows (cdat) == rows (v));
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
186
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
187 ## Test input validation
28896
90fea9cc9caa test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents: 27978
diff changeset
188 %!error <Invalid call> isocolors ()
90fea9cc9caa test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents: 27978
diff changeset
189 %!error <Invalid call> isocolors (1)
90fea9cc9caa test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents: 27978
diff changeset
190 %!error <Invalid call> isocolors (1,2,3)
90fea9cc9caa test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents: 27978
diff changeset
191 %!error <Invalid call> isocolors (1,2,3,4,5,6)
90fea9cc9caa test: Add expected error message <Invalid call> to BIST tests for nargin.
Rik <rik@octave.org>
parents: 27978
diff changeset
192 %!error <Invalid call> isocolors (1,2,3,4,5,6,7,8)
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
193 %!error <last argument must be a vertex list> isocolors (1, {1})
22790
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
194 %!error <last argument must be a vertex list> isocolors (1, [1 2 3 4])
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
195 %!error <last argument must be a .*patch handle> isocolors (1, 0)