Mercurial > hg > octave-nkf
diff scripts/geometry/trimesh.m @ 9110:22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
author | David Bateman <dbateman@free.fr> |
---|---|
date | Sat, 11 Apr 2009 16:26:01 +0200 |
parents | 1bf0ce0930be |
children | 16f53d29049f |
line wrap: on
line diff
--- a/scripts/geometry/trimesh.m +++ b/scripts/geometry/trimesh.m @@ -38,27 +38,29 @@ elseif (ischar (z)) triplot (tri, x, y, z, varargin{:}); else - idx = tri(:, [1,2,3,1]).'; - nt = size (tri, 1); - ## FIXME We should really use patch instead of plot3, but we don't - ## have a patch function, and probably won't in 3D that works with - ## gnuplot + newplot (); if (nargout > 0) - h = plot3 ([x(idx); NaN*ones(1, nt)](:), - [y(idx); NaN*ones(1, nt)](:), - [z(idx); NaN*ones(1, nt)](:), varargin{:}); + h = patch ("Vertices", [x(:), y(:), z(:)], "Faces", tri, + "FaceColor", "none", "EdgeColor", __next_line_color__(), + varargin{:}); else - plot3 ([x(idx); NaN*ones(1, nt)](:), - [y(idx); NaN*ones(1, nt)](:), - [z(idx); NaN*ones(1, nt)](:), varargin{:}); + patch ("Vertices", [x(:), y(:), z(:)], "Faces", tri, + "FaceColor", "none", "EdgeColor", __next_line_color__(), + varargin{:}); + endif + + if (! ishold ()) + set (gca(), "view", [-37.5, 30], + "xgrid", "on", "ygrid", "on", "zgrid", "on"); endif endif endfunction %!demo +%! N = 10; %! rand ('state', 10) -%! x = 3 - 6 * rand (1, 50); -%! y = 3 - 6 * rand (1, 50); +%! x = 3 - 6 * rand (N, N); +%! y = 3 - 6 * rand (N, N); %! z = peaks (x, y); -%! tri = delaunay (x, y); -%! trimesh (tri, x, y, z); +%! tri = delaunay (x(:), y(:)); +%! trimesh (tri, x(:), y(:), z(:));