From: Anunay Kris on 18 Jun 2010 12:37 Hi, Im trying to read data stored in a .mat file into a .wrl file. What command do i use for this. - Anunay
From: Jan Houska on 20 Jun 2010 07:44 Hi Anunay, Anunay Kris wrote: > Im trying to read data stored in a .mat file into a .wrl file. What > command do i use for this. your question does not make much sense. MAT-file can contain any kind of numeric or text or whatever type of data, while a VRML97 (WRL) file describes graphic objects. There are many ways how to convert numeric data to their graphic representation, and many kinds of data do not have any meaningful graphic representation at all. That said, if your data can be meaningfully displayed as a 3D graph and you want to convert that graph to VRML, please have a look at the "surf" (for rendering) and "vrml" (for conversion) commands. Good Luck, Jan -- Jan Houska HUMUSOFT s.r.o. houska(a)humusoft.com Pobrezni 20 http://www.humusoft.com 186 00 Praha 8 tel: ++ 420 284 011 730 Czech Republic fax: ++ 420 284 011 740
From: anunay k on 21 Jun 2010 10:58 On Jun 20, 6:44 am, Jan Houska <hou...(a)humusoft.com> wrote: > Hi Anunay, > > Anunay Kris wrote: > > Im trying to read data stored in a .mat file into a .wrl file. What > > command do i use for this. > > your question does not make much sense. MAT-file can contain any kind of > numeric or text or whatever type of data, while a VRML97 (WRL) file > describes graphic objects. There are many ways how to convert numeric > data to their graphic representation, and many kinds of data do not have > any meaningful graphic representation at all. > > That said, if your data can be meaningfully displayed as a 3D graph and > you want to convert that graph to VRML, please have a look at the "surf" > (for rendering) and "vrml" (for conversion) commands. > > Good Luck, Jan > > -- > Jan Houska HUMUSOFT s.r.o. > hou...(a)humusoft.com Pobrezni 20http://www.humusoft.com 186 00 Praha 8 > tel: ++ 420 284 011 730 Czech Republic > fax: ++ 420 284 011 740 Hi Jan, Let me rephrase my original question. I have a table of points which represents the amplitude of a surface at different values of x and y on the surface and this is stored in a mat file. At every instant of time the value of the amplitude changes(for all x and y) . Im plotting the surface in vrml with 'elevation grid' and the amplitude at every instant of tim is 'height' . I want to know if there is a way for the .wrl file('height' data field) to read this data from a .mat file. - Anunay
From: Saurabh Mahapatra on 22 Jun 2010 19:15 Hi Anunay, I took a shot at this and have written a little script that should do the transformation. Look at the example script and modify accordingly. The example that I used was a MATLAB example from MESHGRID. >>doc meshgrid The rules that I followed for creating the elevation grid is from here: http://www.lighthouse3d.com/vrml/tutorial/index.shtml?elevg Basically, you need to figure out the xSpacing, xDimension, zDimension, zSpacing. Keep in mind the VRML coordinate system that has X pointing to the right, Z towards you and Y upwards. See this: http://www.mathworks.com/access/helpdesk/help/toolbox/sl3d/f2-36380.html I have not had time to refine the code(place viewpoints, add color, lighting) so it is open to improvements. Thanks, Saurabh clear all; %% This is MATLAB data equispaced along two axes [X,Y] = meshgrid(-2:.2:2, -2:.2:2); Z = X .* exp(-X.^2 - Y.^2); surf(X,Y,Z) % Transforming data into VRML. Remember Z axis is pointing out of the % screen towards you. X axis to the right and Y Axis is upwards. xDimension=length(X(1,:)); xSpacing=abs(X(1,2)-X(1,1)); zDimension=length(Y(1,:)); zSpacing=abs(Y(2,1)-Y(1,1)); filename='myshape.wrl'; delete(filename); fid = fopen(filename, 'w'); fprintf(fid,'#VRML V2.0 utf8'); fprintf(fid, '\n Transform { \n'); fprintf(fid,' \n translation %f %f %f\n', -(max(max(X))-min(min(X)))/2,-(max(max(Z))-min(min(Z)))/2, -(max(max(Y))-min(min(Y)))/2); fprintf(fid,' \n rotation 1 0 0 0.52\n'); fprintf(fid,' \n scale 0.1 0.1 1\n'); fprintf(fid, '\n children Shape {\n'); fprintf(fid,'\n appearance Appearance {\n'); fprintf(fid,'\n material Material {}\n'); fprintf(fid,'\n }\n'); fprintf(fid, '\n geometry ElevationGrid { \n'); fprintf(fid, '\n xDimension %d\n', xDimension); fprintf(fid, '\n xSpacing %d\n', xSpacing); fprintf(fid, '\n zDimension %d\n', zDimension); fprintf(fid, '\n zSpacing %d\n', zSpacing); fprintf(fid,' height ['); for i=xDimension:-1:1 for j=zDimension:-1:1 fprintf(fid,'%f', Z(i,j)); if (i==1 && j==1) else fprintf(fid,','); end end fprintf(fid,'\n'); end fprintf(fid,']\n'); fprintf(fid,'\n color NULL\n'); fprintf(fid,'\n colorPerVertex TRUE\n'); fprintf(fid,'\n normal NULL\n'); fprintf(fid,'\n normalPerVertex TRUE\n'); fprintf(fid, '\n texCoord NULL \n'); fprintf(fid, '\n ccw TRUE\n'); %fprintf(fid, '\n convex TRUE\n'); fprintf(fid, '\n solid FALSE\n'); fprintf(fid, '\n creaseAngle 0.0\n'); fprintf(fid,' }\n'); fprintf(fid,' }\n'); fprintf(fid,' }\n'); fclose(fid); w=vrworld(filename); open(w); f=vrfigure(w);
|
Pages: 1 Prev: How to modify each matrix of a randn(:,:,:) Next: circumstantial? |