[Tex/LaTex] Adding arrows on 3D curves in Asymptote

3darrowsasymptotegraphics

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.

Best Answer

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

enter image description here

\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}
Related Question