3

I am trying to draw a quarter-ellipse starting from the point (a,a,0), ending at (0,0,a), in the code below:

\begin{asy}[width=\textwidth]

settings.render=6;
settings.prc=false;
import three;
import graph3;
import grid3;
currentprojection=obliqueX;

pen thickblack = black+0.75;
real axislength = 1.0;
draw(L=Label("$x$", position=Relative(1.1), align=SW), O--axislength*X,thickblack, Arrow3); 
draw(L=Label("$y$", position=Relative(1.1), align=E), O--axislength*Y,thickblack, Arrow3); 
draw(L=Label("$z$", position=Relative(1.1), align=N), O--axislength*Z,thickblack, Arrow3); 

label("$a$", (0.5,0,0), align=NW);
label("$a$", (0,0.5,0), align=NE);
label("$a$", (0,0,0.5), align=NW);

real a=0.5;

draw(O--expi(pi/2,pi/4),black+0.25);
draw(arc(c=O, a*Y, a*Z), blue);
draw(arc(c=O, a*X, a*Z), red);

dot((a,a,0)); 

draw((0,a,0)--(a,a,0),blue);
draw((a,a,0)--(a,0,0),red);
draw((0,0,a)--(0,0.9,a),red);
draw((a,0,0)--(a,0.9,0),red);
draw(arc(c=(0,0.8,0),(a,0.8,0), (0,0.8,a)), red);

draw((a,a,0)--(0.9,a,0),blue);
draw((0,0,a)--(0.9,0,a),blue);

\end{asy}

In addition, I need fill the two triangles [(0,0,0) -- (0,a,0) -- (a,a,0)] and [(0,0,0) -- (a,0,0) -- (a,a,0)] with different patterns, but I do not know how. Sorry if this is very basic, I am new to asymptote.two-cylinder intersection

  • Welcome! If you wish to format your code, put it in the cursor and press the {} button while editing. –  Apr 12 '20 at 02:55

1 Answers1

2

Welcome! These are some ad hoc suggestions based on this great tutorial and this answer. The elliptic arc is drawn as a parametric plot, and the triangles as filled surfaces.

\documentclass{article}
\usepackage{asymptote}
\begin{document}
\begin{asy}[width=\textwidth]

settings.render=6;
settings.prc=false;
import three;
import graph3;
import grid3;
currentprojection=obliqueX;

pen thickblack = black+0.75;
real axislength = 1.0;
draw(L=Label("$x$", position=Relative(1.1), align=SW), O--axislength*X,thickblack, Arrow3); 
draw(L=Label("$y$", position=Relative(1.1), align=E), O--axislength*Y,thickblack, Arrow3); 
draw(L=Label("$z$", position=Relative(1.1), align=N), O--axislength*Z,thickblack, Arrow3); 

label("$a$", (0.5,0,0), align=NW);
label("$a$", (0,0.5,0), align=NE);
label("$a$", (0,0,0.5), align=NW);

real a=0.5;

draw(O--expi(pi/2,pi/4),black+0.25);
draw(arc(c=O, a*Y, a*Z), blue);
draw(arc(c=O, a*X, a*Z), red);

dot((a,a,0)); 

draw((0,a,0)--(a,a,0),blue);
draw((a,a,0)--(a,0,0),red);
draw((0,0,a)--(0,0.9,a),red);
draw((a,0,0)--(a,0.9,0),red);
draw(arc(c=(0,0.8,0),(a,0.8,0), (0,0.8,a)), red);

draw((a,a,0)--(0.9,a,0),blue);
draw((0,0,a)--(0.9,0,a),blue);

triple f(real t) {
    return (a*cos(t),a*cos(t),a*sin(t));
}

path3 ellarc = graph(f, 0, pi/2, operator ..); 
draw(ellarc,orange);

path3 t1=((0,0,0) -- (0,a,0) -- (a,a,0) -- cycle);
surface s1=surface(t1);
draw(s1,red+opacity(.6),light=nolight);

path3 t2=((0,0,0) -- (a,0,0) -- (a,a,0) -- cycle);
surface s2=surface(t2);
draw(s2,blue+opacity(.6),light=nolight);
\end{asy}
\end{document}

enter image description here

ADDENDUM: It is very easy to shade one curved triangle.

\documentclass{article}
\usepackage{asymptote}
\begin{document}
\begin{asy}[width=\textwidth]

