7017
|
1 ## Copyright (C) 2007 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 -*- |
|
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 ## to the plot. |
|
28 ## @seealso{plot, trimesh, delaunay} |
|
29 ## @end deftypefn |
|
30 |
|
31 function h = triplot (tri, x, y, varargin) |
|
32 |
|
33 if (nargin < 3) |
6826
|
34 print_usage (); |
6823
|
35 endif |
|
36 |
6826
|
37 idx = tri(:, [1, 2, 3, 1]).'; |
|
38 nt = size (tri, 1); |
6823
|
39 if (nargout > 0) |
6826
|
40 h = plot ([x(idx); NaN*ones(1, nt)](:), |
|
41 [y(idx); NaN*ones(1, nt)](:), varargin{:}); |
6823
|
42 else |
6826
|
43 plot ([x(idx); NaN*ones(1, nt)](:), |
|
44 [y(idx); NaN*ones(1, nt)](:), varargin{:}); |
6823
|
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); |