annotate scripts/plot/draw/isonormals.m @ 22142:62208397b99e

Add function "smooth3" (patch #8864). * scripts/plot/draw/smooth3.m: New function. * scripts/plot/draw/module.mk: Add to build system. * __unimplemented__.m: Remove "smooth3" from list. * plot.txi: Add to documentation. * isosurface.m: Add "smooth3" to @seealso list.
author Markus Muetzel <markus.muetzel@gmx.de>
date Mon, 18 Jul 2016 19:38:27 +0200
parents ffad2baa90f7
children ba8a9d2934c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
1 ## Copyright (C) 2009-2015 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 ##
11104
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
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
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
8 ## your option) any later version.
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
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
13 ## 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
2c356a35d7f5 fix copyright notices
John W. Eaton <jwe@octave.org>
parents: 10846
diff changeset
17 ## <http://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
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
20 ## @deftypefn {} {[@var{n}] =} isonormals (@var{val}, @var{v})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
21 ## @deftypefnx {} {[@var{n}] =} isonormals (@var{val}, @var{p})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
22 ## @deftypefnx {} {[@var{n}] =} isonormals (@var{x}, @var{y}, @var{z}, @var{val}, @var{v})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
23 ## @deftypefnx {} {[@var{n}] =} isonormals (@var{x}, @var{y}, @var{z}, @var{val}, @var{p})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
24 ## @deftypefnx {} {[@var{n}] =} isonormals (@dots{}, "negate")
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20173
diff changeset
25 ## @deftypefnx {} {} isonormals (@dots{}, @var{p})
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
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 ## Calculate normals to an isosurface.
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19833
diff changeset
28 ##
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
29 ## If called with one output argument and the first input argument
12529
0579a13f29a1 Add isocolors, isonormals, isosurface functions to documentation.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
30 ## @var{val} is a three-dimensional array that contains the data for an
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
31 ## isosurface geometry and the second input argument @var{v} keeps the
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
32 ## vertices of an isosurface then return the normals @var{n} in form of
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
33 ## a matrix with the same size than @var{v} at computed points
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
34 ## @command{[x, y, z] = meshgrid (1:l, 1:m, 1:n)}. The output argument
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
35 ## @var{n} can be taken to manually set @var{VertexNormals} of a patch.
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
36 ##
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
37 ## If called with further input arguments @var{x}, @var{y} and @var{z}
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
38 ## which are three--dimensional arrays with the same size than @var{val}
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
39 ## then the volume data is taken at those given points. Instead of the
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
40 ## vertices data @var{v} a patch handle @var{p} can be passed to this
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
41 ## function.
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
42 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 14872
diff changeset
43 ## If given the string input argument @qcode{"negate"} as last input argument
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
44 ## then compute the reverse vector normals of an isosurface geometry.
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
45 ##
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
46 ## If no output argument is given then directly redraw the patch that is
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
47 ## given by the patch handle @var{p}.
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
48 ##
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10635
diff changeset
49 ## For example:
13929
9cae456085c2 Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents: 12974
diff changeset
50 ## @c Set example in small font to prevent overfull line
10846
a4f482e66b65 Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents: 10821
diff changeset
51 ##
12974
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
52 ## @smallexample
20927
1da6c81e6486 style fix for function declarations
John W. Eaton <jwe@octave.org>
parents: 20852
diff changeset
53 ## function isofinish (p)
12974
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
54 ## set (gca, "PlotBoxAspectRatioMode", "manual", ...
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
55 ## "PlotBoxAspectRatio", [1 1 1]);
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
56 ## set (p, "VertexNormals", -get (p,"VertexNormals")); # Revert normals
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
57 ## set (p, "FaceColor", "interp");
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
58 ## ## set (p, "FaceLighting", "phong");
12974
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
59 ## ## light ("Position", [1 1 5]); # Available with JHandles
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
60 ## endfunction
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
61 ##
12974
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
62 ## N = 15; # Increase number of vertices in each direction
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
63 ## iso = .4; # Change isovalue to .1 to display a sphere
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
64 ## lin = linspace (0, 2, N);
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
65 ## [x, y, z] = meshgrid (lin, lin, lin);
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
66 ## c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2);
12974
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
67 ## figure (); # Open another figure window
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
68 ##
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
69 ## subplot (2,2,1); view (-38, 20);
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
70 ## [f, v, cdat] = isosurface (x, y, z, c, iso, y);
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
71 ## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ...
12974
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
72 ## "FaceColor", "interp", "EdgeColor", "none");
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19700
diff changeset
73 ## isofinish (p); # Call user function isofinish
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
74 ##
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
75 ## subplot (2,2,2); view (-38, 20);
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
76 ## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ...
12974
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
77 ## "FaceColor", "interp", "EdgeColor", "none");
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
78 ## isonormals (x, y, z, c, p); # Directly modify patch
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
79 ## isofinish (p);
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
80 ##
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
81 ## subplot (2,2,3); view (-38, 20);
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
82 ## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ...
12974
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
83 ## "FaceColor", "interp", "EdgeColor", "none");
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
84 ## n = isonormals (x, y, z, c, v); # Compute normals of isosurface
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
85 ## set (p, "VertexNormals", n); # Manually set vertex normals
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
86 ## isofinish (p);
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
87 ##
14327
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
88 ## subplot (2,2,4); view (-38, 20);
4d917a6a858b doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
89 ## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ...
12974
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
90 ## "FaceColor", "interp", "EdgeColor", "none");
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
91 ## isonormals (x, y, z, c, v, "negate"); # Use reverse directly
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
92 ## isofinish (p);
12974
6590446c2498 doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents: 12578
diff changeset
93 ## @end smallexample
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
94 ##
22142
62208397b99e Add function "smooth3" (patch #8864).
Markus Muetzel <markus.muetzel@gmx.de>
parents: 21758
diff changeset
95 ## @seealso{isosurface, isocolors, smooth3}
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
96 ## @end deftypefn
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
97
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
98 ## Author: Martin Helm <martin@mhelm.de>
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
99
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
100 function varargout = isonormals (varargin)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
101
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 na = nargin;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
103 negate = false;
22ae6b3411a7 Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff changeset
104 if (ischar (varargin{nargin}))
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 na = nargin-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
106 if (strcmp (lower (varargin{nargin}), "negate"))
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 negate = 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
108 else
10635
d1978e7364ad Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
109 error ("isonormals: Unknown option '%s'", varargin{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
110 endif
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
11120
a44f979a35ce style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents: 11104
diff changeset
113 switch (na)
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 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
115 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
116 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
117 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
118 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
119 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
120 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
121 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
122 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
123 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
124 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
125 vp = varargin{5};
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
126 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
127 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
128 endswitch
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
129
19700
00e31f316a3a Fix Matlab incompatibility of "ismatrix" (bug #42422).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 19697
diff changeset
130 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
131 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
132 v = 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
133 elseif (ishandle (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
134 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
135 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
136 else
10635
d1978e7364ad Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
137 error ("isonormals: Last argument is not a vertex list or a 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
138 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
139
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
140 if (negate)
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
141 normals = -__interp_cube__ (x, y, z, c, v, "normals");
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
142 else
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
143 normals = __interp_cube__ (x, y, z, c, v, "normals");
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
144 endif
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
145
11120
a44f979a35ce style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents: 11104
diff changeset
146 switch (nargout)
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
147 case 0
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19700
diff changeset
148 if (! isempty (pa))
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
149 set (pa, "VertexNormals", normals);
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
150 endif
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
151 case 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
152 varargout = {normals};
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
153 otherwise
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
154 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
155 endswitch
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20927
diff changeset
156
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
157 endfunction
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
158
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
159
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
160 %!test
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
161 %! [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
162 %! c = abs ((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
163 %! [f, v, cdat] = isosurface (x, y, z, c, .4, y);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
164 %! n = isonormals (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
165 %! assert (size (v), size (n));
9119
3b810beddfa6 Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents: 9110
diff changeset
166 %!test
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
167 %! [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
168 %! c = abs ((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
169 %! [f, v, cdat] = isosurface (x, y, z, c, .4, y);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
170 %! np = isonormals (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
171 %! nn = isonormals (x, y, z, c, v, "negate");
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
172 %! assert (np, -nn);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14327
diff changeset
173