Asymptote/Command/graph/vectorfield
Appearance
Draw a vectorfield along a path:
void vectorfield(picture pic=<default>, path g, int n, path vector(real), real arrowsize=<default>, real arrowlength=<default>, pen p=<default>);
Example:
import graph; defaultpen(0.5); size(400,200); real arrowsize=1.5mm; real arrowlength=15; vector ampere=new path(real x){ return (0,0)--arrowlength*(-1)*(2-3*cos(2*pi*x)^2)*(cos(2*pi*x),sin(2*pi*x)) ; }; vector tait=new path(real x){ return (0,0)--arrowlength*(-1)*(-cos(2*pi*x),sin(2*pi*x)); }; vector grassmann=new path(real x){ return (0,0)--arrowlength*(-1)*(0,sin(2*pi*x)); }; path p=unitcircle; int n=24; pen celmpen=currentpen+2; path cell=(-0.4,0)--(0.4,0); draw(p); vectorfield(p,n,ampere,arrowsize); draw(cell,celmpen,Arrow(4)); draw(shift(0,-1)*cell,celmpen,Arrow(4)); dot((0,0)); dot((0,-1)); label("Amp\`ere",(0,-1),S); p=shift(3,0)*p; cell=shift(3,0)*cell; draw(p); vectorfield(p,n,grassmann,arrowsize); dot((3,0)); dot((3,-1)); label("Grassmann",(3,-1),S); draw(cell,celmpen,Arrow(4)); draw(shift(0,-1)*cell,celmpen,Arrow(4)); p=shift(3,0)*p; cell=shift(3,0)*cell; draw(p); vectorfield(p,n,tait,arrowsize); dot((6,0)); dot((6,-1)); label("Tait",(6,-1),S); draw(cell,celmpen,Arrow(4)); draw(shift(0,-1)*cell,celmpen,Arrow(4));