Mercurial > hg > octave-lyh
annotate scripts/plot/isonormals.m @ 9119:3b810beddfa6
Added help texts and tests.
author | Thomas Treichl <Thomas.Treichl@gmx.net> |
---|---|
date | Tue, 14 Apr 2009 22:02:05 +0200 |
parents | 22ae6b3411a7 |
children | 2884758e265b |
rev | line source |
---|---|
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
|
1 ## Copyright (C) 2009 Martin Helm |
22ae6b3411a7
Add isocolor, 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 ## |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
3 ## This program is free software; you can redistribute it and/or modify |
22ae6b3411a7
Add isocolor, 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 ## it under the terms of the GNU General Public License as published by |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
5 ## the Free Software Foundation; either version 3 of the License, or |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
6 ## (at your option) any later version. |
22ae6b3411a7
Add isocolor, 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 ## |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
8 ## This program is distributed in the hope that it will be useful, |
22ae6b3411a7
Add isocolor, 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 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
11 ## GNU General Public License for more details. |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
12 ## |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
13 ## You should have received a copy of the GNU General Public License |
22ae6b3411a7
Add isocolor, 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 ## along with this program; if not, see http://www.gnu.org/licenses/gpl.html. |
22ae6b3411a7
Add isocolor, 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 |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
16 ## -*- texinfo -*- |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
17 ## @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
|
18 ## @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
|
19 ## @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
|
20 ## @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
|
21 ## @deftypefnx {Function File} {[@var{n}] =} isonormals (@dots{}, "negate") |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
22 ## @deftypefnx {Function File} isonormals (@dots{}, @var{p}) |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
23 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
24 ## If called with one output argument and the first input argument |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
25 ## @var{val} is a three--dimensional array that contains the data for an |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
26 ## 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
|
27 ## 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
|
28 ## 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
|
29 ## @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
|
30 ## @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
|
31 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
32 ## 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
|
33 ## 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
|
34 ## 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
|
35 ## 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
|
36 ## function. |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
37 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
38 ## 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
|
39 ## 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
|
40 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
41 ## 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
|
42 ## given by the patch handle @var{p}. |
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 ## For example, |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
45 ## @example |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
46 ## function [] = isofinish (p) |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
47 ## set (gca, "DataAspectRatioMode","manual","DataAspectRatio",[1 1 1]); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
48 ## set (p, "VertexNormals", -get(p,"VertexNormals")); ## Revert normals |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
49 ## set (p, "FaceColor", "interp"); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
50 ## ## set (p, "FaceLighting", "phong"); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
51 ## ## light ("Position", [1 1 5]); ## Available with JHandles |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
52 ## 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
|
53 ## |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
54 ## N = 15; ## Increase number of vertices in each direction |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
55 ## iso = .4; ## Change isovalue to .1 to display a sphere |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
56 ## lin = linspace (0, 2, N); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
57 ## [x, y, z] = meshgrid (lin, lin, lin); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
58 ## c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
59 ## figure (); ## Open another figure window |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
60 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
61 ## subplot (2, 2, 1); view (-38, 20); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
62 ## [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
|
63 ## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, \ |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
64 ## "FaceColor", "interp", "EdgeColor", "none"); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
65 ## isofinish (p); ## Call user function isofinish |
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, 2); view (-38, 20); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
68 ## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, \ |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
69 ## "FaceColor", "interp", "EdgeColor", "none"); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
70 ## isonormals (x, y, z, c, p); ## Directly modify patch |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
71 ## isofinish (p); |
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, 3); 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, \ |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
75 ## "FaceColor", "interp", "EdgeColor", "none"); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
76 ## n = isonormals (x, y, z, c, v); ## Compute normals of isosurface |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
77 ## set (p, "VertexNormals", n); ## Manually set vertex normals |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
78 ## isofinish (p); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
79 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
80 ## subplot (2, 2, 4); view (-38, 20); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
81 ## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, \ |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
82 ## "FaceColor", "interp", "EdgeColor", "none"); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
83 ## isonormals (x, y, z, c, v, "negate"); ## Use reverse directly |
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 ## @end example |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
86 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
87 ## @seealso {isosurface, isocolors, isocaps, marching_cube} |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
88 ## |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
89 ## @end deftypefn |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
90 |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
91 ## 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
|
92 |
22ae6b3411a7
Add isocolor, 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 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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 error ("Unknown option '%s'", 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 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
|
103 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
|
104 switch na |
22ae6b3411a7
Add isocolor, 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 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 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
|
126 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
|
127 error ("Last argument is no vertex list and no patch handle"); |
22ae6b3411a7
Add isocolor, 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 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
|
129 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
|
130 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
|
131 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
|
132 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
|
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 switch nargout |
22ae6b3411a7
Add isocolor, 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 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 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
|
141 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
|
142 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
|
143 endswitch |
9119
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
144 endfunction |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
145 |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
146 %!test |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
147 %! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
148 %! c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
149 %! [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
|
150 %! n = isonormals (x, y, z, c, v); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
151 %! assert (size (v), size (n)); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
152 %!test |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
153 %! [x, y, z] = meshgrid (0:.5:2, 0:.5:2, 0:.5:2); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
154 %! c = abs ((x-.5).^2 + (y-.5).^2 + (z-.5).^2); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
155 %! [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
|
156 %! np = isonormals (x, y, z, c, v); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
157 %! nn = isonormals (x, y, z, c, v, "negate"); |
3b810beddfa6
Added help texts and tests.
Thomas Treichl <Thomas.Treichl@gmx.net>
parents:
9110
diff
changeset
|
158 %! assert (all (np == -nn)); |