Anda di halaman 1dari 15

3D Visualization using

Boris Kaus
ETH Zurich
Some reasons to use MATLAB

 Easy to use, widespread.


 Cross-platform (Windows/Mac/LINUX).
 High-level programming language (=small code).
 Extensive visualization tools.
 Program & visualize = debug & develop faster.
 Dont worry about things like solving system of
equations etc.
 There are no really good (free) alternatives
(although attempts have been made, e.g. Octave).
 Most universities do have licenses.
Some reasons NOT to use MATLAB

 MATLAB language is an interpreter language, and


hence slow.
 Tuning your codes for production runs can be tricky.
- Although the MILAMIN code from the Oslo group can do ~50
Mio DOFs (using big memory machine)
 Expensive (~ $10000/license) if you have to buy it.
 Compiler exists, but doesnt bring the speedup we
would like to have.
 Typically only good on one processor.
 3D visualization is relatively slow.
Some examples of 2D plots
11 1

10 0.9

9 0.8

0.7
8

0.6
7
0.5
6
0.4
5
0.3
4
0.2
3
0.1
2
0
1 -3 -2 -1 0 1 2 3
1 2 3 4 5 6 7 8 9 10

Multiple Decay Rates


200 0.8
1.5

150 0.6

1
100 0.4

0.5 50 0.2

Slow Decay

Fast Decay
0 0
0

-50 -0.2

-0.5
-100 -0.4

-1 -150 -0.6

-200 -0.8
-1.5 0 2 4 6 8 10 12 14 16 18 20
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2 2.5
Time (sec)
Some more elaborate 2D plots

Gorczyk et al.
(2006), G-cubed
What about 3D?

-2

-4

-6
25
-8
0
20 surf(peaks(20))
5 15
10 10
15
5
20
25 0
Height

light; lighting phong


6

8 4

4 2
2

0
0
shading interp;
-2
h=colorbar
-4

-6
25
-2 title(h,height)
-8
20
0
5 15
-4 load clown
10 10
surface(peaks,flipud(X),...
15 'FaceColor','texturemap',...
5 -6
20 'EdgeColor','none',...
25 0
'CDataMapping','direct')
colormap(map)
Velocity
Example of quiver3

1
0.8
0.8

0.6 0.6

0.4 0.4

0.2 0.2

0
0
-0.2
-0.2
-0.4
-0.4
-0.6
-0.6
-0.8 1.5

-1 1
0.5 3
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
2
0 1

[x,y] = meshgrid(-2:.2:2,-1:.15:1); -0.5

-1
-1
0

z = x .* exp(-x.^2 - y.^2); -1.5 -3


-2

[px,py] = gradient(z,.2,.15); [x,y] = meshgrid(-2:.2:2,-1:.15:1);


contour(x,y,z), hold on z = x .* exp(-x.^2 - y.^2);
quiver(x,y,px,py), hold off, axis image [u,v,w] = surfnorm(x,y,z);
quiver3(x,y,z,u,v,w); hold on,
surf(x,y,z), hold off
Volumetric data

[x y z v] = flow;
h=contourslice(x,y,z,v,[1:9],[],[0], linspace(-8,2,10));
axis([0 10 -3 3 -3 3]); daspect([1 1 1])
Made with sliceomatic (later). camva(24); camproj perspective;
campos([-3 -15 5])
set(gcf, 'Color', [.3 .3 .3], 'renderer', 'zbuffer')
Bucky ball set(gca, 'Color', 'black' , 'XColor', 'white', ...
'YColor', 'white' , 'ZColor', 'white')
box on
Combined stuff

load wind
figure;
cla
spd = sqrt(u.*u + v.*v + w.*w);
p = patch(isosurface(x,y,z,spd, 40));
isonormals(x,y,z,spd, p)
set(p, 'FaceColor', 'red', 'EdgeColor', 'none');
p2 = patch(isocaps(x,y,z,spd, 40));
set(p2, 'FaceColor', 'interp', 'EdgeColor', 'none')
daspect([1 1 1]);
[f verts] = reducepatch(isosurface(x,y,z,spd, 30), .2);
h=coneplot(x,y,z,u,v,w,verts(:,1),verts(:,2),verts(:,3),2);
set(h, 'FaceColor', 'cyan', 'EdgeColor', 'none');
[sx sy sz] = meshgrid(80, 20:10:50, 0:5:15);
h2=streamline(x,y,z,u,v,w,sx,sy,sz);
set(h2, 'Color', [.4 1 .4]);
colormap(jet)
box on
axis tight
camproj perspective;
camva(34);
campos([165 -20 65]);
camtarget([100 40 -5])
camlight left;
lighting gouraud
Maps etcetera. (partly with mapping toolbox)
80

60

40

20

-20

-40

-60

-80

0 50 100 150 200 250 300 350


topography [m]

-6000 -4000 -2000 0 2000 4000


Graphical User Interfaces

Created with the guide tool of MATLAB


Some more time-consuming examples
Sliceomatic my favorite 3D MATLAB tool

from: http://www.mathworks.com/matlabcentral/fileexchange
Melt-channels?
But:

I feel that Paraview is faster, better, easier to use than


MATLAB for 3D data visualization.

Plus: its for free

Anda mungkin juga menyukai