Path: news.mathworks.com!not-for-mail
From: "Titus" <titus.edelhofer@mathworks.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: tristripping of vertices matrix
Date: Thu, 23 Aug 2007 15:23:37 +0200
Organization: The MathWorks, Inc.
Lines: 43
Message-ID: <fak1oq$pig$1@fred.mathworks.com>
References: <fak18v$j47$1@fred.mathworks.com>
NNTP-Posting-Host: 172.16.78.181
X-Trace: fred.mathworks.com 1187875419 26192 172.16.78.181 (23 Aug 2007 13:23:39 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 23 Aug 2007 13:23:39 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3028
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
Xref: news.mathworks.com comp.soft-sys.matlab:425194




"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