annotate scripts/plot/draw/isocolors.m @ 25054:6652d3823428 stable

maint: Update copyright dates in all source files.
author John W. Eaton <jwe@octave.org>
date Fri, 30 Mar 2018 09:19:05 -0400
parents 194eb4bd202b
children 00f796120a6d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25054
6652d3823428 maint: Update copyright dates in all source files.
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
1 ## Copyright (C) 2009-2018 Martin Helm
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
2 ##
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
3 ## 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
4 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24423
diff changeset
5 ## 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
6 ## 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
7 ## 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
8 ## (at your option) any later version.
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
9 ##
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
10 ## 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
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## 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
14 ##
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
15 ## 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
16 ## 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
17 ## <https://www.gnu.org/licenses/>.
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
18
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 ## -*- texinfo -*-
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
20 ## @deftypefn {} {@var{cdat} =} isocolors (@var{c}, @var{v})
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
21 ## @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
22 ## @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
23 ## @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
24 ## @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
25 ## @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
26 ##
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
27 ## Compute isosurface colors.
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
28 ##
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
29 ## 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
30 ## 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
31 ## 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
32 ## 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
33 ## 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
34 ## argument @var{cdat} can be used to manually set the
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
35 ## @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
36 ##
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
37 ## 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
38 ## 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
39 ## 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
40 ##
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
41 ## 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
42 ## 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
43 ## @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
44 ## 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
45 ##
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
46 ## 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
47 ## 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
48 ## 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
49 ## 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
50 ##
12529
0579a13f29a1 Add isocolors, isonormals, isosurface functions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
51 ## @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
52 ## @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
53
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
54 ## Author: Martin Helm <martin@mhelm.de>
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
55
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
56 function cdat = isocolors (varargin)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
57
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
58 calc_rgb = false;
11120
a44f979a35ce style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents: 11104
diff changeset
59 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
60 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
61 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
62 vp = 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
63 x = 1:size (c, 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
64 y = 1:size (c, 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
65 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
66 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
67 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
68 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
69 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
70 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
71 vp = 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
72 x = 1:size (R, 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
73 y = 1:size (R, 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
74 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
75 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
76 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
77 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
78 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
79 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
80 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
81 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
82 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
83 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
84 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
85 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
86 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
87 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
88 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
89 vp = varargin{7};
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
90 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
91 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
92 endswitch
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
93
19700
00e31f316a3a Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 19697
diff changeset
94 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
95 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
96 v = vp;
24423
1d52db450db4 Change ishandle to return true for Java objects for Matlab compatibility.
Rik <rik@octave.org>
parents: 24188
diff changeset
97 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
98 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
99 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
100 else
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
101 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
102 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
103
11120
a44f979a35ce style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents: 11104
diff changeset
104 if (calc_rgb)
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
105 new_colors = zeros (rows (v), 3);
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
106 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
107 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
108 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
109 else
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
110 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
111 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
112
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
113 if (nargout == 0)
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
114 if (! isempty (pa))
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
115 set (pa, "FaceVertexCData", new_colors);
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
116 endif
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
117 else
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
118 cdat = new_colors;
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
119 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
120
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
121 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
122
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
123
22790
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
124 %!demo
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
125 %! function isofinish (p)
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
126 %! set (gca, "PlotBoxAspectRatioMode", "manual", ...
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
127 %! "PlotBoxAspectRatio", [1 1 1]);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
128 %! set (p, "FaceColor", "interp");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
129 %! set (p, "FaceLighting", "flat");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
130 %! light ("Position", [1 1 5]);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
131 %! endfunction
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
132 %!
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
133 %! N = 15; # Increase number of vertices in each direction
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
134 %! iso = .4; # Change isovalue to .1 to display a sphere
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
135 %! lin = linspace (0, 2, N);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
136 %! [x, y, z] = meshgrid (lin, lin, lin);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
137 %! 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
138 %! clf;
22790
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
139 %!
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
140 %! subplot (2,2,1);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
141 %! view (-38, 20);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
142 %! [f, v] = isosurface (x, y, z, c, iso);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
143 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
144 %! cdat = rand (size (c)); # Compute random color data
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
145 %! isocolors (x, y, z, cdat, p); # Directly set colors of patch
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
146 %! title ("random colors for patch handle");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
147 %! isofinish (p);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
148 %!
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
149 %! subplot (2,2,2);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
150 %! view (-38, 20);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
151 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
152 %! [r, g, b] = meshgrid (lin, 2-lin, 2-lin);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
153 %! cdat = isocolors (x, y, z, c, v); # Compute color data vertices
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
154 %! set (p, "FaceVertexCData", cdat); # Set color data manually
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
155 %! title ('random colors for "FaceVertexCData"');
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
156 %! isofinish (p);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
157 %!
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
158 %! subplot (2,2,3);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
159 %! view (-38, 20);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
160 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
161 %! 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
162 %! set (p, "FaceVertexCData", cdat); # Set color data manually
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
163 %! title ('random RGB colors for "FaceVertexCData"');
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
164 %! isofinish (p);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
165 %!
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
166 %! subplot (2,2,4);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
167 %! view (-38, 20);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
168 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none");
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
169 %! 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
170 %! cdat = isocolors (x, y, z, r, g, b, v);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
171 %! set (p, "FaceVertexCData", cdat);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
172 %! title ('gray shades for "FaceVertexCData"');
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
173 %! isofinish (p);
f403ad463aa4 isonormals.m: Overhaul function
Rik <rik@octave.org>
parents: 22786
diff changeset
174
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
175 %!test
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
176 %! [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
177 %! 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
178 %! [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
179 %! 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
180 %! 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
181
22786
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
182 ## Test input validation
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
183 %!error isocolors ()
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
184 %!error isocolors (1)
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
185 %!error isocolors (1,2,3)
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
186 %!error isocolors (1,2,3,4,5,6)
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
187 %!error isocolors (1,2,3,4,5,6,7,8)
13f3ec0f7c01 isocolors.m: Overhaul function.
Rik <rik@octave.org>
parents: 22755
diff changeset
188 %!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
189 %!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
190 %!error <last argument must be a .*patch handle> isocolors (1, 0)