How to find the intersection of two `path3[]`

I'm using Asymptote to draw some figures and I need to put a dot on the intersection of two `path3[]` but the command `intersectionpoint()` doesn't work for `path3[]`. What can I do?

• I am not familiar with this package but those who are will need to see a minimum working example in order to trouble shot your problem. This includes the preamble, begin and end document, and a small re-creation of the issue. Commented Jul 26, 2013 at 14:45

Built-in three-dimensional version of the function `intersectionpoints` returns an array of intersection points of the two `3d` paths. To get the intersections of two `path3[]` arrays, a simple function `intersectionpoints3` can be used, that checks and accumulates all combinations of the intersection points:

``````import three;
currentprojection=orthographic(camera=(-5,1.5,4),up=Y,target=O,zoom=1);

triple[] intersectionpoints3(path3[] p,path3[] q){
triple[] r=new triple[];
triple[] s;
for(path3 pk:p){
for(path3 qj:q){
s=intersectionpoints(pk,qj);
if(s.length>0)r.append(s);
}
}
return r;
}

size(200);
path3[] p=box(O,(1,1,1));
path3[] q=(-0.5,0,0.5)--(1.5,0,0.5)..(2,0.5,0.5)..(1.5,1,0.5)
^^(1.5,1,0.5)--(-0.5,1,0.5)..(-1,0.5,0.5)..(-0.5,0,0.5);

draw(p,darkblue);
draw(q,orange);

dot(intersectionpoints3(p,q),red);
``````