Embedding 3D graphics in pdf from Matlab

204 downloads 526 Views 828KB Size Report
Embed 3D graphics in pdf from Matlab. Matlab Figures. U3D file format. LATEX code. What we need: • u3d pre and mesh2pdf packages for Matlab from.
Embed 3D graphics in pdf from Matlab

Embedding 3D graphics in pdf from Matlab • able to view and navigate 3D plots/graphics • enhance your documents/presentations

Embed 3D graphics in pdf from Matlab

Figure: Some surface plots.

Embed 3D graphics in pdf from Matlab

(sdtest9wend2R50.u3d)

(eudiswend2R50.u3d)

Embed 3D graphics in pdf from Matlab

Universal 3D(U3D)

• compressed file format standard for 3D computer graphics

data • file name extension filename.u3d • supported by the pdf format • interactively visualized by Acrobat Reader (since version 7)

Embed 3D graphics in pdf from Matlab

Matlab Figures

U3D file format

LATEX code

What we need: • u3d pre and mesh2pdf packages for Matlab from

Mathworks;1

2

• movie15 package for LATEX

1

from any ctan site;3

http://www.mathworks.com/matlabcentral/fileexchange/ 25383-matlab-mesh-to-pdf-with-3d-interactive-object 2 http://www.mathworks.com/matlabcentral/fileexchange/ 27245-generate-vertices-faces-and-color-for-u3d-format 3 http: //www.ctan.org/tex-archive/help/Catalogue/entries/movie15.html which provide interface to embed movies, sounds and 3D objects into PDF.

Embed 3D graphics in pdf from Matlab

• Generate 3D graphics in Matlab in a normal figure window

>>[X,Y,Z]=peaks(30); >>surf(X,Y,0.3*Z); • Create a structure of faces and vertices of the 3D surface

>>fvc=u3d pre; • Generate the graphics information

>>mesh to latex(’filename’,fvc.vertices, ... uint32(fvc.faces),fvc.facevertexcdata); • filename.u3d - a u3d file • filename.tex - an example of LATEX

code

Embed 3D graphics in pdf from Matlab

Example of filename.tex: \ begin { center } \ i n c l u d e m o v i e [ p o s t e r , t o o l b a r , l a b e l=f i l e n a m e . u3d , t e x t =( f i l e n a m e . u3d ) , 3 Daac =7 , 3 D r o l l =0, 3 Dc2c =0.000000 1 . 0 0 0 0 0 0 0 . 0 0 0 0 0 0 , 3 Droo =8 6.60254 0 , 3Dcoo=0 0 0 , 3 D l i g h t s=CAD, ] { \ l i n e w i d t h } {\ l i n e w i d t h }{ f i l e n a m e . u3d } \ end { c e n t e r }

Copy the code from filename.tex and paste into your LATEX document where you want the 3D graphic. Remember to add into the preamble \usepackage[3d]{movie15}

Embed 3D graphics in pdf from Matlab

(peaksurf.u3d)

Z

2 0 −2 2 0 X

−2

2

0

−2

Y

Figure: Drag your mouse over the graphic.

Embed 3D graphics in pdf from Matlab

(try4.u3d)

Z

2 0 −2 2 0 X

−2

2

0

−2

Y

Figure: Drag your mouse over the graphic.

Embed 3D graphics in pdf from Matlab

Nothing is perfect... always!

Weakness of the current mesh2pdf and u3d pre packages: • Only works for surf,mesh,isosurface figures in Matlab,

not for scatter3 figure • can we label it? adding text? (axis?)