Eric Carlson <ecarlson@coe.eng.ua.edu> wrote in message <V9KLf.1089$IV4.14@fe05.lga>...
> G. Dibujo wrote:
> > Eric Carlson wrote:
> >
> >>
> >>G. Dibujo wrote:
> >>
> >>>Eric Carlson wrote:
> >>>
> >>>
> >>>>..........
> >>>>Depending on what you plan to do, MATLAB may be fast enough.
> >>
> >>Until
> >>
> >>>>I
> >>>>start getting into scenes with hundreds of thousands of
> >>
> >>triangles,
> >>
> >>>>I
> >>>>notice little difference.
> >>>>
> >>>>.........
> >>>
> >>>
> >>>If a scene has hundreds of thousands of triangles, then it will
> >>>certainly have over a handred thousand vertices. So my question
> >>
> >>is
> >>
> >>>how it possible to create a very large matrix like
> >>>"zeros(100000,100000)" when you try to calculate for instance
> >
> > the
> >
> >>>edge matrix of a triangle mesh. Allocating memory for such a
> >
> > huge
> >
> >>>matrix requires at least 8 GB of memory.
> >>>
> >>>Any suggestions. Thanks.
> >>
> >>Hello,
> >>Sorry for the slow reply  been away.
> >>
> >>I am not sure what you mean exactly. My experience with MATLAB 3D
> >>graphics deals primarily with the use of the patch command and the
> >>associated facevertex structure. Variations of the FV structure
> >>are
> >>used throughout 3D graphics. Using the FV structure, you specify
> >>each
> >>vertex X_k=(x_k y_k z_k) and associate it with index k. Each
> >>triangle
> >>face is specified as an ordered triplet of vertex indices T = [l m
> >>n].
> >>If you want consistent rendering behavior, then you also need to
> >>make
> >>sure that the order of the vertices is such that
> >>cross(X_mX_l,X_nX_m)
> >>is consistently pointing on one side of the surface. Not all of the
> >>
> >>surface routines in MATLAB are consistent this way, which leads to
> >>very
> >>aggravating coloring effects at times.
> >>
> >>For a hypothetical case with 100,000 vertices and 100,000
> >>triangles, you
> >>will need 100K*3*8+100k*3*8= 4800K = 4.8 M.
> >>
> >>These structures and more are explained in Ch 11 of my book
> >>Foundations
> >>of Engineering with MATLAB 7 at www.otfringe.com (and will be
> >>available
> >>as an ebook later this Spring)
> >>
> >>Cheers,
> >>Eric Carlson
> >>
> >
> >
> > I agree with you that a large number of vertices and triangles is not
> > a problem when you use the MATLAB patch command to display a 3D
> > triangle mesh. The problem arises when you want to compute for
> > instance the adjacency matrix of the mesh. An adjaceny matrix A =
> > (a_{ij}) is a concept from graph theory and is defined between the
> > mesh vertices as follows: a_{ii}=0 and a_{ij} = 1 if vertex_i is
> > connected to vertex_j.
> > Now let's assume that we have a 3D model with 100,000 vertices as
> > illustrated in the code segment below. My question is how to
> > preallocate a zero matrix of size 100,000x100,000 which requires 80
> > GB of memory:
> >
> > %1st step: load a 3D model:
> > % Copyright: <http://lodbook.com/models/>
> >
> >>>load dragon
> >>>whos
> >
> > Name Size Bytes Class
> >
> > faces 202520x3 4860480 double array
> > vertices 100207x3 2404968 double array
> >
> > % 2nd step: How to calculate the adjacency matrix
> >
> > nvert = length(vertices);
> > nface = length(faces);
> > %preallocate a zero matrix of size nvert x nvert
> > A = zeros(nvert,nvert); % Requires 80 GB?
> > for i=1:nface
> > A(faces(i,1),faces(i,2)) = 1;
> > A(faces(i,2),faces(i,3)) = 1;
> > A(faces(i,3),faces(i,1)) = 1;
> > % make sure symmetry holds
> > A(faces(i,2),faces(i,1)) = 1;
> > A(faces(i,3),faces(i,2)) = 1;
> > A(faces(i,1),faces(i,3)) = 1;
> > end
> > A = sparse(A);
> The total number of nonzeros from this matrix will be bounded by
> N_triangles*2*3 (three edges per triangle X 2 for symmetry), so the
> total size of A need not exceed this amount. I don't do much with
> sparse matrices in MATLAB but you might try something like:
>
> %first column IA, second JA
> IA_JA = [faces(:,1) faces(:,2)
> faces(:,1) faces(: 3)
> faces(:,2) faces(:,3)
> faces(:,2) faces(:,1)
> faces(:,3) faces(:,1)
> faces(:,3) faces(:,2)];
> IA_JA = unique(IA_JA, 'rows');
>
> A=sparse(IA_JA(:,1), IA_JA(:,2),1);
>
>
>
Hi Eric,
Just a quick question for you or anyone else reading this... Is there a book/tutorial to learn graphics in matlab. I searched online, however all i could get was how to visualize data.
Is there specific reference material for Graphics similar to OpenGL in matlab??
Thanks in advance.
Asad
