Path: news.mathworks.com!not-for-mail
From: "Felix Morsdorf" <felix.morsdorf@geo.uzh.ch>
Newsgroups: comp.soft-sys.matlab
Subject: Re: tristripping of vertices matrix
Date: Thu, 23 Aug 2007 14:44:58 +0000 (UTC)
Organization: Universit&#228;t Z&#252;rich
Lines: 63
Message-ID: <fak6h9$tu$1@fred.mathworks.com>
References: <fak18v$j47$1@fred.mathworks.com> <fak1oq$pig$1@fred.mathworks.com>
Reply-To: "Felix Morsdorf" <felix.morsdorf@geo.uzh.ch>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1187880298 958 172.30.248.38 (23 Aug 2007 14:44:58 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 23 Aug 2007 14:44:58 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 498125
Xref: news.mathworks.com comp.soft-sys.matlab:425215



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
> 
> 
>