# Is there a good tutorial for Asymptote?

I'm trying to do some figures with asymptote, which is new to me and every step is a painful trial an error. I especially need to use the `arc` command in 3D:

``````path3 arc(triple c, real r, real theta1, real phi1, real theta2, real phi2,
triple normal=O);
``````

But I can't figure how to select the angle. I read the documentation, but it hasn't help me. Any good tutorials?

• Commented Jul 23, 2013 at 14:57
• @SeanAllred Yes, but this is really basic and doesn't help me with the 3D `arc` command. Commented Jul 23, 2013 at 15:00
• Other than the documentation, often times this stuff is exactly by trial and error. You learn as you go. Perhaps you can apply a transformation to the entire section of the image? Commented Jul 23, 2013 at 15:07
• @SeanAllred: Perhaps the reason is that Asymptote has no good tutorial to compare with the tutorials in the tikz manual. Commented Aug 4, 2013 at 13:50
• I have written a tutorial that may be found at math.uchicago.edu/~cstaats/Charles_Staats_III/…. I'm not posting it as an answer because I have yet to say anything about three-dimensional images, but the discussion of arcs on pages 12-14 may nevertheless be useful. Commented Nov 8, 2013 at 19:42

From what I understand, arcs are defined mostly in two different ways:

1. path3 arc=arc(center,starting point,end point)
2. path3 arc=arc(center,theta1,phi1,theta2,phi2)

In the first case, the starting and end points are defined through Cartesian coordinates, while in the second case, they are defined through spherical coordinates. I think there are other ways when you know the normal of the plane in which the arc is drawn. Have a look at the code below and the corresponding figure.

``````// command line compilation: asy -f pdf MyFig
if(!settings.multipleView) settings.batchView=false;

import solids;
import three;
settings.render=0;
settings.prc=false;
currentprojection=perspective(1,1,1);
size(8cm);

real r=.4, ar=.5;

// sphere to visualize the various arcs
revolution S=sphere(O,r);
draw(S.silhouette(),black+linewidth(.5pt));
draw(S,black+linewidth(.5pt));

// axes
draw((0,0,0)--(0,ar,0),linewidth(0.5pt),Arrow3);
draw((0,0,0)--(0,0,ar),linewidth(0.5pt),Arrow3);
draw((0,0,0)--(ar,0,0),linewidth(0.5pt),Arrow3);

///////////////////////////////////////////////////////////
/////////////////////// blue arc //////////////////////////
///////////////////////////////////////////////////////////
// starting point in spherical coordinates
real theta=0, phi=0;
real x1=r*sin(theta)*cos(phi), y1=r*sin(theta)*sin(phi), z1=r*cos(theta);
// end point
real theta=pi/2, phi=0;
real x2=r*sin(theta)*cos(phi), y2=r*sin(theta)*sin(phi), z2=r*cos(theta);
draw(arc((0,0,0),(x1,y1,z1),(x2,y2,z2)),blue+linewidth(1pt),ArcArrow3);

///////////////////////////////////////////////////////////
////////////////////// green arc //////////////////////////
///////////////////////////////////////////////////////////
// starting point
real theta=0, phi=3*pi/4;
real x1=r*sin(theta)*cos(phi),y1=r*sin(theta)*sin(phi),z1=r*cos(theta);
// end point
real theta=pi/3, phi=3*pi/4;
real x2=r*sin(theta)*cos(phi), y2=r*sin(theta)*sin(phi),z2=r*cos(theta);
draw(arc((0,0,0),(x1,y1,z1),(x2,y2,z2)),green+linewidth(1pt),ArcArrow3);

///////////////////////////////////////////////////////////
/////////////////// other examples ////////////////////////
///////////////////////////////////////////////////////////
// arc(center,starting point,end point))
draw(arc((0,0,0),(0,r,0),(0,r*cos(pi/4),r*sin(pi/4))),red+linewidth(1pt),ArcArrow3);