2

Consider a MWE:

enter image description here

This is part of some diagram, so it looks unfinished, but never mind. I tried to make the example really minimal working.

\documentclass{article}%
%============================================================
\usepackage{asymptote}
\usepackage[utf8]{inputenc}
\usepackage{color}
%============================================================
\begin{document}
\begin{asy}
settings.outformat = "pdf";
settings.prc = false;
settings.render = 16;
import three;
import bsp;
texpreamble("\usepackage{euler,beton}");
size(5cm, 0);
currentprojection=orthographic((5,4,3));

path3 pl =plane((0,-2,0),(-2,0,0),(0,1,0));
path3 pl1=rotate(-28,X)*pl;
path3 pl2=rotate(-56,X)*pl;
path3 pl3=shift(-0.3*normal(pl1))*pl1;

triple[] asd=intersectionpoints(pl2,pl3);
triple A=asd[1];
triple B=asd[0];

triple[] asf=intersectionpoints(pl,pl2);
triple C=asf[1];
triple D=asf[0];

triple[] asg=intersectionpoints(pl,pl3);
triple E=asg[1];
triple F=asg[0];

path3 q11=(D -- -Y -- C-Y -- C -- cycle);
surface sq11=surface(q11);
draw(sq11,white+opacity(.6),light=nolight);
draw(D -- -Y -- C-Y -- C--cycle);

path3 q31=(D--C--A--B--cycle);
surface sq31=surface(q31);
draw(sq31,white+opacity(.6),light=nolight);
draw(D--C--A--B--cycle);

\end{asy}

\end{document}

It works. BUT I want it to be vector graphics (publishing house requirement). When I change

settings.render = 16;

into

settings.render = 0;

('cause that's what makes my graphics vector ) it brakes:

enter image description here

If I keep it vector (settings.render = 0;), but comment all the lines with opacity options, it works:

enter image description here

but this is not what I want.

How to make a vector picture with opacity option for these planes?

Commented example for your comvenience:

\documentclass{article}%
%============================================================
\usepackage{asymptote}
\usepackage[utf8]{inputenc}
\usepackage{color}
%============================================================
\begin{document}
\begin{asy}
settings.outformat = "pdf";
settings.prc = false;
settings.render = 0;
import three;
import bsp;
texpreamble("\usepackage{euler,beton}");
size(5cm, 0);
currentprojection=orthographic((5,4,3));

path3 pl =plane((0,-2,0),(-2,0,0),(0,1,0));
path3 pl1=rotate(-28,X)*pl;
path3 pl2=rotate(-56,X)*pl;
path3 pl3=shift(-0.3*normal(pl1))*pl1;

triple[] asd=intersectionpoints(pl2,pl3);
triple A=asd[1];
triple B=asd[0];

triple[] asf=intersectionpoints(pl,pl2);
triple C=asf[1];
triple D=asf[0];

triple[] asg=intersectionpoints(pl,pl3);
triple E=asg[1];
triple F=asg[0];

path3 q11=(D -- -Y -- C-Y -- C -- cycle);
surface sq11=surface(q11);
//draw(sq11,white+opacity(.6),light=nolight);
draw(D -- -Y -- C-Y -- C--cycle);

path3 q31=(D--C--A--B--cycle);
surface sq31=surface(q31);
//draw(sq31,white+opacity(.6),light=nolight);
draw(D--C--A--B--cycle);

\end{asy}

\end{document}

For references: this is a continuation of my question.

