Mercurial > hg > octave-nkf
comparison scripts/geometry/triplot.m @ 6823:9fddcc586065
[project @ 2007-08-24 08:27:27 by dbateman]
author | dbateman |
---|---|
date | Fri, 24 Aug 2007 08:27:29 +0000 |
parents | |
children | 8618f29520c6 |
comparison
equal
deleted
inserted
replaced
6822:5c4702203cc4 | 6823:9fddcc586065 |
---|---|
1 ## Copyright (C) 2007 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 2, or (at your option) | |
8 ## 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, write to the Free | |
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
18 ## 02110-1301, USA. | |
19 | |
20 ## -*- texinfo -*- | |
21 ## @deftypefn {Function File} {} triplot (@var{tri}, @var{x}, @var{y}) | |
22 ## @deftypefnx {Function File} {} triplot (@var{tri}, @var{x}, @var{y}, @var{linespec}) | |
23 ## @deftypefnx {Function File} {@var{h} = } triplot (@dots{}) | |
24 ## Plot a triangular mesh in 2D. The variable @var{tri} is the triangular | |
25 ## meshing of the points @code{(@var{x}, @var{y})} which is returned from | |
26 ## @code{delaunay}. If given, the @var{linespec} determines the properties | |
27 ## to use for the lines. The output argument @var{h} is the graphic handle | |
28 ## to the plot. | |
29 ## @seealso{plot, trimesh, delaunay} | |
30 ## @end deftypefn | |
31 | |
32 function h = triplot (tri, x, y, varargin) | |
33 | |
34 if (nargin < 3) | |
35 print_usage(); | |
36 endif | |
37 | |
38 idx = tri (:, [1, 2, 3, 1]).'; | |
39 nt = size(tri, 1); | |
40 if (nargout > 0) | |
41 h = plot([x(idx); NaN*ones(1, nt)](:), ... | |
42 [y(idx); NaN*ones(1, nt)](:), varargin{:}); | |
43 else | |
44 plot([x(idx); NaN*ones(1, nt)](:), ... | |
45 [y(idx); NaN*ones(1, nt)](:), varargin{:}); | |
46 endif | |
47 endfunction | |
48 | |
49 %!demo | |
50 %! rand ('state', 2) | |
51 %! x = rand (20, 1); | |
52 %! y = rand (20, 1); | |
53 %! tri = delaunay (x, y); | |
54 %! triplot (tri, x, y); |