# Asymptote: Intersect Line with Plane, z-order not correct

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": 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;

currentlight=light(white,(2,2,2),(2,-2,-2));
//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));

draw(ray);

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(planeUV);

draw(surface(planeXY), m_white);
draw(planeXY);
``````

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