5
  • did you try running asy with the -nosafe flag? – Thruston Mar 11 '20 at 17:50
  • At least here (Fedora 31, asymtptote-2.59-2.fc31.x86_64, ghostscript-9.27-2.fc31.x86_64) it compiles with no hitch, and renders properly (with settings.render = 16 and 0). – vonbrand Mar 12 '20 at 11:06
  • I tried old and last versions of Asymptote but it does not work with settings.render=0. (Ghostscript v1.50). If this example or the one of your previous question were ok with an old version and settings.render=0, reporting an issue is relevant. – O.G. Mar 12 '20 at 13:45
  • @Thruston, I use TexStudio, so it compiles automatically. In the settings: Configure TexStudio->Biuld-> Build& View I have asy-chain. The asy-chain command is: txs:///latex | txs:///asy | txs:///latex | txs:///view-dvi, but I dont compile it with terminal. – Sergey Belyaev Mar 12 '20 at 14:02
  • @vonbrand, I tried to install the newer version of asymptote and even asked the question here: tex.stackexchange.com/questions/529656/…. Nobody answered after my update, so I still have 2.41 and have no idea how to upgrade to anything higher. (ubuntu 18.04, asymtptote-2.41, I have no idea about my ghostscript) – Sergey Belyaev Mar 12 '20 at 14:07
1

I do not know if this example was ok with a previous version of Asymptote or/and Ghostscript. It seems that transparency, render=0 and surface cannot work all together.

However there is a difference with the example in Planes' intersection in Asymptote. In this example you use the bsp package and transparency, render=0, bsp can work all together. Your MWE it becomes

      settings.outformat = "pdf";
      settings.prc = false;
      settings.render = 0;
      import three;
      import bsp;
      texpreamble("\usepackage{euler,beton}");
      size(10cm);


      currentprojection=orthographic((5,4,3));

      path3 pl =plane((0,-2,0),(-2,0,0),(0,1,0));
      path3 pl1=rotate(-28,X)*pl;
      path3 pl2=rotate(-56,X)*pl;
      path3 pl3=shift(-0.3*normal(pl1))*pl1;

      triple[] asd=intersectionpoints(pl2,pl3);
      triple A=asd[1];
      triple B=asd[0];

      triple[] asf=intersectionpoints(pl,pl2);
      triple C=asf[1];
      triple D=asf[0];

      triple[] asg=intersectionpoints(pl,pl3);
      triple E=asg[1];
      triple F=asg[0];

      path3 q11=(D -- (-Y) -- (C-Y) -- C -- cycle);
      //surface sq11=surface(q11);
      //draw(sq11,yellow);//+opacity(.6));
      //draw(D -- -Y -- C-Y -- C--cycle);
      path3 q31=(D--C--A--B--cycle);
      face faces[];
      filldraw(faces.push(q11),project(q11),white+opacity(.5));
      filldraw(faces.push(q31),project(q31),white+opacity(.5));
      //draw(D--C--A--B--cycle,black+1bp);
      add(faces);

and the result is a vector graphic.

Vector graphic and 3D are very difficult to manage. With polygones it seems to be possible but needs some specific routines.

enter image description here

5
  • It did work on the older versions of asymptote. I try to compile your example (ubuntu 18.04, TexStudio, asymptote 2.41), gives the mistake: Process started: asy TestAsyPicFile-1.asy GPL Ghostscript 9.26: Unrecoverable error, exit code 1 /usr/share/asymptote/plain_shipout.asy: 87.10: runtime: shipout failed Process exited with error(s) – Sergey Belyaev Mar 12 '20 at 14:24
  • If I try to compile it without bsp package, the mistake appears as well: Process started: asy TestAsyPicFile-1.asy TestAsyPicFile-1.asy: 44.1: no type of name 'face' Process exited with error(s) This is obviously the lack of bsp, I think. – Sergey Belyaev Mar 12 '20 at 14:26
  • @SergeyBelyaev import bsp; is not sufficient, it is necessary to use the add mechanism to draw any plane. In fact bsp is a 3D->2D process using the binary space partition algorithm, more or less the painter's algorithm. Planes are added through filldraw(..) commands, and at the end add(faces) returns in the right order the drawing of a decomposition of all the planes so that visible/hidden parts are well managed. – O.G. Mar 12 '20 at 14:43
  • I understand. But what do I do wrong when I compile your example. It gives me an error as above – Sergey Belyaev Mar 12 '20 at 16:03
  • With svn version, my example is fine. You have an old version of asymptote with Ghoscript version >9.23. Try -nosafe option. But I do not understand why 1) you can compile your example (render=0) with transparency 2) you can compile the example on tex.stackexchange.com/questions/339032/…. – O.G. Mar 12 '20 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.