Asymptote using graph.asy – fig0250

Category: Asymptote,Examples 2D,graph.asyPh. Ivaldi @ 2 h 10 min

Figure 0024
(Compiled with Asymptote version 2.14svn-r5318)
    
size(10cm,0);
import contour;
import graph;

xlimits( -3, 3);
ylimits( -3, 3);
yaxis( "$y$" , Ticks());
xaxis( "$x$", Ticks());

real f(real x, real y) {return x*y;}

draw(contour(f,(-3,-3),(3,3),new real[] {1}));

Étiquettes : , , , ,


Asymptote using graph.asy – fig0260

Category: Asymptote,Examples 2D,graph.asyPh. Ivaldi @ 3 h 10 min

Figure 0025
(Compiled with Asymptote version 2.14svn-r5318)
    
size(10cm,0);
import contour;
import stats;
import graph;

xlimits( -5, 5);  
ylimits( -4, 5);  
yaxis( "$y$" , Ticks(Label(currentpen+fontsize(8),align=E)));
xaxis( "$x$", Ticks(Label(currentpen+fontsize(8))));

real f(real x, real y) {return x^2-x-y^2+3y-6;}

int min=-5,
  max=5,
  n=max-min+1;

real[] value=sequence(min,max);

pen[] p=sequence(new pen(int i) {
    return (value[i] >= 0 ? solid : dashed) + 
    (value[i] >= 0 ? (value[i]/max)*red : (value[i]/min)*blue) + 
    fontsize(4);
  },n);

Label[] Labels=sequence(new Label(int i) {
    return Label(value[i] != 0 ? (string) value[i] : "",Relative(unitrand()),(0,0),
                 UnFill(1bp));
  },n);

draw(Labels,contour(f,(-5,-5),(5,5),value),p);

Étiquettes : , , , , ,


Asymptote using graph3.asy – fig0080

Category: Asymptote,Examples 3D,graph3.asyPh. Ivaldi @ 10 h 11 min

Figure 0008
(Compiled with Asymptote version 2.14svn-r5318)
    
// Adapted from the documentation of Asymptote.
import graph3;
import contour;
texpreamble("\usepackage{icomma}");

size3(12cm,12cm,8cm,IgnoreAspect);

real sinc(pair z) {
  real r=2pi*abs(z);
  return r != 0 ? sin(r)/r : 1;
}

limits((-2,-2,-0.2),(2,2,1.2));
currentprojection=orthographic(1,-2,0.5);

xaxis3(rotate(90,X)*"$x$",
       Bounds(Min,Min),
       OutTicks(rotate(90,X)*Label, endlabel=false));

yaxis3("$y$", Bounds(Max,Min), InTicks(Label));
zaxis3("$z$", Bounds(Min,Min), OutTicks());

draw(lift(sinc,contour(sinc,(-2,-2),(2,2),new real[] {0})), bp+0.8*red);
draw(surface(sinc,(-2,-2),(2,2),nx=100, Spline), lightgray);

draw(scale3(2*sqrt(2))*unitdisk, paleyellow+opacity(0.25), nolight);
draw(scale3(2*sqrt(2))*unitcircle3, 0.8*red);

Étiquettes : , , , ,


Asymptote using graph3.asy – fig0090

Category: Asymptote,Examples 3D,graph3.asyPh. Ivaldi @ 11 h 11 min

Figure 0009
(Compiled with Asymptote version 2.14svn-r5318)
    
size(12cm,0,false);
import graph3;
import contour;
import palette;

texpreamble("\usepackage{icomma}");

real f(pair z) {return z.x*z.y*exp(-z.x);}

currentprojection=orthographic(-2.5,-5,1);

draw(surface(f,(0,0),(5,10),20,Spline),palegray,bp+rgb(0.2,0.5,0.7));

scale(true);

