0

How can i draw a vector field like this?enter image description here

3

Yes, I know this question has TikZ in the title. Nevertheless I'd like to present an asymptote solution since IMHO this does a much better job on real 3D graphics. Compile with pdflatex -shell-escape.

\documentclass[border=5pt]{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=AsyVF}
import graph3;
import three;
import solids;

size(6cm,8cm);
settings.render = 4;
currentprojection = perspective((9,4,4), up=Z,autoadjust=true);//,autoadjust=true
currentlight=(2,15,5);

// coordinate axes 
draw(-Z -- 2X-Z,L=Label("$x$",position=EndPoint));
draw(-Z -- 3Y-Z,L=Label("$y$", position=EndPoint));
draw(-Z -- 2Z,L=Label("$z$", position=EndPoint));

for (int irun=1; irun<=20; irun+=1)
{
real myx = sin(irun*2*pi/20);
real myy = -0.5;
real myz = cos(irun*2*pi/20);
draw(myx*X+myy*Y+myz*Z -- myx*X+myy*Y+myz*Z+(0.8+0.3*sin(irun*2*pi/10))*Y, arrow=Arrow3(), p=linewidth(0.5pt),light=currentlight);
//draw(shift(myx*X+myy*Y+myz*Z)*scale3(0.05)*unitsphere,lightgray,light=currentlight);
}

for (int irun=1; irun<=20; irun+=1)
{
real myx = sin(irun*2*pi/20);
real myy = 0.8;
real myz = cos(irun*2*pi/20);
draw(myx*X+myy*Y+myz*Z -- 1.2*myx*X+myy*Y+1.2*myz*Z+1.1*Y, arrow=Arrow3(), p=linewidth(0.5pt),light=currentlight);
//draw(shift(myx*X+myy*Y+myz*Z)*scale3(0.05)*unitsphere,lightgray,light=currentlight);
}

\end{asypicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.