Mercurial > hg > octave-lyh
annotate scripts/plot/trimesh.m @ 14459:a22a41ab6824
doc: Add Colin Macdonald and Mike Miller to contributors.in
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Tue, 13 Mar 2012 01:30:26 -0400 |
parents | 4506eade9f04 |
children | 460a3c6d8bf1 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14092
diff
changeset
|
1 ## Copyright (C) 2007-2012 David Bateman |
6823 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6823 | 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. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6823 | 18 |
19 ## -*- texinfo -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
20 ## @deftypefn {Function File} {} trimesh (@var{tri}, @var{x}, @var{y}, @var{z}) |
7650 | 21 ## @deftypefnx {Function File} {@var{h} =} trimesh (@dots{}) |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
22 ## Plot a triangular mesh 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 |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13747
diff
changeset
|
25 ## @code{(@var{x}, @var{y})}. |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13747
diff
changeset
|
26 ## |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13747
diff
changeset
|
27 ## The optional return value @var{h} is a graphics handle to the created plot. |
12187
87926ee23581
Add undocumented function trisurf to manual.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
28 ## @seealso{triplot, trisurf, delaunay3} |
6823 | 29 ## @end deftypefn |
30 | |
31 function h = trimesh (tri, x, y, z, varargin) | |
32 | |
33 if (nargin < 3) | |
6826 | 34 print_usage (); |
6823 | 35 endif |
36 | |
37 if (nargin == 3) | |
38 triplot (tri, x, y); | |
39 elseif (ischar (z)) | |
40 triplot (tri, x, y, z, varargin{:}); | |
41 else | |
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:
9051
diff
changeset
|
42 newplot (); |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
43 handle = patch ("Vertices", [x(:), y(:), z(:)], "Faces", tri, |
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
44 "FaceColor", "none", "EdgeColor", __next_line_color__(), |
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
45 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:
9051
diff
changeset
|
46 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:
9051
diff
changeset
|
47 set (gca(), "view", [-37.5, 30], |
10549 | 48 "xgrid", "on", "ygrid", "on", "zgrid", "on"); |
6823 | 49 endif |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
50 if (nargout > 0) |
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
51 h = handle; |
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
52 endif |
6823 | 53 endif |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
54 |
6823 | 55 endfunction |
56 | |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
57 |
6823 | 58 %!demo |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
59 %! clf; |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
60 %! old_state = rand ('state'); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
61 %! restore_state = onCleanup (@() rand ('state', old_state)); |
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
62 %! rand ('state', 10); |
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:
9051
diff
changeset
|
63 %! 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:
9051
diff
changeset
|
64 %! 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:
9051
diff
changeset
|
65 %! y = 3 - 6 * rand (N, N); |
6823 | 66 %! z = peaks (x, y); |
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:
9051
diff
changeset
|
67 %! 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:
9051
diff
changeset
|
68 %! trimesh (tri, x(:), y(:), z(:)); |
13747
e8564e8b0043
Restore random number state after %!demos or %!tests
Rik <octave@nomad.inbox5.com>
parents:
12792
diff
changeset
|
69 |