Mercurial > hg > octave-thorsten
annotate scripts/plot/isonormals.m @ 14237:11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Add clf() to all demos using plot features to get reproducibility.
Use 64 as input to all colormaps (jet (64)) to get reproducibility.
* bicubic.m, cell2mat.m, celldisp.m, cplxpair.m, interp1.m, interp2.m,
interpft.m, interpn.m, profile.m, profshow.m, convhull.m, delaunay.m,
griddata.m, inpolygon.m, voronoi.m, autumn.m, bone.m, contrast.m, cool.m,
copper.m, flag.m, gmap40.m, gray.m, hot.m, hsv.m, image.m, imshow.m, jet.m,
ocean.m, pink.m, prism.m, rainbow.m, spring.m, summer.m, white.m, winter.m,
condest.m, onenormest.m, axis.m, clabel.m, colorbar.m, comet.m, comet3.m,
compass.m, contour.m, contour3.m, contourf.m, cylinder.m, daspect.m,
ellipsoid.m, errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m,
ezplot.m, ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fill.m,
fplot.m, grid.m, hold.m, isosurface.m, legend.m, loglog.m, loglogerr.m,
pareto.m, patch.m, pbaspect.m, pcolor.m, pie.m, pie3.m, plot3.m, plotmatrix.m,
plotyy.m, polar.m, quiver.m, quiver3.m, rectangle.m, refreshdata.m, ribbon.m,
rose.m, scatter.m, scatter3.m, semilogx.m, semilogxerr.m, semilogy.m,
semilogyerr.m, shading.m, slice.m, sombrero.m, stairs.m, stem.m, stem3.m,
subplot.m, surf.m, surfc.m, surfl.m, surfnorm.m, text.m, title.m, trimesh.m,
triplot.m, trisurf.m, uigetdir.m, uigetfile.m, uimenu.m, uiputfile.m,
waitbar.m, xlim.m, ylim.m, zlim.m, mkpp.m, pchip.m, polyaffine.m, spline.m,
bicgstab.m, cgs.m, gplot.m, pcg.m, pcr.m, treeplot.m, strtok.m, demo.m,
example.m, rundemos.m, speed.m, test.m, calendar.m, datestr.m, datetick.m,
weekday.m: Revamp %!demos to use Octave coding conventions on spacing, etc.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 20 Jan 2012 12:59:53 -0800 |
parents | 72c96de7a403 |
children | 4d917a6a858b |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13929
diff
changeset
|
1 ## Copyright (C) 2009-2012 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 | 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 | 5 ## Octave is free software; you can redistribute it and/or modify it |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
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 | 16 ## along with Octave; see the file COPYING. If not, see |
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 -*- |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{n}] =} isonormals (@var{val}, @var{v}) |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
21 ## @deftypefnx {Function File} {[@var{n}] =} isonormals (@var{val}, @var{p}) |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
22 ## @deftypefnx {Function File} {[@var{n}] =} isonormals (@var{x}, @var{y}, @var{z}, @var{val}, @var{v}) |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
23 ## @deftypefnx {Function File} {[@var{n}] =} isonormals (@var{x}, @var{y}, @var{z}, @var{val}, @var{p}) |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
24 ## @deftypefnx {Function File} {[@var{n}] =} isonormals (@dots{}, "negate") |
12578
f5a780d675a1
Clean up operator and function indices in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12529
diff
changeset
|
25 ## @deftypefnx {Function File} {} isonormals (@dots{}, @var{p}) |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
26 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
27 ## 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
|
28 ## @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
|
29 ## 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
|
30 ## 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
|
31 ## 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
|
32 ## @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
|
33 ## @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
|
34 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
35 ## 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
|
36 ## 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
|
37 ## 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
|
38 ## 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
|
39 ## function. |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
40 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
41 ## If given the string input argument "negate" as last input argument |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
42 ## 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
|
43 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
44 ## 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
|
45 ## given by the patch handle @var{p}. |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
46 ## |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
47 ## For example: |
13929
9cae456085c2
Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
12974
diff
changeset
|
48 ## @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
|
49 ## |
12974
6590446c2498
doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents:
12578
diff
changeset
|
50 ## @smallexample |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
51 ## function [] = isofinish (p) |
12974
6590446c2498
doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents:
12578
diff
changeset
|
52 ## set (gca, "PlotBoxAspectRatioMode", "manual", ... |
6590446c2498
doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents:
12578
diff
changeset
|
53 ## "PlotBoxAspectRatio",[1 1 1]); |
6590446c2498
doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents:
12578
diff
changeset
|
54 ## 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
|
55 ## set (p, "FaceColor", "interp"); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
56 ## ## set (p, "FaceLighting", "phong"); |
12974
6590446c2498
doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents:
12578
diff
changeset
|
57 ## ## 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
|
58 ## 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
|
59 ## |
12974
6590446c2498
doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents:
12578
diff
changeset
|
60 ## 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
|
61 ## 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
|
62 ## lin = linspace (0, 2, N); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
63 ## [x, y, z] = meshgrid (lin, lin, lin); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
64 ## 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
|
65 ## figure (); # Open another figure window |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
66 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
67 ## subplot (2, 2, 1); view (-38, 20); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
68 ## [f, v, cdat] = isosurface (x, y, z, c, iso, y); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
69 ## 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
|
70 ## "FaceColor", "interp", "EdgeColor", "none"); |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
71 ## isofinish (p); ## Call user function isofinish |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
72 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
73 ## subplot (2, 2, 2); view (-38, 20); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
74 ## 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
|
75 ## "FaceColor", "interp", "EdgeColor", "none"); |
6590446c2498
doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents:
12578
diff
changeset
|
76 ## 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
|
77 ## isofinish (p); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
78 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
79 ## subplot (2, 2, 3); view (-38, 20); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
80 ## 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
|
81 ## "FaceColor", "interp", "EdgeColor", "none"); |
6590446c2498
doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents:
12578
diff
changeset
|
82 ## 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
|
83 ## 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
|
84 ## isofinish (p); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
85 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
86 ## subplot (2, 2, 4); view (-38, 20); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
87 ## 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
|
88 ## "FaceColor", "interp", "EdgeColor", "none"); |
6590446c2498
doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents:
12578
diff
changeset
|
89 ## 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
|
90 ## isofinish (p); |
12974
6590446c2498
doc: Correct Texinfo overfull hbox instances.
Rik <octave@nomad.inbox5.com>
parents:
12578
diff
changeset
|
91 ## @end smallexample |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
92 ## |
12529
0579a13f29a1
Add isocolors, isonormals, isosurface functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
93 ## @seealso{isosurface, isocolors} |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
94 ## @end deftypefn |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
95 |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
96 ## 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
|
97 |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
98 function varargout = isonormals(varargin) |
22ae6b3411a7
Add isocolor, 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 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 else |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
106 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
|
107 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
|
108 endif |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 vp = varargin{5}; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
122 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
|
123 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
|
124 endswitch |
22ae6b3411a7
Add isocolor, 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 if (ismatrix (vp) && size (vp,2) == 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
|
126 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
|
127 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
|
128 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
|
129 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
|
130 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
|
131 else |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
132 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
|
133 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
|
134 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
|
135 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
|
136 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
|
137 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
|
138 endif |
11120
a44f979a35ce
style fixes for some .m files
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
139 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
|
140 case 0 |
22ae6b3411a7
Add isocolor, 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 if (!isempty (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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 endswitch |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
149 endfunction |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
150 |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
151 %!test |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
152 %! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
153 %! c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
154 %! [f, v, cdat] = isosurface (x, y, z, c, .4, y); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
155 %! n = isonormals (x, y, z, c, v); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
156 %! assert (size (v), size (n)); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
157 %!test |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
158 %! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
159 %! c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
160 %! [f, v, cdat] = isosurface (x, y, z, c, .4, y); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
161 %! np = isonormals (x, y, z, c, v); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
162 %! nn = isonormals (x, y, z, c, v, "negate"); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
163 %! assert (all (np == -nn)); |