Mercurial > hg > octave-nkf
annotate scripts/plot/trisurf.m @ 12792:dc29b64668fa
codesprint : Move trimesh, triplot, trisurf from geometry to plot directory
* geometry/module.mk, plot/module.mk: Move trimesh, triplot, trisurf from geometry to plot directory.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 16 Jul 2011 09:16:52 -0700 |
parents | scripts/geometry/trisurf.m@482cf3aad915 |
children | e81ddf9cacd5 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2007-2011 David Bateman |
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 ## |
22ae6b3411a7
Add isocolor, 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 file is part of Octave. |
22ae6b3411a7
Add isocolor, 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 ## |
22ae6b3411a7
Add isocolor, 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 ## Octave is free software; you can redistribute it and/or modify it |
22ae6b3411a7
Add isocolor, 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 ## 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
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
22ae6b3411a7
Add isocolor, 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 ## 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
|
9 ## |
22ae6b3411a7
Add isocolor, 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 ## Octave is distributed in the hope that it will be useful, but |
22ae6b3411a7
Add isocolor, 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 ## 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
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
22ae6b3411a7
Add isocolor, 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 ## 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
|
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 |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
22ae6b3411a7
Add isocolor, 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 |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
20 ## @deftypefn {Function File} {} trisurf (@var{tri}, @var{x}, @var{y}, @var{z}) |
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
|
21 ## @deftypefnx {Function File} {@var{h} =} trisurf (@dots{}) |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
22 ## Plot a triangular surface in 3D@. The variable @var{tri} is the triangular |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
23 ## meshing of the points @code{(@var{x}, @var{y})} which is returned |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
24 ## from @code{delaunay}. The variable @var{z} is value at the point |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
25 ## @code{(@var{x}, @var{y})}. The output argument @var{h} is the graphic |
12187
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
26 ## handle of the plot. |
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
27 ## @seealso{triplot, trimesh, delaunay3} |
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
|
28 ## @end deftypefn |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
29 |
12524
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
30 function varargout = trisurf (tri, x, y, z, varargin) |
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
|
31 |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
32 if (nargin < 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
|
33 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
|
34 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
|
35 |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
36 if (nargin == 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
|
37 triplot (tri, x, y); |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
38 elseif (ischar (z)) |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
39 triplot (tri, x, y, z, 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
|
40 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
|
41 if (nargin > 4 && isnumeric (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
|
42 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
|
43 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
|
44 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
|
45 c = z; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
46 endif |
12524
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
47 if (! any (strcmpi (varargin, "FaceColor"))) |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
48 nfc = numel (varargin) + 1; |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
49 varargin(nfc+(0:1)) = {"FaceColor", "flat"}; |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
50 else |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
51 nfc = find (any (strcmpi (varargin, "FaceColor")), 1); |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
52 endif |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
53 if (! any (strcmpi (varargin, "EdgeColor")) |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
54 && strcmpi (varargin{nfc+1}, "interp")) |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
55 varargin(end+(1:2)) = {"EdgeColor", "none"}; |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
56 endif |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
57 newplot (); |
12524
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
58 h = patch ("Faces", tri, "Vertices", [x(:), y(:), z(:)], |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
59 "FaceVertexCData", reshape (c, numel (c), 1), |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
60 varargin{:}); |
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 if (nargout > 0) |
12524
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
62 varargout = {h}; |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
63 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
|
64 |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
65 if (! ishold ()) |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
66 set (gca(), "view", [-37.5, 30], |
10549 | 67 "xgrid", "on", "ygrid", "on", "zgrid", "on"); |
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
|
68 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
|
69 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
|
70 endfunction |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
71 |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
72 %!demo |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
73 %! N = 10; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
74 %! rand ('state', 10) |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
75 %! x = 3 - 6 * rand (N, N); |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
76 %! y = 3 - 6 * rand (N, N); |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
77 %! z = peaks (x, y); |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
78 %! tri = delaunay (x(:), y(:)); |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
79 %! trisurf (tri, x(:), y(:), z(:)); |
12524
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
80 |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
81 %!demo |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
82 %! x = rand (100, 1); |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
83 %! y = rand (100, 1); |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
84 %! z = x.^2 + y.^2; |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
85 %! tri = delaunay (x, y); |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
86 %! trisurf (tri, x, y, z) |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
87 |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
88 %!demo |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
89 %! x = rand (100, 1); |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
90 %! y = rand (100, 1); |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
91 %! z = x.^2 + y.^2; |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
92 %! tri = delaunay (x, y); |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
93 %! trisurf (tri, x, y, z, "facecolor", "interp") |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
94 |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
95 %!demo |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
96 %! x = rand (100, 1); |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
97 %! y = rand (100, 1); |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
98 %! z = x.^2 + y.^2; |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
99 %! tri = delaunay (x, y); |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
100 %! trisurf (tri, x, y, z, "facecolor", "interp", "edgecolor", "k") |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
101 |
482cf3aad915
trisurf.m: Set default edgecolor as Matlab does. Add demos.
Ben Abbott <bpabbott@mac.com>
parents:
12187
diff
changeset
|
102 |