17

I would like to make 3d pictures and put them side-by-side. I can do that nicely creating a file example.asy:

settings.render=1;
import graph;
import graph3;
import contour3;

material reds =  material(diffusepen=0.7red,ambientpen=red,emissivepen=0.3*red,specularpen=0.95white,shininess=0.95);
material blues = material(diffusepen=0.7blue,ambientpen=blue,emissivepen=0.3*blue,specularpen=0.95white,shininess=0.95);

int numberlines=8;

defaultrender.merge=true;
defaultrender.tessellate=true;
defaultrender.compression=Low;

picture p1,p2;
size(p1,100);
size(p2,100);

real f(real x, real y, real z) {return y^2+x-2;}
real c(real x, real y, real z) {return 2*x+2*z -2;}

draw(p1,surface(contour3(f,(-3,-3,-3),(3,3,3),numberlines)),reds);
draw(p1,surface(contour3(c,(-3,-3,-3),(3,3,3),numberlines)),blues);
draw(p2,surface(contour3(f,(-3,-3,-3),(3,3,3),numberlines)),reds);
draw(p2,surface(contour3(c,(-3,-3,-3),(3,3,3),numberlines)),blues);

currentprojection=orthographic(camera=(9,10,4),up=Z,target=O,zoom=1);
add(p2.fit(currentprojection),(0,0),W);
currentprojection=orthographic(camera=(0,7,7),up=Z,target=O,zoom=1);
add(p1.fit(currentprojection),(0,0),30E);

The result is the same 3d image from two different points of view: enter image description here

However, if I try to reproduce that in a LaTeX document, I get two repeated copies of the second image (in this case the projection with camera at (0,7,7)): enter image description here

This is the LaTeX code I'm using:

\documentclass{article}

\usepackage[inline]{asymptote}

\begin{asydef}
settings.outformat="png";
settings.render=1;
import graph;
import graph3;
import contour3;

material reds =  material(diffusepen=0.7red,ambientpen=red,emissivepen=0.3*red,specularpen=0.95white,shininess=0.95);
material blues = material(diffusepen=0.7blue,ambientpen=blue,emissivepen=0.3*blue,specularpen=0.95white,shininess=0.95);

int numberlines=8;

defaultrender.merge=true;
defaultrender.tessellate=true;
defaultrender.compression=Low;
\end{asydef}

\begin{document}
\begin{asy}
    picture p1,p2;
    size(p1,100);
    size(p2,100);

    real f(real x, real y, real z) {return y^2+x-2;}
    real c(real x, real y, real z) {return 2*x+2*z -2;}

    draw(p1,surface(contour3(f,(-3,-3,-3),(3,3,3),numberlines)),reds);
    draw(p1,surface(contour3(c,(-3,-3,-3),(3,3,3),numberlines)),blues);
    draw(p2,surface(contour3(f,(-3,-3,-3),(3,3,3),numberlines)),reds);
    draw(p2,surface(contour3(c,(-3,-3,-3),(3,3,3),numberlines)),blues);

    currentprojection=orthographic(camera=(9,10,4),up=Z,target=O,zoom=1);
    add(p2.fit(currentprojection),(0,0),W);
    currentprojection=orthographic(camera=(0,7,7),up=Z,target=O,zoom=1);
    add(p1.fit(currentprojection),(0,0),30E);
\end{asy}
\end{document}

This is with asymptote 2.15.2.

How can I get, from LaTeX, the same output I got by running asy -V from the command line?

4
  • 1
    Have you tried omitting the line settings.outformat="pdf" from your asydef environment? That's the only difference I see, and usually the asy file actually output by the asymptote package will automatically include an appropriate settings.outformat= statement. (Actually, it's not the only difference--you might also try omitting the inline option when you call the package.) Commented Oct 29, 2013 at 19:50
  • Thank you!!! settings.outformat makes no difference, but remving the inline option fixes the problem. I suppose, then, that this is a bug in asymptote (or more precisely, in its interface with LaTeX), right? Commented Oct 29, 2013 at 23:46
  • 1
    Almost certainly. If you want to delve deeper, you might look at the filename-number.asy file that is actually produced after running LaTeX with the inline option. Commented Oct 30, 2013 at 0:03
  • 4
    Well, not using inline seems to mess up the document somehow (3d images are included over the text, as if no space was reserved for them)... But I've found that if I use \usepackage[inline,attach]{asymptote} with \usepackage[dvips]{attachfile2}, and settings.embed=true in my asydef, it works! Commented Oct 30, 2013 at 12:43

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.