settings.render=6;
settings.prc=false;
import three;
import graph3;
import grid3;
currentprojection=obliqueX;

pen thickblack = black+0.75;
real axislength = 1.0;
draw(L=Label("$x$", position=Relative(1.1), align=SW), O--axislength*X,thickblack, Arrow3); 
draw(L=Label("$y$", position=Relative(1.1), align=E), O--axislength*Y,thickblack, Arrow3); 
draw(L=Label("$z$", position=Relative(1.1), align=N), O--axislength*Z,thickblack, Arrow3); 

label("$a$", (0.5,0,0), align=NW);
label("$a$", (0,0.5,0), align=NE);
label("$a$", (0,0,0.5), align=NW);

real a=0.5;

draw(O--expi(pi/2,pi/4),black+0.25);
draw(arc(c=O, a*Y, a*Z), blue);
draw(arc(c=O, a*X, a*Z), red);

dot((a,a,0)); 

draw((0,a,0)--(a,a,0),blue);
draw((a,a,0)--(a,0,0),red);
draw((0,0,a)--(0,0.9,a),red);
draw((a,0,0)--(a,0.9,0),red);
draw(arc(c=(0,0.8,0),(a,0.8,0), (0,0.8,a)), red);

draw((a,a,0)--(0.9,a,0),blue);
draw((0,0,a)--(0.9,0,a),blue);

triple f(real t) {
    return (a*cos(t),a*cos(t),a*sin(t));
}

path3 ellarc = graph(f, 0, pi/2, operator ..,n=101); 
path3 ellarcp = graph(f,  pi/2,0, operator ..,n=101); 

draw(ellarc,orange);

path3 t1=((0,0,0) -- (0,a,0) -- (a,a,0) -- cycle);
surface s1=surface(t1);
draw(s1,red+opacity(.6),light=nolight);

path3 t2=((0,0,0) -- (a,0,0) -- (a,a,0) -- cycle);
surface s2=surface(t2);
draw(s2,blue+opacity(.6),light=nolight);


path3 ec2 = ( (ellarc) .. arc(c=O, a*Z, a*X)-- cycle); 
surface sec2=surface(ec2); 
draw(sec2,cyan+opacity(.5),light=nolight);

//path3 ec1 = ( arc(c=O, a*Y, a*Z) -- (ellarcp) -- cycle); 
//surface sec1=surface(ec1); 
//draw(sec1,green+opacity(.5),light=nolight); 


\end{asy}
\end{document}

enter image description here

However, I fail to get a precise fill of the other curved triangle. I tried reverting the orientation and so on, nothing worked, I guess I am just not experienced enough. However, as this is not part of the original question, I'd like to encourage you to ask a new question on this.

  • 1
    Very nice! Thanks a lot! By the way, I am trying to apply distinct patterns to spherical triangles [(a,a,0),(a,0,0),(0,0,a),(a,a,0)] and [(a,a,0),(0,a,0),(0,0,a),(a,a,0)]. I tried this code:

    path3 ec1 = ((a,a,0) .. (ellarc) .. (arc(0,a,0)-- cycle); surface sec1=surface(ec1); draw(sec1,green+opacity(.5),light=nolight);

    path3 ec2 = ((a,a,0) .. (ellarc) .. (arc(a,0,0)-- cycle); surface sec2=surface(ec2); draw(sec2,cyan+opacity(.5),light=nolight);

    but it is not working. I do not know why. I am doing something wrong, of course. Could you help me?

    – Natanael Martins Neves Apr 12 '20 at 15:26
  • @NatanaelMartinsNeves I didn't try it out but in path3 ec1 = ((a,a,0) .. (ellarc) .. (arc(0,a,0)-- cycle); there are three opening but only two closing parentheses. Can you try to make the parentheses match? –  Apr 12 '20 at 15:29
  • Yes, I have already made the parentheses match, but it still not working. – Natanael Martins Neves Apr 12 '20 at 15:41
  • @NatanaelMartinsNeves For instance, path3 ec2 = ( (ellarc) .. arc(c=O, a*Z, a*X)-- cycle); surface sec2=surface(ec2); draw(sec2,cyan+opacity(.5),light=nolight); works. For some reason the other triangle seems to be more tricky, though. –  Apr 12 '20 at 15:45