# [Tex/LaTex] good tutorial for Asymptote

arcasymptote

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?

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