Mercurial > hg > octave-lyh
comparison scripts/plot/triplot.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/triplot.m@87926ee23581 |
children | e8564e8b0043 |
comparison
equal
deleted
inserted
replaced
12791:610a4e780a19 | 12792:dc29b64668fa |
---|---|
1 ## Copyright (C) 2007-2011 David Bateman | |
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 | |
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. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} triplot (@var{tri}, @var{x}, @var{y}) | |
21 ## @deftypefnx {Function File} {} triplot (@var{tri}, @var{x}, @var{y}, @var{linespec}) | |
22 ## @deftypefnx {Function File} {@var{h} =} triplot (@dots{}) | |
23 ## Plot a triangular mesh in 2D@. The variable @var{tri} is the triangular | |
24 ## meshing of the points @code{(@var{x}, @var{y})} which is returned from | |
25 ## @code{delaunay}. If given, the @var{linespec} determines the properties | |
26 ## to use for the lines. The output argument @var{h} is the graphic handle | |
27 ## of the plot. | |
28 ## @seealso{plot, trimesh, trisurf, delaunay} | |
29 ## @end deftypefn | |
30 | |
31 function h = triplot (tri, x, y, varargin) | |
32 | |
33 if (nargin < 3) | |
34 print_usage (); | |
35 endif | |
36 | |
37 idx = tri(:, [1, 2, 3, 1]).'; | |
38 nt = size (tri, 1); | |
39 if (nargout > 0) | |
40 h = plot ([x(idx); NaN(1, nt)](:), | |
41 [y(idx); NaN(1, nt)](:), varargin{:}); | |
42 else | |
43 plot ([x(idx); NaN(1, nt)](:), | |
44 [y(idx); NaN(1, nt)](:), varargin{:}); | |
45 endif | |
46 endfunction | |
47 | |
48 %!demo | |
49 %! rand ('state', 2) | |
50 %! x = rand (20, 1); | |
51 %! y = rand (20, 1); | |
52 %! tri = delaunay (x, y); | |
53 %! triplot (tri, x, y); |