xaxis3(Label("$x$",MidPoint),OutTicks());
yaxis3(Label("$y$",MidPoint),OutTicks(Step=2));
zaxis3(Label("$z=xye^{-x}$",Relative(1),align=2E),Bounds(Min,Max),OutTicks);

real[] datumz={0.5,1,1.5,2,2.5,3,3.5};

Label[] L=sequence(new Label(int i) {
    return YZ()*(Label(format("$z=%g$",datumz[i]),
                       align=2currentprojection.vector()-1.5Z,Relative(1)));
  },datumz.length);

pen fontsize=bp+fontsize(10);
draw(L,lift(f,contour(f,(0,0),(5,10),datumz)),
     palette(datumz,Gradient(fontsize+red,fontsize+black)));

Étiquettes : , , , , ,


Asymptote using graph3.asy – fig0100

Category: Asymptote,Examples 3D,graph3.asyPh. Ivaldi @ 12 h 11 min

Figure 0010
(Compiled with Asymptote version 1.92svn-r4817)
    
// From documentation of Asymptote
import graph;
import palette;
import contour;
texpreamble("\usepackage{icomma}");

size(10cm,10cm,IgnoreAspect);

pair a=(0,0);
pair b=(5,10);

real fz(pair z) {
  return z.x*z.y*exp(-z.x);
}
real f(real x, real y) {return fz((x,y));}

int N=200;
int Divs=10;
int divs=2;

defaultpen(1bp);
pen Tickpen=black;
pen tickpen=gray+0.5*linewidth(currentpen);
pen[] Palette=BWRainbow();

scale(false);

bounds range=image(f,Automatic,a,b,N,Palette);

xaxis("$x$",BottomTop,LeftTicks(pTick=grey, ptick=invisible, extend=true));
yaxis("$y$",LeftRight,RightTicks(pTick=grey, ptick=invisible, extend=true));

// Major contours
real[] Cvals;
Cvals=sequence(11)/10 * (range.max-range.min) + range.min;
draw(contour(f,a,b,Cvals,N,operator ..),Tickpen);

// Minor contours
real[] cvals;
real[] sumarr=sequence(1,divs-1)/divs * (range.max-range.min)/Divs;
for (int ival=0; ival < Cvals.length-1; ++ival)
    cvals.append(Cvals[ival]+sumarr);
draw(contour(f,a,b,cvals,N,operator ..),tickpen);

palette("$f(x,y)=xye^{-x}$",range,point(NW)+(0,1),point(NE)+(0,0.25),Top,Palette,
        PaletteTicks(N=Divs,n=divs,Tickpen,tickpen));

Étiquettes : , , , , ,


Asymptote using graph3.asy – fig0110

Category: Asymptote,Examples 3D,graph3.asyPh. Ivaldi @ 13 h 11 min

Figure 0011
(Compiled with Asymptote version 2.14svn-r5318)
    
import graph3;
import palette;
import contour;
size(14cm,0);
currentprojection=orthographic(-1,-1.5,0.75);
currentlight=(-1,0,5);

real a=1, b=1;
real f(pair z) { return a*(6+sin(z.x/b)+sin(z.y/b));}
real g(pair z){return f(z)-6a;}

// The axes
limits((0,0,4a),(14,14,8a));
xaxis3(Label("$x$",MidPoint),OutTicks());
yaxis3(Label("$y$",MidPoint),OutTicks(Step=2));
ticklabel relativelabel()
{
  return new string(real x) {return (string)(x-6a);};
}
zaxis3(Label("$z$",Relative(1),align=2E),Bounds(Min,Max),OutTicks(relativelabel()));

// The surface
surface s=surface(f,(0,0),(14,14),100,Spline);

pen[] pens=mean(palette(s.map(zpart),Gradient(yellow,red)));

// Draw the surface
draw(s,pens);
// Project the surface onto the XY plane.
draw(planeproject(unitsquare3)*s,pens,nolight);

