# Adding arrows on 3D curves in Asymptote

I am trying to plot (1D) trajectories in 3D with Asymptote (because I am also plotting surfaces with opacity and do not want to use hacks for hidden surfaces).

Each curve is defined by points in an external csv file. The following minimal example for one curve works properly (given a data.csv file of course):

\documentclass[margin=1cm]{standalone}
\usepackage{asymptote}

\begin{document}
\begin{asy}
settings.outformat="pdf";
settings.prc=false;
settings.render=0;

import graph3;
currentprojection=orthographic(1,-2,4);
currentlight=(1,-1,1);
size3(200,200,80,IgnoreAspect);

file in=input("data.csv").line().csv();
real[][] a=in.dimension(0,0);
a=transpose(a);

real[] x=a[0];
real[] y=a[1];
real[] z=a[2];

draw(graph(x,y,z),blue,currentlight);

xaxis3(XY()*"$x_1$",Arrow3);
yaxis3(XY()*"$x_2$",Arrow3);
zaxis3("$y$",Arrow3);
\end{asy}
\end{document}


Now, I would like to add arrows on the curve to show the direction of the trajectory.

It seems if the trajectory was a path, I could do it quite easily using something such as draw(pathname,Arrow(Relative(0.7)));. But I can't manage to "convert" my graph as a curve to do so.

Any ideas how I could add arrows?

I cannot manage to plot arrows on the curves.

• In this case you need to use Arrow3 instead of just Arrow: draw(graph(x,y,z),blue,Arrow3(Relative(0.7)),currentlight); – g.kov Aug 6 '14 at 21:40

In this case you need to use Arrow3 instead of just Arrow. With a simple data file it gives

\begin{filecontents*}{data.csv}
0.81,0.59,0.1
0.31,0.95,0.2
-0.31,0.95,0.3
-0.81,0.59,0.4
-1,0,0.5
-0.81,-0.59,0.6
-0.31,-0.95,0.7
0.31,-0.95,0.8
0.81,-0.59,0.9
1,0,1
\end{filecontents*}
\documentclass[margin=1cm]{standalone}
\usepackage{asymptote}

\begin{document}
\begin{asy}
settings.outformat="pdf";
settings.prc=false;
settings.render=0;

import graph3;
currentprojection=orthographic(1,-2,4);
currentlight=(1,-1,1);
size3(200,200,80,IgnoreAspect);

file in=input("data.csv").line().csv();
real[][] a=in.dimension(0,0);
a=transpose(a);

real[] x=a[0];
real[] y=a[1];
real[] z=a[2];

draw(graph(x,y,z,operator..),blue,Arrow3(Relative(0.7)),currentlight);

xaxis3(XY()*"$x_1$",Arrow3);
yaxis3(XY()*"$x_2$",Arrow3);
zaxis3("$y$",Arrow3);
\end{asy}
\end{document}

• TY. Why did you add the operator.. in draw(graph(...),...)? – anderstood Aug 6 '14 at 22:02
• @anderstood: operator.. was used instead of the default operator-- just to make a smooth-looking curve from the included small example data file. Otherwise it needs to be used with care, since the spline can go wild sometimes. – g.kov Aug 6 '14 at 22:11
• Do you know how to adjust the size of the arrow tip? – Chris Chudzicki Feb 8 '15 at 21:57
• xaxis3(XY()*"$x_1$",Arrow3(size=3bp)); – g.kov Feb 9 '15 at 5:47