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
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 ##
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
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})
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
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 ##
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
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
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
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)
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
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)
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
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)