|
Many thanks Titus for your help!
It works very well, the generalised form will look like this:
A = reshape(1:20,4,5)';
[m,n] = size(A);
jj = [1:m-1,2:m];
ATri = reshape(A(jj,:),m-1,n*2);
these lines replace about four time the code with loops :-)
cheers,
Felix
"Titus" <titus.edelhofer@mathworks.de> wrote in message <fak1oq$pig
$1@fred.mathworks.com>...
>
> "Felix Morsdorf" <felix.morsdorf@geo.uzh.ch> schrieb im Newsbeitrag
> news:fak18v$j47$1@fred.mathworks.com...
> > Hello all,
> >
> > I am trying to write a function that outputs the content of a matlab
> > opengl
> > rendered axis to an OpenSceneGraph (.osg) file for faster 3d
> > visualization.
> >
> > I have so far succeeded for simple objects like point, lines and patches.
> >
> > For objects of type 'surf' I am now facing the problem of converting the
> > matlab generated vertices and vertex normals matrices into triangle
> > strips.
> >
> > Matlab vertices (three times for x,y,z) Tristrip(s):
> > 1 2 3 1 4 2
> > 5 3 6
> > 4 5 6 4 7 5
> > 8 6 9
> > 7 8 9
> >
> >
> > I have now implemeted a very clumsy (using loops and slow!) way of
doing
> > it,
> > which generates some triangles that are not in the original data. Does
> > anybody know a way of doing it using e.g. clever indexing ?
> >
> > cheers,
> >
> > Felix
>
> Hi Felix,
> at least for this example the following works:
> A = reshape(1:9,3,3)'
> ATri = reshape(A([1 2 2 3],:), 2, 6)
>
> Hope, this helps,
> Titus
>
>
>
|