[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tetramesh alternative?
From: |
Martin Helm |
Subject: |
Re: tetramesh alternative? |
Date: |
Tue, 6 Jul 2010 21:31:53 +0200 |
User-agent: |
KMail/1.12.4 (Linux/2.6.31.12-0.2-desktop; KDE/4.3.5; x86_64; ; ) |
Am Dienstag, 6. Juli 2010 20:11:30 schrieb Martin Helm:
> Am Dienstag, 6. Juli 2010 16:13:47 schrieb Bart Vandewoestyne:
> > Hello list,
> >
> > I have two students working on M*tl*b code where the tetramesh
> > command is used:
> >
> > http://www.mathworks.com/access/helpdesk/help/techdoc/ref/tetramesh.html
> >
> > They would like the code to also run in Octave. On
> >
> > http://wiki.octave.org/wiki.pl?MissingMatlabFunctions
> >
> > I have found that tetramesh is currently still missing in Octave.
> >
> > Is there a workaround/alternative? Can they do the visualization
> > using another command sequence that would lead to about the same
> > result?
> >
> > Thanks!
> > Bart
>
> Just to give a simple idea, the example from the link above can be
> rewritten in octave with the patch function:
>
> 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);
>
> ## create a triangulation from the tetraeder array
> T = [tetra(:, 1) tetra(:, 2) tetra(:, 3); ...
> tetra(:, 2) tetra(:, 3) tetra(:, 4); ...
> tetra(:, 3) tetra(:, 4) tetra(:, 1); ...
> tetra(:, 4) tetra(:, 1) tetra(:, 2)];
>
> X = [x(:) y(:) z(:)];
>
> patch("Faces", T, "Vertices", X, "FaceVertexCData", X)
> view(30,30)
>
> Of course I did not use a very intelligent coloring here, just that you can
> see something.
>
> It will also work with the standard gnuplot backend.
>
> So it is easy to make your own tetramesh function.
>
> - mh
>
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)
Bildschirmfoto2.png
Description: PNG image