Official Asymptote example – flow

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 10 h 57 min

Figure 0071
(Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
defaultpen(1.0);

size(0,150,IgnoreAspect);

real arrowsize=4mm;
real arrowlength=2arrowsize;

typedef path vector(real);

// Return a vector interpolated linearly between a and b.
vector vector(pair a, pair b) {
  return new path(real x) {
    return (0,0)--arrowlength*interp(a,b,x);
  };
}

real f(real x) {return 1/x;}

real epsilon=0.5;
path g=graph(f,epsilon,1/epsilon);

int n=3;
draw(g);
xaxis("$x$");
yaxis("$y$");

add(vectorfield(vector(W,W),g,n,true));
add(vectorfield(vector(NE,NW),(0,0)--(point(E).x,0),n,true));
add(vectorfield(vector(NE,NE),(0,0)--(0,point(N).y),n,true));


Étiquettes :


Official Asymptote example – slopefield1

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

Figure 0206
(Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */
    
import slopefield;

size(200);

real func(real x) {return 2x;}
add(slopefield(func,(-3,-3),(3,3),20,Arrow));
draw(curve((0,0),func,(-3,-3),(3,3)),red);



Étiquettes : ,


Official Asymptote example – vectorfield

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 17 h 57 min

Figure 0252
(Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(100);

pair a=(0,0);
pair b=(2pi,2pi);

path vector(pair z) {return (0,0)--(sin(z.x),cos(z.y));}

add(vectorfield(vector,a,b));

Étiquettes : ,


Official Asymptote example – vectorfield3

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 18 h 57 min

Figure 0251
(Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(12cm,0);

currentprojection=orthographic(1,-2,1);
currentlight=(1,-1,0.5);

real f(pair z) {return abs(z)^2;}

path3 gradient(pair z) {
  static real dx=sqrtEpsilon, dy=dx;
  return O--((f(z+dx)-f(z-dx))/2dx,(f(z+I*dy)-f(z-I*dy))/2dy,0);
}

pair a=(-1,-1);
pair b=(1,1);

triple F(pair z) {return (z.x,z.y,0);}

add(vectorfield(gradient,F,a,b,red));

draw(surface(f,a,b,Spline),gray+opacity(0.5));

xaxis3(XY()*"$x$",OutTicks(XY()*Label));
yaxis3(XY()*"$y$",InTicks(YX()*Label));
zaxis3("$z$",OutTicks);

Étiquettes : ,


Official Asymptote example – vectorfieldsphere

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

Figure 0253
(Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(12cm);

currentprojection=orthographic(1,-2,1);
currentlight=(1,-1,0.5);

triple f(pair z) {return expi(z.x,z.y);}

path3 vector(pair z) {
  triple v=f(z);
  return O--(v.y,v.z,v.x);
}

add(vectorfield(vector,f,(0,0),(pi,2pi),10,0.25,red,render(merge=true)));

draw(unitsphere,gray+opacity(0.5),render(compression=0,merge=true));

Étiquettes : , , ,