Hello TeX Stackoverflow!

I have a question about 3D plotting in Asymptote. I want to produce a very simple 3D sketch of a line intersecting two planes, but I have trouble making it look "realistic": enter image description here

The line should go over the left border of the plane, hit it's center and go through. Then the line should not be visible behind the plane until it passes the opposite border. Same with the other plane.

Here is the code that produces the image above:

settings.outformat = "pdf";
settings.prc = false;
settings.render = 0;
size(7cm, 0);
import graph3;
import math;

//draw(O--X, blue);
//draw(O--Y, green);
//draw(O--Z, red); 

triple UVO = X - Y / 2 - Z / 2;
triple XYO = -X - Y / 2 - Z / 2;

path3 planeUV = plane(O = UVO, Y, Z);
path3 planeXY = plane(O = XYO, Y, Z);

triple rayStart = 2X;//(2, -0.5, 0.5);
triple rayEnd = -rayStart;
path3 ray = rayStart -- rayEnd;

material m_white = material(diffusepen=gray(0.4), emissivepen=gray(0.6));


real i1 =  intersect(P = rayStart, Q = rayEnd, X, UVO);
real i2 =  intersect(P = rayStart, Q = rayEnd, X, XYO);

dot(point(ray, i1));
dot(point(ray, i2));

draw(surface(planeUV), m_white);

draw(surface(planeXY), m_white);

I would also like to visualize the intersection points with a dot, which also does not work at the moment.

A similar problem has already been solved here, but unfortunately I could not find a way to adapt this code to my situation.

I have read that it is in general very hard to produce 3D graphics in Asymptote and Tikz that have correct z-ordering, but given my very simple sketch, this should not be so hard right?

If it is not possible with Asymptote or Tikz, does there exist a package/tool that achieves what I want?

Thank you for the help!

  • First, try with settings.render = 8; instead of zero. Second, you can get the intersection by using the real intersect(triple P, triple Q, triple n, triple Z); function from the math module. – Charles Staats Oct 8 '15 at 15:31
  • @CharlesStaats: Would you mind converting your comment into an answer? – Tom Bombadil Dec 16 '15 at 11:25

Your Answer

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

Browse other questions tagged or ask your own question.