help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tetramesh alternative?


From: David Bateman
Subject: Re: tetramesh alternative?
Date: Tue, 06 Jul 2010 22:05:54 +0200
User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706)

Martin Helm wrote:
Here is a very primitive implementation of tetramesh

function tetramesh( T, X, C)
  if nargin < 3
     C = mod((1:size(T, 1))'-1, size(colormap(), 1) + 1);
  endif
  triang = [T(:, 1) T(:, 2) T(:, 3); ...
            T(:, 2) T(:, 3) T(:, 4); ...
            T(:, 3) T(:, 4) T(:, 1); ...
            T(:, 4) T(:, 1) T(:, 2)];
  patch("Faces", triang, "Vertices", X, "FaceVertexCData", [C; C; C; C])
endfunction

which gives with the example above:

backend("fltk")
d = [-1 1];
[x,y,z] = meshgrid(d,d,d);
x = [x(:);0];
y = [y(:);0];
z = [z(:);0];
tetra = delaunay3(x,y,z);
X = [x(:) y(:) z(:)];
tetramesh(tetra, X)
view(30,30)


It works in gnuplot as well, though note that the gnuplot backend can only plot triangular patches in 3-D (which is fine for tetramesh)

D.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]