// Draw contour for "datumz"
real[] datumz={-1.5, -1, 0, 1, 1.5};
guide[][] pl=contour(g,(0,0),(14,14),datumz);
for (int i=0; i < pl.length; ++i)
  for (int j=0; j < pl[i].length; ++j)
    draw(path3(pl[i][j]));

// Draw the contours on the surface
draw(lift(f,pl));

if(!is3D())
  shipout(bbox(3mm,Fill(black)));

Étiquettes : , , , , , , , , , ,


Official Asymptote example – magnetic

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

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

size(200,0);
currentprojection=orthographic((6,8,2),up=Y);

real a(real z) {return (z < 6) ? 1 : exp((abs(z)-6)/4);}
real b(real z) {return 1/a(z);}
real B(real z) {return 1-0.5cos(pi*z/10);}

real f(real x, real y, real z) {return 0.5B(z)*(a(z)*x^2+b(z)*y^2)-1;}

draw(surface(contour3(f,(-2,-2,-10),(2,2,10),10)),blue+opacity(0.75),
     render(merge=true));

xaxis3(Label("$x$",1),red);
yaxis3(Label("$y$",1),red);
zaxis3(Label("$z$",1),red);

Étiquettes : , , ,


Official Asymptote example – multicontour

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

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

size(200);

real f(real x, real y) {return x^2-y^2;}
int n=10;
real[] c=new real[n];
for(int i=0; i < n; ++i) c[i]=(i-n/2)/n;

pen[] p=sequence(new pen(int i) {
    return (c[i] >= 0 ? solid : dashed)+fontsize(6pt);
  },c.length);

Label[] Labels=sequence(new Label(int i) {
    return Label(c[i] != 0 ? (string) c[i] : "",Relative(unitrand()),(0,0),
                 UnFill(1bp));
  },c.length);

draw(Labels,contour(f,(-1,-1),(1,1),c),p);

Étiquettes : , , , ,


Official Asymptote example – onecontour

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

Figure 0152
(Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */
    
import contour;
size(75);

real f(real a, real b) {return a^2+b^2;}
draw(contour(f,(-1,-1),(1,1),new real[] {1}));

Étiquettes : ,


Official Asymptote example – sinc

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

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

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

size(12cm,0);

real sinc(pair z) {
  real r=2pi*abs(z);
  return r != 0 ? sin(r)/r : 1;
}

render render=render(compression=Low,merge=true);

draw(lift(sinc,contour(sinc,(-2,-2),(2,2),new real[] {0})),red);
draw(surface(sinc,(-2,-2),(2,2),Spline),lightgray,render);

draw(scale3(2*sqrt(2))*unitdisk,paleyellow+opacity(0.25),nolight,render);
draw(scale3(2*sqrt(2))*unitcircle3,red,render);

xaxis3("$x$",Bounds,InTicks);
yaxis3("$y$",Bounds,InTicks(beginlabel=false));
zaxis3("$z$",Bounds,InTicks);

Étiquettes : , , , ,


Animation with Asymptote – fig0010

Category: Animation,AsymptotePh. Ivaldi @ 8 h 20 min

Figure 0001
(Compiled with Asymptote version 1.43)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import contour3;
import animate;
// settings.tex="pdflatex";
// settings.outformat="pdf";

size(10cm);
currentprojection=orthographic(15,8,10);
animation A;
A.global=false;

typedef real fct3(real,real,real);
fct3 F(real t)
{
  return new real(real x, real y, real z){return x^2+y^2-t*z^2+t-1;};
}

int n=15;
picture pic;
real tmin=0.1, tmax=2;
real step=(tmax-tmin)/n;
draw(box((-5,-5,-5),(5,5,5)));
for (int i=0; i < n; ++i) {
  save();
  draw(surface(contour3(F(tmin+i*step),(-5,-5,-5),(5,5,5),15)),lightblue);
  pic.erase();
  add(pic,bbox(5mm,FillDraw(lightyellow)));
  A.add(pic);
  restore();
}

A.movie();

Étiquettes : , , ,