Mercurial > hg > octave-nkf
annotate scripts/plot/patch.m @ 12118:973f585cfdf2 release-3-2-x
include PTHREAD_CFLAGS in LINK_DEPS for liboctave
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 22 Jan 2010 10:21:33 +0100 |
parents | 22ae6b3411a7 |
children | be55736a0783 |
rev | line source |
---|---|
8920 | 1 ## Copyright (C) 2005, 2007, 2008, 2009 John W. Eaton |
6807 | 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. | |
6807 | 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/>. | |
6807 | 18 |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {} patch () | |
21 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c}) | |
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:
8920
diff
changeset
|
22 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{z}, @var{c}) |
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:
8920
diff
changeset
|
23 ## @deftypefnx {Function File} {} patch (@var{fv}) |
7020 | 24 ## @deftypefnx {Function File} {} patch ('Faces', @var{f}, 'Vertices', @var{v}, @dots{}) |
25 ## @deftypefnx {Function File} {} patch (@dots{}, @var{prop}, @var{val}) | |
6988 | 26 ## @deftypefnx {Function File} {} patch (@var{h}, @dots{}) |
7650 | 27 ## @deftypefnx {Function File} {@var{h} =} patch (@dots{}) |
6895 | 28 ## Create patch object from @var{x} and @var{y} with color @var{c} and |
29 ## insert in the current axes object. Return handle to patch object. | |
30 ## | |
31 ## For a uniform colored patch, @var{c} can be given as an RGB vector, | |
32 ## scalar value referring to the current colormap, or string value (for | |
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:
8920
diff
changeset
|
33 ## example, "r" or "red"). |
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:
8920
diff
changeset
|
34 ## |
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:
8920
diff
changeset
|
35 ## If passed a structure @var{fv} contain the fields "vertices", "faces" |
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:
8920
diff
changeset
|
36 ## and optionally "facevertexcdata", create the patch based on these |
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:
8920
diff
changeset
|
37 ## properties. |
6807 | 38 ## @end deftypefn |
39 | |
40 ## Author: jwe | |
41 | |
7216 | 42 function retval = patch (varargin) |
6807 | 43 |
7215 | 44 [h, varargin] = __plt_get_axis_arg__ ("patch", varargin{:}); |
7216 | 45 |
7215 | 46 oldh = gca (); |
7216 | 47 |
7215 | 48 unwind_protect |
49 axes (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:
8920
diff
changeset
|
50 [tmp, failed] = __patch__ (h, 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:
8920
diff
changeset
|
51 if (failed) |
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:
8920
diff
changeset
|
52 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:
8920
diff
changeset
|
53 endif |
7215 | 54 unwind_protect_cleanup |
55 axes (oldh); | |
56 end_unwind_protect | |
7020 | 57 |
6807 | 58 if (nargout > 0) |
7216 | 59 retval = tmp; |
6807 | 60 endif |
61 | |
62 endfunction | |
7020 | 63 |
64 %!demo | |
65 %! ## Patches with same number of vertices | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
66 %! clf |
7020 | 67 %! t1 = (1/16:1/8:1)'*2*pi; |
68 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
69 %! x1 = sin(t1) - 0.8; | |
70 %! y1 = cos(t1); | |
71 %! x2 = sin(t2) + 0.8; | |
72 %! y2 = cos(t2); | |
73 %! patch([x1,x2],[y1,y2],'r'); | |
74 | |
75 %!demo | |
76 %! ## Unclosed patch | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
77 %! clf |
7020 | 78 %! t1 = (1/16:1/8:1)'*2*pi; |
79 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; | |
80 %! x1 = sin(t1) - 0.8; | |
81 %! y1 = cos(t1); | |
82 %! x2 = sin(t2) + 0.8; | |
83 %! y2 = cos(t2); | |
84 %! patch([[x1;NaN(8,1)],x2],[[y1;NaN(8,1)],y2],'r'); | |
85 | |
86 %!demo | |
87 %! ## Specify vertices and faces separately | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
88 %! clf |
7020 | 89 %! t1 = (1/16:1/8:1)'*2*pi; |
90 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; | |
91 %! x1 = sin(t1) - 0.8; | |
92 %! y1 = cos(t1); | |
93 %! x2 = sin(t2) + 0.8; | |
94 %! y2 = cos(t2); | |
95 %! vert = [x1, y1; x2, y2]; | |
96 %! fac = [1:8,NaN(1,8);9:24]; | |
97 %! patch('Faces',fac,'Vertices',vert,'FaceColor','r'); | |
98 | |
99 %!demo | |
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:
8920
diff
changeset
|
100 %! ## Specify vertices and faces separately |
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:
8920
diff
changeset
|
101 %! clf |
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:
8920
diff
changeset
|
102 %! t1 = (1/16:1/8:1)'*2*pi; |
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:
8920
diff
changeset
|
103 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; |
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:
8920
diff
changeset
|
104 %! x1 = sin(t1) - 0.8; |
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:
8920
diff
changeset
|
105 %! y1 = cos(t1); |
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:
8920
diff
changeset
|
106 %! x2 = sin(t2) + 0.8; |
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:
8920
diff
changeset
|
107 %! y2 = cos(t2); |
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:
8920
diff
changeset
|
108 %! vert = [x1, y1; x2, y2]; |
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:
8920
diff
changeset
|
109 %! fac = [1:8,NaN(1,8);9:24]; |
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:
8920
diff
changeset
|
110 %! patch('Faces',fac,'Vertices',vert,'FaceVertexCData', [0, 1, 0; 0, 0, 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:
8920
diff
changeset
|
111 |
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:
8920
diff
changeset
|
112 %!demo |
7020 | 113 %! ## Property change on multiple patches |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
114 %! clf |
7020 | 115 %! t1 = (1/16:1/8:1)'*2*pi; |
116 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
117 %! x1 = sin(t1) - 0.8; | |
118 %! y1 = cos(t1); | |
119 %! x2 = sin(t2) + 0.8; | |
120 %! y2 = cos(t2); | |
121 %! h = patch([x1,x2],[y1,y2],cat (3,[0,0],[1,0],[0,1])); | |
122 %! pause (1); | |
123 %! set (h, 'FaceColor', 'r'); | |
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:
8920
diff
changeset
|
124 |
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:
8920
diff
changeset
|
125 %!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:
8920
diff
changeset
|
126 %! clf |
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:
8920
diff
changeset
|
127 %! vertices = [0, 0, 0; |
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:
8920
diff
changeset
|
128 %! 1, 0, 0; |
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:
8920
diff
changeset
|
129 %! 1, 1, 0; |
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:
8920
diff
changeset
|
130 %! 0, 1, 0; |
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:
8920
diff
changeset
|
131 %! 0.5, 0.5, 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:
8920
diff
changeset
|
132 %! faces = [1, 2, 5; |
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:
8920
diff
changeset
|
133 %! 2, 3, 5; |
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:
8920
diff
changeset
|
134 %! 3, 4, 5; |
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:
8920
diff
changeset
|
135 %! 4, 1, 5]; |
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:
8920
diff
changeset
|
136 %! patch('Vertices', vertices, 'Faces', faces, ... |
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:
8920
diff
changeset
|
137 %! 'FaceVertexCData', jet(4), 'FaceColor', 'flat') |
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:
8920
diff
changeset
|
138 %! view (-37.5, 30) |