Mercurial > octave
annotate scripts/plot/draw/isocolors.m @ 30875:5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
For new users of Octave it is best to show explicit calling forms
in the documentation and to show a return argument when it exists.
* bp-table.cc, shift.m, accumarray.m, accumdim.m, bincoeff.m, bitcmp.m,
bitget.m, bitset.m, blkdiag.m, celldisp.m, cplxpair.m, dblquad.m, flip.m,
fliplr.m, flipud.m, idivide.m, int2str.m, interpft.m, logspace.m, num2str.m,
polyarea.m, postpad.m, prepad.m, randi.m, repmat.m, rng.m, rot90.m, rotdim.m,
structfun.m, triplequad.m, uibuttongroup.m, uicontrol.m, uipanel.m,
uipushtool.m, uitoggletool.m, uitoolbar.m, waitforbuttonpress.m, help.m,
__additional_help_message__.m, hsv.m, im2double.m, im2frame.m, javachk.m,
usejava.m, argnames.m, char.m, formula.m, inline.m, __vectorize__.m, findstr.m,
flipdim.m, strmatch.m, vectorize.m, commutation_matrix.m, cond.m, cross.m,
duplication_matrix.m, expm.m, orth.m, rank.m, rref.m, trace.m, vech.m, cast.m,
compare_versions.m, delete.m, dir.m, fileattrib.m, grabcode.m, gunzip.m,
inputname.m, license.m, list_primes.m, ls.m, mexext.m, movefile.m,
namelengthmax.m, nargoutchk.m, nthargout.m, substruct.m, swapbytes.m, ver.m,
verLessThan.m, what.m, fminunc.m, fsolve.m, fzero.m, optimget.m, __fdjac__.m,
matlabroot.m, savepath.m, campos.m, camroll.m, camtarget.m, camup.m, camva.m,
camzoom.m, clabel.m, diffuse.m, legend.m, orient.m, rticks.m, specular.m,
thetaticks.m, xlim.m, xtickangle.m, xticklabels.m, xticks.m, ylim.m,
ytickangle.m, yticklabels.m, yticks.m, zlim.m, ztickangle.m, zticklabels.m,
zticks.m, ellipsoid.m, isocolors.m, isonormals.m, stairs.m, surfnorm.m,
__actual_axis_position__.m, __pltopt__.m, close.m, graphics_toolkit.m, pan.m,
print.m, printd.m, __ghostscript__.m, __gnuplot_print__.m, __opengl_print__.m,
rotate3d.m, subplot.m, zoom.m, compan.m, conv.m, poly.m, polyaffine.m,
polyder.m, polyint.m, polyout.m, polyreduce.m, polyvalm.m, roots.m, prefdir.m,
prefsfile.m, profexplore.m, profexport.m, profshow.m, powerset.m, unique.m,
arch_rnd.m, arma_rnd.m, autoreg_matrix.m, bartlett.m, blackman.m, detrend.m,
durbinlevinson.m, fftconv.m, fftfilt.m, fftshift.m, fractdiff.m, hamming.m,
hanning.m, hurst.m, ifftshift.m, rectangle_lw.m, rectangle_sw.m, triangle_lw.m,
sinc.m, sinetone.m, sinewave.m, spectral_adf.m, spectral_xdf.m, spencer.m,
ilu.m, __sprand__.m, sprand.m, sprandn.m, sprandsym.m, treelayout.m, beta.m,
betainc.m, betaincinv.m, betaln.m, cosint.m, expint.m, factorial.m, gammainc.m,
gammaincinv.m, lcm.m, nthroot.m, perms.m, reallog.m, realpow.m, realsqrt.m,
sinint.m, hadamard.m, hankel.m, hilb.m, invhilb.m, magic.m, pascal.m, rosser.m,
toeplitz.m, vander.m, wilkinson.m, center.m, corr.m, cov.m, discrete_cdf.m,
discrete_inv.m, discrete_pdf.m, discrete_rnd.m, empirical_cdf.m,
empirical_inv.m, empirical_pdf.m, empirical_rnd.m, kendall.m, kurtosis.m,
mad.m, mean.m, meansq.m, median.m, mode.m, moment.m, range.m, ranks.m,
run_count.m, skewness.m, spearman.m, statistics.m, std.m, base2dec.m,
bin2dec.m, blanks.m, cstrcat.m, deblank.m, dec2base.m, dec2bin.m, dec2hex.m,
hex2dec.m, index.m, regexptranslate.m, rindex.m, strcat.m, strjust.m,
strtrim.m, strtrunc.m, substr.m, untabify.m, __have_feature__.m,
__prog_output_assert__.m, __run_test_suite__.m, example.m, fail.m, asctime.m,
calendar.m, ctime.m, date.m, etime.m:
Add return arguments to @deftypefn macros where they were missing. Rename
variables in functions (particularly generic "retval") to match documentation.
Rename some return variables for (hopefully) better clarity (e.g., 'ax' to 'hax'
to indicate it is a graphics handle to an axes object).
author | Rik <rik@octave.org> |
---|---|
date | Wed, 30 Mar 2022 20:40:27 -0700 |
parents | 796f54d4ddbf |
children | 597f3ee61a48 |
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 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30236
diff
changeset
|
3 ## Copyright (C) 2009-2022 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 | 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 | 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 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
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 | 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 | 27 ## @deftypefn {} {@var{cdat} =} isocolors (@var{c}, @var{v}) |
28 ## @deftypefnx {} {@var{cdat} =} isocolors (@var{x}, @var{y}, @var{z}, @var{c}, @var{v}) | |
29 ## @deftypefnx {} {@var{cdat} =} isocolors (@var{x}, @var{y}, @var{z}, @var{r}, @var{g}, @var{b}, @var{v}) | |
30 ## @deftypefnx {} {@var{cdat} =} isocolors (@var{r}, @var{g}, @var{b}, @var{v}) | |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
31 ## @deftypefnx {} {@var{cdat} =} isocolors (@dots{}, @var{hp}) |
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
32 ## @deftypefnx {} {} isocolors (@dots{}, @var{hp}) |
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 | 36 ## If called with one output argument, and the first input argument @var{c} |
37 ## is a three-dimensional array that contains indexed color values, and the | |
38 ## second input argument @var{v} are the vertices of an isosurface geometry, | |
39 ## then return a matrix @var{cdat} with color data information for the geometry | |
40 ## at computed points @code{[x, y, z] = meshgrid (1:l, 1:m, 1:n)}. The output | |
41 ## argument @var{cdat} can be used to manually set the | |
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 | 44 ## If called with additional input arguments @var{x}, @var{y} and @var{z} which |
45 ## are three-dimensional arrays of the same size as @var{c} then the | |
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 | 48 ## Instead of indexed color data @var{c}, @code{isocolors} can also be called |
49 ## with RGB values @var{r}, @var{g}, @var{b}. If input arguments @var{x}, | |
50 ## @var{y}, @var{z} are not given then @code{meshgrid} computed values are | |
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 ## |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
53 ## Optionally, a patch handle @var{hp} can be given as the last input argument |
22786 | 54 ## to all function call variations and the vertex data will be extracted |
55 ## from the isosurface patch object. Finally, if no output argument is given | |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
56 ## then the colors of the patch given by the patch handle @var{hp} 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 | 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) |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
100 hp = []; |
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
|
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")) |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
103 hp = vp; |
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
104 v = get (hp, "Vertices"); |
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
|
105 else |
22786 | 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 | 110 new_colors = zeros (rows (v), 3); |
111 new_colors(:,1) = __interp_cube__ ("isocolors", x, y, z, R, v, "values"); | |
112 new_colors(:,2) = __interp_cube__ ("isocolors", x, y, z, G, v, "values"); | |
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 | 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 | 118 if (nargout == 0) |
30875
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
119 if (! isempty (hp)) |
5d3faba0342e
doc: Ensure documentation lists output argument when it exists for all m-files.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
120 set (hp, "FaceVertexCData", new_colors); |
22786 | 121 endif |
122 else | |
123 cdat = new_colors; | |
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 | 129 %!demo |
130 %! function isofinish (p) | |
131 %! set (gca, "PlotBoxAspectRatioMode", "manual", ... | |
132 %! "PlotBoxAspectRatio", [1 1 1]); | |
133 %! set (p, "FaceColor", "interp"); | |
134 %! set (p, "FaceLighting", "flat"); | |
135 %! light ("Position", [1 1 5]); | |
136 %! endfunction | |
137 %! | |
138 %! N = 15; # Increase number of vertices in each direction | |
139 %! iso = .4; # Change isovalue to .1 to display a sphere | |
140 %! lin = linspace (0, 2, N); | |
141 %! [x, y, z] = meshgrid (lin, lin, lin); | |
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 | 144 %! |
145 %! subplot (2,2,1); | |
146 %! view (-38, 20); | |
147 %! [f, v] = isosurface (x, y, z, c, iso); | |
148 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none"); | |
149 %! cdat = rand (size (c)); # Compute random color data | |
150 %! isocolors (x, y, z, cdat, p); # Directly set colors of patch | |
151 %! title ("random colors for patch handle"); | |
152 %! isofinish (p); | |
153 %! | |
154 %! subplot (2,2,2); | |
155 %! view (-38, 20); | |
156 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none"); | |
157 %! [r, g, b] = meshgrid (lin, 2-lin, 2-lin); | |
158 %! cdat = isocolors (x, y, z, c, v); # Compute color data vertices | |
159 %! set (p, "FaceVertexCData", cdat); # Set color data manually | |
160 %! title ('random colors for "FaceVertexCData"'); | |
161 %! isofinish (p); | |
162 %! | |
163 %! subplot (2,2,3); | |
164 %! view (-38, 20); | |
165 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none"); | |
166 %! cdat = isocolors (r, g, b, c, p); # Compute color data for patch | |
167 %! set (p, "FaceVertexCData", cdat); # Set color data manually | |
168 %! title ('random RGB colors for "FaceVertexCData"'); | |
169 %! isofinish (p); | |
170 %! | |
171 %! subplot (2,2,4); | |
172 %! view (-38, 20); | |
173 %! p = patch ("Faces", f, "Vertices", v, "EdgeColor", "none"); | |
174 %! r = g = b = repmat ([1:N] / N, [N, 1, N]); # Black to white | |
175 %! cdat = isocolors (x, y, z, r, g, b, v); | |
176 %! set (p, "FaceVertexCData", cdat); | |
177 %! title ('gray shades for "FaceVertexCData"'); | |
178 %! isofinish (p); | |
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 | 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 | 193 %!error <last argument must be a vertex list> isocolors (1, {1}) |
22790 | 194 %!error <last argument must be a vertex list> isocolors (1, [1 2 3 4]) |
22786 | 195 %!error <last argument must be a .*patch handle> isocolors (1, 0) |