Official Asymptote example – BezierPatch

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

Figure 0001
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

size(10cm);
currentlight=(0,0,1);

surface s=surface(patch(new triple[][] {
      {(0,0,0),(1,0,0),(1,0,0),(2,0,0)},
      {(0,1,0),(1,0,1),(1,0,1),(2,1,0)},
      {(0,1,0),(1,0,-1),(1,0,-1),(2,1,0)},
      {(0,2,0),(1,2,0),(1,2,0),(2,2,0)}}));

draw(s,yellow);
draw(s.s[0].vequals(0.5),squarecap+2bp+blue,currentlight);
draw(s.s[0].uequals(0.5),squarecap+2bp+red,currentlight);

Mots-clefs : , , ,


Official Asymptote example – BezierSurface

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 8 h 57 min

Figure 0002
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

string viewpoint="{-24.132780075073242 7.2992024421691895 7.695427417755127}{0.8244762420654297 -0.563306450843811 0.0540805421769619}{35.62141440580922}{17.392748820528627}{}";

//viewpoint=getstring("viewpoint",viewpoint);
currentprojection=perspective(viewpoint);

currentlight=White;

triple[][][] P={{
    {(-1.6,0,1.875),(-1.6,-0.3,1.875),(-1.5,-0.3,2.1),(-1.5,0,2.1)},
    {(-2.3,0,1.875),(-2.3,-0.3,1.875),(-2.5,-0.3,2.1),(-2.5,0,2.1)},
    {(-2.7,0,1.875),(-2.7,-0.3,1.875),(-3,-0.3,2.1),(-3,0,2.1)},
    {(-2.7,0,1.65),(-2.7,-0.3,1.65),(-3,-0.3,1.65),(-3,0,1.65)}
  },{
    {(-2.7,0,1.65),(-2.7,-0.3,1.65),(-3,-0.3,1.65),(-3,0,1.65)},
    {(-2.7,0,1.425),(-2.7,-0.3,1.425),(-3,-0.3,1.2),(-3,0,1.2)},
    {(-2.5,0,0.975),(-2.5,-0.3,0.975),(-2.65,-0.3,0.7275),(-2.65,0,0.7275)},
    {(-2,0,0.75),(-2,-0.3,0.75),(-1.9,-0.3,0.45),(-1.9,0,0.45)}
  },{
    {(-2.7,0,1.65),(-2.7,0.3,1.65),(-3,0.3,1.65),(-3,0,1.65)},
    {(-2.7,0,1.875),(-2.7,0.3,1.875),(-3,0.3,2.1),(-3,0,2.1)},
    {(-2.3,0,1.875),(-2.3,0.3,1.875),(-2.5,0.3,2.1),(-2.5,0,2.1)},
    {(-1.6,0,1.875),(-1.6,0.3,1.875),(-1.5,0.3,2.1),(-1.5,0,2.1)}
  },{
    {(-2,0,0.75),(-2,0.3,0.75),(-1.9,0.3,0.45),(-1.9,0,0.45)},
    {(-2.5,0,0.975),(-2.5,0.3,0.975),(-2.65,0.3,0.7275),(-2.65,0,0.7275)},
    {(-2.7,0,1.425),(-2.7,0.3,1.425),(-3,0.3,1.2),(-3,0,1.2)},
    {(-2.7,0,1.65),(-2.7,0.3,1.65),(-3,0.3,1.65),(-3,0,1.65)}
  }};

picture pic;
size(pic,15cm);
size3(pic,10cm);
draw(pic,surface(P),blue);

add(embed("label",pic),(0,0),N);
label(cameralink("label"),(0,0),10S,fontsize(24pt));

Mots-clefs : , , ,


Official Asymptote example – Bode

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 9 h 57 min

Figure 0003
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
texpreamble("\def\Arg{\mathop {\rm Arg}\nolimits}");

size(10cm,5cm,IgnoreAspect);

real ampl(real x) {return 2.5/(1+x^2);}
real phas(real x) {return -atan(x)/pi;}

scale(Log,Log);
draw(graph(ampl,0.01,10));
ylimits(0.001,100);

xaxis("$\omega\tau_0$",BottomTop,LeftTicks);
yaxis("$|G(\omega\tau_0)|$",Left,RightTicks);

picture q=secondaryY(new void(picture pic) {
    scale(pic,Log,Linear);
    draw(pic,graph(pic,phas,0.01,10),red);
    ylimits(pic,-1.0,1.5);
    yaxis(pic,"$\Arg G/\pi$",Right,red,
          LeftTicks("$% #.1f$",
                    begin=false,end=false));
    yequals(pic,1,Dotted);
  });
label(q,"(1,0)",Scale(q,(1,0)),red);
add(q);


Mots-clefs : , , ,


Official Asymptote example – CAD1

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 10 h 57 min

Figure 0004
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import CAD;

sCAD cad=sCAD.Create();

// Freehand line
draw(g=cad.MakeFreehand(pFrom=(3,-1)*cm,(6,-1)*cm),
     p=cad.pFreehand);

// Standard measurement lines
draw(g=box((0,0)*cm,(1,1)*cm),p=cad.pVisibleEdge);
cad.MeasureParallel(L="$\sqrt{2}$",
                    pFrom=(0,1)*cm,
                    pTo=(1,0)*cm,
                    dblDistance=-15mm);

// Label inside,shifted to the right; arrows outside
draw(g=box((2,0)*cm,(3,1)*cm),p=cad.pVisibleEdge);
cad.MeasureParallel(L="1",
                    pFrom=(2,1)*cm,
                    pTo=(3,1)*cm,
                    dblDistance=5mm,
                    dblLeft=5mm,
                    dblRelPosition=0.75);

// Label and arrows outside
draw(g=box((5,0)*cm,(5.5,1)*cm),p=cad.pVisibleEdge);
cad.MeasureParallel(L="0.5",
                    pFrom=(5,1)*cm,
                    pTo=(5.5,1)*cm,
                    dblDistance=5mm,
                    dblLeft=10mm,
                    dblRelPosition=-1);

// Small bounds,asymmetric measurement line
draw(g=box((7,0)*cm,(7.5,1)*cm),p=cad.pVisibleEdge);
cad.MeasureParallel(L="0.5",
                    pFrom=(7,1)*cm,
                    pTo=(7.5,1)*cm,
                    dblDistance=5mm,
                    dblLeft=2*cad.GetMeasurementBoundSize(bSmallBound=true),
                    dblRight=10mm,
                    dblRelPosition=2,
                    bSmallBound=true);

Mots-clefs :


Official Asymptote example – CDlabel

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 11 h 57 min

Figure 0005
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(11.7cm,11.7cm);
asy(nativeformat(),"logo");
fill(unitcircle^^(scale(2/11.7)*unitcircle),
     evenodd+rgb(124/255,205/255,124/255));
label(scale(1.1)*minipage(
"\centering\scriptsize \textbf{\LARGE {\tt Asymptote}\\
\smallskip
\small The Vector Graphics Language}\\
\smallskip
\textsc{Andy Hammerlindl, John Bowman, and Tom Prince}
http://asymptote.sourceforge.net\\
",8cm),(0,0.6));
label(graphic("logo."+nativeformat(),"height=7cm"),(0,-0.22));
clip(unitcircle^^(scale(2/11.7)*unitcircle),evenodd);

Mots-clefs : , , ,


Official Asymptote example – Coons

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 12 h 57 min

Figure 0006
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);

pen[] p={red,green,blue,magenta};
path g=(0,0){dir(45)}..(1,0)..(1,1)..(0,1)..cycle;
tensorshade(g,p);
dot(g);

Mots-clefs : , ,


Official Asymptote example – GaussianSurface

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 13 h 57 min

Figure 0007
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(200,0);

currentprojection=perspective(10,8,4);

real f(pair z) {return 0.5+exp(-abs(z)^2);}

draw((-1,-1,0)--(1,-1,0)--(1,1,0)--(-1,1,0)--cycle);

draw(arc(0.12Z,0.2,90,60,90,25),ArcArrow3);

surface s=surface(f,(-1,-1),(1,1),nx=5,Spline);

xaxis3(Label("$x$"),red,Arrow3);
yaxis3(Label("$y$"),red,Arrow3);
zaxis3(XYZero(extend=true),red,Arrow3);

draw(s,lightgray,meshpen=black+thick(),nolight);

label("$O$",O,-Z+Y,red);

Mots-clefs : , ,


Official Asymptote example – Gouraud

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 14 h 57 min

Figure 0008
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);

pen[] p={red,green,blue,magenta};
pair[] z={(-1,0),(0,0),(0,1),(1,0)};
int[] edges={0,0,0,1};
gouraudshade(z[0]--z[2]--z[3]--cycle,p,z,edges);

draw(z[0]--z[1]--z[2]--cycle);
draw(z[1]--z[3]--z[2],dashed);

dot(Label,z[0],W);
dot(Label,z[1],S);
dot(Label,z[2],N);
dot(Label,z[3],E);

label("0",z[0]--z[1],S,red);
label("1",z[1]--z[2],E,red);
label("2",z[2]--z[0],NW,red);

Mots-clefs : ,


Official Asymptote example – Gouraudcontour

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 15 h 57 min

Figure 0009
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
import palette;
import contour;

size(200);

int n=100;

real[] x=new real[n];
real[] y=new real[n];
real[] f=new real[n];

real F(real a, real b) {return a^2+b^2;}

real r() {return 1.1*(rand()/randMax*2-1);}

for(int i=0; i < n; ++i) {
  x[i]=r();
  y[i]=r();
  f[i]=F(x[i],y[i]);
}

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

bounds range=image(x,y,f,Range(0,2),Palette);
draw(contour(pairs(x,y),f,new real[]{0.25,0.5,1},operator ..));

palette("$f(x,y)$",range,point(NW)+(0,0.5),point(NE)+(0,0.8),Top,Palette,
        PaletteTicks(Tickpen,tickpen));

Mots-clefs : , , ,


Official Asymptote example – HermiteSpline

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 16 h 57 min

Figure 0010
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(140mm,70mm,IgnoreAspect); 
scale(false); 
real[] x={1,3,4,5,6};
real[] y={1,5,2,0,4}; 

marker mark=marker(scale(1mm)*cross(6,false,r=0.35),red,Fill); 

draw(graph(x,y,Hermite),"Hermite Spline",mark);
xaxis("$x$",Bottom,LeftTicks(x)); 
yaxis("$y$",Left,LeftTicks); 
attach(legend(),point(NW),40S+30E,UnFill);


Mots-clefs : , , , ,


Official Asymptote example – Hobbycontrol

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 17 h 57 min

Figure 0011
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);
pair z0=(0,0);
pair z1=(0.5,3);
pair z2=(2,1);

path g=z0..z1..z2;

pair d0=dir(g,0);
pair d1=dir(g,1);
draw(Label("$\omega_0$",1),z0-d0..z0+d0,blue+dashed,Arrow);
draw(Label("$\omega_1$",1),z1-d1..z1+1.5d1,blue+dashed,Arrow);
draw(z0--interp(z0,z1,1.5),dashed);
draw(subpath(g,0,1),blue);
draw("$\theta$",arc(z0,0.4,degrees(z1-z0),degrees(d0)),red,Arrow,
     EndPenMargin);
draw("$\phi$",arc(z1,1.05,degrees(z1-z0),degrees(d1)),red,Arrow,
     EndPenMargin);

dot("$z_0$",z0,SW,red);
dot("$z_1$",z1,SE,red);

Mots-clefs : , , ,


Official Asymptote example – Hobbydir

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 18 h 57 min

Figure 0012
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);
pair z0=(0,0);
pair z1=(1,2);
pair z2=(2,1);

path g=z0..z1..z2;

label("$\ell_k$",z0--z1);
draw("$\ell_{k+1}$",z1--z2,dashed);
draw(z0--interp(z0,z1,1.5),dashed);
pair d1=dir(g,1);
draw(z1-d1..z1+d1,blue+dashed);
draw(g,blue);
draw(Label("$\theta_k$",0.4),arc(z1,0.4,degrees(z2-z1),degrees(d1)),blue,Arrow,
     EndPenMargin);
draw("$\phi_k$",arc(z1,0.4,degrees(d1),degrees(z1-z0),CCW),Arrow,
     EndPenMargin);

dot("$z_{k-1}$",z0,red);
dot("$z_k$",z1,NW,red);
dot("$z_{k+1}$",z2,red);

Mots-clefs : , , , ,


Official Asymptote example – Klein

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

Figure 0013
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(469pt);

viewportmargin=0;

currentprojection=perspective(
camera=(25.0851928432063,-30.3337528952473,19.3728775115443),
up=Z,
target=(-0.590622314050054,0.692357205025578,-0.627122488455679),
zoom=1,
autoadjust=false);

triple f(pair t) {
  real u=t.x;
  real v=t.y;
  real r=2-cos(u);
  real x=3*cos(u)*(1+sin(u))+r*cos(v)*(u < pi ? cos(u) : -1);
  real y=8*sin(u)+(u < pi ? r*sin(u)*cos(v) : 0);
  real z=r*sin(v);
  return (x,y,z);
}

surface s=surface(f,(0,0),(2pi,2pi),8,8,Spline);
draw(s,lightolive+white);

string lo="$\displaystyle u\in[0,\pi]: \cases{x=3\cos u(1+\sin u)+(2-\cos u)\cos u\cos v,\cr
y=8\sin u+(2-\cos u)\sin u\cos v,\cr
z=(2-\cos u)\sin v.\cr}$";

string hi="$\displaystyle u\in[\pi,2\pi]:\\\cases{x=3\cos u(1+\sin u)-(2-\cos u)\cos v,\cr
y=8\sin u,\cr
z=(2-\cos u)\sin v.\cr}$";

real h=0.0125;

draw(surface(xscale(-0.38)*yscale(-0.18)*lo,s,0,1.7,h));
draw(surface(xscale(0.26)*yscale(0.1)*rotate(90)*hi,s,4.9,1.4,h));
draw(s.uequals(0),blue+dashed);
draw(s.uequals(pi),blue+dashed);

currentpicture.add(new void(frame f, transform3 t, picture pic, projection P) {
    draw(f,invert(box(min(f,P),max(f,P)),P));
  });

Mots-clefs : , , , , ,


Official Asymptote example – NURBSsurface

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

Figure 0014
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

size(10cm);

currentprojection=perspective(40,40,50);

// Nonrational surface:
// udegree=3, vdegree=3, nu=5, nv=6;
real[] uknot={0,0,0,0,0.5,1,1,1,1};
real[] vknot={0,0,0,0,0.4,0.6,1,1,1,1};

triple[][] P={{
  (-31.2061,12.001,6.45082),
  (-31.3952,14.7353,6.53707),
  (-31.5909,21.277,6.70051),
  (-31.4284,25.4933,6.76745),
  (-31.5413,30.3485,6.68777),
  (-31.4896,32.2839,6.58385),
  },{
  (-28.279,12.001,7.89625),
  (-28.4187,14.7353,8.00954),
  (-28.5633,21.277,8.22422),
  (-28.4433,25.4933,8.31214),
  (-28.5266,30.3485,8.20749),
  (-28.4885,32.2839,8.07099),
  },{
  (-20,12.001,10.0379),
  (-20,14.7353,10.2001),
  (-20,21.277,10.5076),
  (-20,25.4933,10.6335),
  (-20,30.3485,10.4836),
  (-20,32.2839,10.2881),
  },{
  (-11.721,12.001,7.84024),
  (-11.5813,14.7353,7.95269),
  (-11.4367,21.277,8.16575),
  (-11.5567,25.4933,8.25302),
  (-11.4734,30.3485,8.14915),
  (-11.5115,32.2839,8.01367),
  },{
  (-8.79391,12.001,6.39481),
  (-8.60483,14.7353,6.48022),
  (-8.40905,21.277,6.64204),
  (-8.57158,25.4933,6.70832),
  (-8.45874,30.3485,6.62943),
  (-8.51041,32.2839,6.52653)
  }};

draw(P,uknot,vknot,new pen[] {red,green,blue,magenta});

// Rational Bezier patch:
// udegree=3, vdegree=3, nu=4, nv=4;
real[] uknot={0,0,0,0,1,1,1,1};
real[] vknot={0,0,0,0,1,1,1,1};
triple[][] P=scale3(20)*octant1.P;

// Optional weights:
real[][] weights=array(P.length,array(P[0].length,1.0));
weights[1][2]=0.5;

draw(P,uknot,vknot,weights,blue);

Mots-clefs : , , ,


Official Asymptote example – Pythagoras

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

Figure 0015
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,150);
import geometry;

real a=3;
real b=4;
real c=hypot(a,b);

pair z1=(0,b);
pair z2=(a,0);
pair z3=(a+b,0);
perpendicular(z1,NE,z1--z2,blue);
perpendicular(z3,NW,blue);
draw(square((0,0),z3));
draw(square(z1,z2));

real d=0.3;
pair v=unit(z2-z1);
draw(baseline("$a$"),-d*I--z2-d*I,red,Bars,Arrows,PenMargins);
draw(baseline("$b$"),z2-d*I--z3-d*I,red,Arrows,Bars,PenMargins);
draw("$c$",z3+z2*I-d*v--z2-d*v,red,Arrows,PenMargins);
draw("$a$",z3+d--z3+z2*I+d,red,Arrows,Bars,PenMargins);
draw("$b$",z3+z2*I+d--z3+z3*I+d,red,Arrows,Bars,PenMargins);

Mots-clefs : , , , , ,


Official Asymptote example – PythagoreanTree

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

Figure 0016
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(250);

real a=3;
real b=4;
real c=hypot(a,b);

transform ta=shift(c,c)*rotate(-aCos(a/c))*scale(a/c)*shift(-c);
transform tb=shift(0,c)*rotate(aCos(b/c))*scale(b/c);

picture Pythagorean(int n) {
  picture pic;
  fill(pic,scale(c)*unitsquare,1/(n+1)*green+n/(n+1)*brown);
  if(n == 0) return pic;
  picture branch=Pythagorean(--n);
  add(pic,ta*branch);
  add(pic,tb*branch);
  return pic;
}

add(Pythagorean(12));

Mots-clefs :


Official Asymptote example – RiemannSurface

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 23 h 57 min

Figure 0017
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import palette;
       
size(200,300,keepAspect=false);
//settings.nothin=true;
       
currentprojection=orthographic(10,10,30);
currentlight=(10,10,5);
triple f(pair t) {return (exp(t.x)*cos(t.y),exp(t.x)*sin(t.y),t.y);}
       
surface s=surface(f,(-4,-2pi),(0,4pi),8,16,Spline);
s.colors(palette(s.map(zpart),Rainbow()));
draw(s);

Mots-clefs : , , , ,


Official Asymptote example – RiemannSurfaceRoot

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 0 h 57 min

Figure 0018
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
// Riemann surface of z^{1/n}
import graph3;
import palette;
 
int n=3;

size(200,300,keepAspect=false);
//settings.nothin=true; 
 
currentprojection=orthographic(10,10,30);
currentlight=(10,10,5);
triple f(pair t) {return (t.x*cos(t.y),t.x*sin(t.y),t.x^(1/n)*sin(t.y/n));}
 
surface s=surface(f,(0,0),(1,2pi*n),8,16,Spline);
s.colors(palette(s.map(zpart),Rainbow()));

draw(s,meshpen=black);

Mots-clefs : , , ,


Official Asymptote example – Sierpinski

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 1 h 57 min

Figure 0019
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(10cm);

// Draw Sierpinski triangle with top vertex A, side s, and depth q.
void Sierpinski(pair A, real s, int q, bool top=true)
{
  pair B=A-(1,sqrt(2))*s/2;
  pair C=B+s;
  if(top) draw(A--B--C--cycle);
  draw((A+B)/2--(B+C)/2--(A+C)/2--cycle);
  if(q > 0) {
    Sierpinski(A,s/2,q-1,false);
    Sierpinski((A+B)/2,s/2,q-1,false);
    Sierpinski((A+C)/2,s/2,q-1,false);
  }
}

Sierpinski((0,1),1,5);

Mots-clefs :


Official Asymptote example – advection

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 2 h 57 min

Figure 0020
(Compiled with Asymptote version 1.87svn-r4643)
/* This code comes from The Official Asymptote Gallery */
    
size(0,22cm);

texpreamble("
\usepackage{bm}
\def\v{\bm}
\def\grad{\v\nabla}
\def\cross{{\v\times}}
\def\curl{\grad\cross}
\def\del{\nabla}
");

defaultpen(fontsize(10pt));

real margin=1.5mm;

object IC=draw("initial condition $\v U_0$",box,(0,1),
               margin,black,FillDraw(palegray));
object Adv0=draw("Lagrangian state $\v U(t)$",ellipse,(1,1),
                 margin,red,FillDraw(palered));
object Adv=draw("Lagrangian prediction $\v U(t+\tau)$",ellipse,(1,0),
                margin,red,FillDraw(palered));
object AdvD=draw("diffused parcels",ellipse,(1.8,1),
                 margin,red,FillDraw(palered));
object Ur=draw("rearranged $\v \widetilde U$",box,(0,0),
               margin,orange+gray,FillDraw(paleyellow));
object Ui=draw("interpolated $\v \widetilde U$",box,(1,-1),
               margin,blue,FillDraw(paleblue));
object Crank=draw("${\cal L}^{-1}(-\tau){\cal L}(\tau)\v \widetilde U$",
                  box,(0.5,-1),margin,blue,FillDraw(paleblue));
object CrankR=draw("${\cal L}^{-1}(-\tau){\cal L}(\tau)\v \widetilde U$",
                   box,(0,-1),margin,orange+gray,FillDraw(paleyellow));
object Urout=draw(minipage("\center{Lagrangian rearranged solution~$\v U_R$}",
                           100pt),box,(0,-2),margin,orange+gray,
                  FillDraw(paleyellow));
object Diff=draw("$\v D\del^2 \v \widetilde U$",box,(0.75,-1.5),
                 margin,blue,FillDraw(paleblue));
object UIout=draw(minipage("\center{semi-Lagrangian solution~$\v U_I$}",80pt),
                  box,(0.5,-2),margin,FillDraw(palered+paleyellow));
object psi=draw("$\psi=\del^{-2}\omega$",box,(1.6,-1),
                margin,darkgreen,FillDraw(palegreen));
object vel=draw("$\v v=\v{\hat z} \cross\grad\psi$",box,(1.6,-0.5),
                margin,darkgreen,FillDraw(palegreen));

add(new void(frame f, transform t) {
    pair padv=0.5*(point(Adv0,S,t)+point(Adv,N,t));
    picture pic;
    draw(pic,"initialize",point(IC,E,t)--point(Adv0,W,t),RightSide,Arrow,
         PenMargin);
    draw(pic,minipage("\flushright{advect: Runge-Kutta}",80pt),
         point(Adv0,S,t)--point(Adv,N,t),RightSide,red,Arrow,PenMargin);
    draw(pic,Label("Lagrange $\rightarrow$ Euler",0.45),
         point(Adv,W,t)--point(Ur,E,t),5LeftSide,orange+gray,
         Arrow,PenMargin);
    draw(pic,"Lagrange $\rightarrow$ Euler",point(Adv,S,t)--point(Ui,N,t),
         RightSide,blue,Arrow,PenMargin);
    draw(pic,point(Adv,E,t)--(point(AdvD,S,t).x,point(Adv,E,t).y),red,
         Arrow(Relative(0.7)),PenMargin);
    draw(pic,minipage("\flushleft{diffuse: multigrid Crank--Nicholson}",80pt),
         point(Ui,W,t)--point(Crank,E,t),5N,blue,MidArrow,PenMargin);
    draw(pic,minipage("\flushleft{diffuse: multigrid Crank--Nicholson}",80pt),
         point(Ur,S,t)--point(CrankR,N,t),LeftSide,orange+gray,Arrow,PenMargin);
    draw(pic,"output",point(CrankR,S,t)--point(Urout,N,t),RightSide,
         orange+gray,Arrow,PenMargin);
    draw(pic,point(Ui,S,t)--point(Diff,N,t),blue,MidArrow,PenMargin);
    draw(pic,point(Crank,S,t)--point(Diff,N,t),blue,MidArrow,PenMargin);
    label(pic,"subtract",point(Diff,N,t),12N,blue);
    draw(pic,Label("Euler $\rightarrow$ Lagrange",0.5),
         point(Diff,E,t)--(point(AdvD,S,t).x,point(Diff,E,t).y)--
         (point(AdvD,S,t).x,point(Adv,E,t).y),RightSide,blue,
         Arrow(position=1.5),PenMargin);
    dot(pic,(point(AdvD,S,t).x,point(Adv,E,t).y),red);
    draw(pic,(point(AdvD,S,t).x,point(Adv,E,t).y)--point(AdvD,S,t),red,Arrow,
         PenMargin);
    draw(pic,"output",point(Crank,S,t)--point(UIout,N,t),RightSide,brown,Arrow,
         PenMargin);
    draw(pic,Label("$t+\tau\rightarrow t$",0.45),
         point(AdvD,W,t)--point(Adv0,E,t),2.5LeftSide,red,Arrow,PenMargin);
    draw(pic,point(psi,N,t)--point(vel,S,t),darkgreen,Arrow,PenMargin);
    draw(pic,Label("self-advection",4.5),point(vel,N,t)--
         arc((point(vel,N,t).x,point(Adv,E,t).y),5,270,90)--
         (point(vel,N,t).x,padv.y)--
         padv,LeftSide,darkgreen,Arrow,PenMargin);
    draw(pic,Label("multigrid",0.5,S),point(Ui,E,t)--point(psi,W,t),darkgreen,
         Arrow,PenMargin);

    add(f,pic.fit());
  });

Mots-clefs :


Official Asymptote example – alignbox

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 3 h 57 min

Figure 0021
(Compiled with Asymptote version 1.87svn-r4643)
/* This code comes from The Official Asymptote Gallery */
    
real margin=1.5mm;

object left=align(object("$x^2$",ellipse,margin),W);
add(left);
object right=align(object("$\sin x$",ellipse,margin),4E);
add(right);
currentpicture.add(new void(frame f, transform t) {
    draw(f,point(left,NE,t)--point(right,W,t));
  });

Mots-clefs : ,


Official Asymptote example – alignedaxis

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 4 h 57 min

Figure 0022
(Compiled with Asymptote version 1.87svn-r4643)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

real Freq=60.0;
real margin=5mm;

pair exp(pair x) {
  return exp(x.x)*(cos(x.y)+I*sin(x.y));
}

real Merr(real x, real w) {
  real tau=x/(2*Freq);
  return 20*log(abs((tau*w+tau/(exp(I*2*pi*Freq*tau)-1))*(I*2*pi*Freq)));
}

real Aerr(real x, real w) {
  real tau=x/(2*Freq);
  return degrees((tau*w+tau/(exp(I*2*pi*Freq*tau)-1))*(I*2*pi*Freq));
}

picture pic1;
scale(pic1,Log,Linear);
real Merr1(real x){return Merr(x,1);}
draw(pic1,graph(pic1,Merr1,1e-4,1),black+1.2);

ylimits(pic1,-60,20);
yaxis(pic1,"magnitude (dB)",LeftRight,RightTicks(new
                                                 real[] {-60,-40,-20,0,20}));
xaxis(pic1,"$f/f_\mathrm{Ny}$",BottomTop,LeftTicks(N=5));
yequals(pic1,0,Dotted);
yequals(pic1,-20,Dotted);
yequals(pic1,-40,Dotted);
xequals(pic1,1e-3,Dotted);
xequals(pic1,1e-2,Dotted);
xequals(pic1,1e-1,Dotted);

size(pic1,100,100,point(pic1,SW),point(pic1,NE));

label(pic1,"$\theta=1$",point(pic1,N),2N);

frame f1=pic1.fit();
add(f1);

picture pic1p;
scale(pic1p,Log,Linear);
real Aerr1(real x){return Aerr(x,1);}
draw(pic1p,graph(pic1p,Aerr1,1e-4,1),black+1.2);

ylimits(pic1p,-5,95);
yaxis(pic1p,"phase (deg)",LeftRight,RightTicks(new real[] {0,45,90}));
xaxis(pic1p,"$f/f_\mathrm{Ny}$",BottomTop,LeftTicks(N=5));
yequals(pic1p,0,Dotted);
yequals(pic1p,45,Dotted);
yequals(pic1p,90,Dotted);
xequals(pic1p,1e-3,Dotted);
xequals(pic1p,1e-2,Dotted);
xequals(pic1p,1e-1,Dotted);

size(pic1p,100,100,point(pic1p,SW),point(pic1p,NE));

frame f1p=pic1p.fit();
f1p=shift(0,min(f1).y-max(f1p).y-margin)*f1p;
add(f1p);

picture pic2;
scale(pic2,Log,Linear);
real Merr2(real x){return Merr(x,0.75);}
draw(pic2,graph(pic2,Merr2,1e-4,1),black+1.2);

ylimits(pic2,-60,20);
yaxis(pic2,"magnitude (dB)",LeftRight,RightTicks(new
                                                 real[] {-60,-40,-20,0,20}));
xaxis(pic2,"$f/f_\mathrm{Ny}$",BottomTop,LeftTicks(N=5));
yequals(pic2,0,Dotted);
yequals(pic2,-20,Dotted);
yequals(pic2,-40,Dotted);
xequals(pic2,1e-3,Dotted);
xequals(pic2,1e-2,Dotted);
xequals(pic2,1e-1,Dotted);

size(pic2,100,100,point(pic2,SW),point(pic2,NE));

label(pic2,"$\theta=0.75$",point(pic2,N),2N);

frame f2=pic2.fit();
f2=shift(max(f1).x-min(f2).x+margin)*f2;
add(f2);

picture pic2p;
scale(pic2p,Log,Linear);
real Aerr2(real x){return Aerr(x,0.75);}
draw(pic2p,graph(pic2p,Aerr2,1e-4,1),black+1.2);

ylimits(pic2p,-5,95);
yaxis(pic2p,"phase (deg)",LeftRight,RightTicks(new real[] {0,45.1,90}));
xaxis(pic2p,"$f/f_\mathrm{Ny}$",BottomTop,LeftTicks(N=5));
yequals(pic2p,0,Dotted);
yequals(pic2p,45,Dotted);
yequals(pic2p,90,Dotted);
xequals(pic2p,1e-3,Dotted);
xequals(pic2p,1e-2,Dotted);
xequals(pic2p,1e-1,Dotted);

size(pic2p,100,100,point(pic2p,SW),point(pic2p,NE));

frame f2p=pic2p.fit();
f2p=shift(max(f1p).x-min(f2p).x+margin,min(f2).y-max(f2p).y-margin)*f2p;
add(f2p);

Mots-clefs : , ,


Official Asymptote example – arrows3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 5 h 57 min

Figure 0023
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

size(15cm);

currentprojection=perspective(24,14,13);
currentlight=light(gray(0.5),specularfactor=3,viewport=false,
                   (0.5,-0.5,-0.25),(0.5,0.5,0.25),(0.5,0.5,1),(-0.5,-0.5,-1));

defaultpen(0.75mm);

path3 g=arc(O,1,90,-60,90,60);
transform3 t=shift(invert(3S,O));

draw(g,blue,Arrows3(TeXHead3),currentlight);
draw(scale3(3)*g,green,ArcArrows3(HookHead3),currentlight);
draw(scale3(6)*g,red,Arrows3(DefaultHead3),currentlight);

draw(t*g,blue,Arrows3(TeXHead2),currentlight);
draw(t*scale3(3)*g,green,ArcArrows3(HookHead2,NoFill),currentlight);
draw(t*scale3(6)*g,red,Arrows3(DefaultHead2(normal=Z)),currentlight);

Mots-clefs : ,


Official Asymptote example – axis3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 6 h 57 min

Figure 0024
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(0,200);
size3(200,IgnoreAspect);

currentprojection=perspective(5,2,2);

scale(Linear,Linear,Log);

xaxis3("$x$",0,1,red,OutTicks(2,2));
yaxis3("$y$",0,1,red,OutTicks(2,2));
zaxis3("$z$",1,30,red,OutTicks(beginlabel=false));

Mots-clefs : , ,


Official Asymptote example – basealign

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

Figure 0025
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import fontsize;
import three;
currentprojection=orthographic(Z);

defaultpen(fontsize(100pt));

dot(O);

label("acg",O,align=N,basealign);
label("ace",O,align=N,red);
label("acg",O,align=S,basealign);
label("ace",O,align=S,red);
label("acg",O,align=E,basealign);
label("ace",O,align=E,red);
label("acg",O,align=W,basealign);
label("ace",O,align=W,red);

picture pic;
dot(pic,(labelmargin(),0,0),blue);
dot(pic,(-labelmargin(),0,0),blue);
dot(pic,(0,labelmargin(),0),blue);
dot(pic,(0,-labelmargin(),0),blue);
add(pic,O);

dot((0,0));

label("acg",(0,0),align=N,basealign);
label("ace",(0,0),align=N,red);
label("acg",(0,0),align=S,basealign);
label("ace",(0,0),align=S,red);
label("acg",(0,0),align=E,basealign);
label("ace",(0,0),align=E,red);
label("acg",(0,0),align=W,basealign);
label("ace",(0,0),align=W,red);

picture pic;
dot(pic,(labelmargin(),0),blue);
dot(pic,(-labelmargin(),0),blue);
dot(pic,(0,labelmargin()),blue);
dot(pic,(0,-labelmargin()),blue);
add(pic,(0,0));

Mots-clefs : , , , ,


Official Asymptote example – bezier2

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 8 h 57 min

Figure 0026
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import beziercurve;

pair midpoint(pair a, pair b) {return interp(a,b,0.5);}

pair m0=midpoint(z0,c0);
pair m1=midpoint(c0,c1);
pair m2=midpoint(c1,z1);

draw(m0--m1--m2,dashed);
dot("$m_0$",m0,NW,red);
dot("$m_1$",m1,N,red);
dot("$m_2$",m2,red);

pair m3=midpoint(m0,m1);
pair m4=midpoint(m1,m2);
pair m5=midpoint(m3,m4);

draw(m3--m4,dashed);
dot("$m_3$",m3,NW,red);
dot("$m_4$",m4,NE,red);
dot("$m_5$",m5,N,red);

Mots-clefs : , ,


Official Asymptote example – beziercurve

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 9 h 57 min

Figure 0027
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(400);
pair z0=(0,0);
pair c0=(1,1);
pair c1=(2,1);
pair z1=(3,0);
draw(z0..controls c0 and c1 .. z1,blue);

draw(z0--c0--c1--z1,dashed);
dot("$z_0$",z0,W,red);
dot("$c_0$",c0,NW,red);
dot("$c_1$",c1,NE,red);
dot("$z_1$",z1,red);

Mots-clefs : , ,


Official Asymptote example – binarytreetest

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 10 h 57 min

Figure 0028
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import binarytree;

picture pic,pic2;

binarytree bt=binarytree(1,2,4,nil,5,nil,nil,0,nil,nil,3,6,nil,nil,7);
draw(pic,bt);

binarytree st=searchtree(10,5,2,1,3,4,7,6,8,9,15,13,12,11,14,17,16,18,19);
draw(pic2,st,blue);

add(pic.fit(),(0,0),10N);
add(pic2.fit(),(0,0),10S);


Mots-clefs : ,


Official Asymptote example – brokenaxis

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 11 h 57 min

Figure 0029
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(200,150,IgnoreAspect);

// Break the x axis at 3; restart at 8:
real a=3, b=8;

// Break the y axis at 100; restart at 1000:
real c=100, d=1000;

scale(Broken(a,b),BrokenLog(c,d));

real[] x={1,2,4,6,10};
real[] y=x^4;

draw(graph(x,y),red,MarkFill[0]);

xaxis("$x$",BottomTop,LeftTicks(Break(a,b)));
yaxis("$y$",LeftRight,RightTicks(Break(c,d)));

label(rotate(90)*Break,(a,point(S).y));
label(rotate(90)*Break,(a,point(N).y));
label(Break,(point(W).x,ScaleY(c)));
label(Break,(point(E).x,ScaleY(c)));


Mots-clefs : ,


Official Asymptote example – buildcycle

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 12 h 57 min

Figure 0030
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);

real w=1.35;

path[] p;
for(int k=0; k < 2; ++k) {
  int i=2+2*k;
  int ii=i^2;
  p[k]=(w/ii,1){1,-ii}::(w/i,1/i)::(w,1/ii){ii,-1};
}

path q0=(0,0)--(w,0.5);
path q1=(0,0)--(w,1.5);
draw(q0); draw(p[0]); draw(q1); draw(p[1]);
path s=buildcycle(q0,p[0],q1,p[1]);
fill(s,mediumgrey);

label("$P$",intersectionpoint(p[0],q0),N);
label("$Q$",intersectionpoint(p[0],q1),E);
label("$R$",intersectionpoint(p[1],q1),W);
label("$S$",intersectionpoint(p[1],q0),S);
label("$f > 0$",0.5*(min(s)+max(s)),UnFill);

Mots-clefs : ,


Official Asymptote example – cardioid

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 13 h 57 min

Figure 0031
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(0,100);

real f(real t) {return 1+cos(t);}

path g=polargraph(f,0,2pi,operator ..)--cycle;
filldraw(g,pink);

xaxis("$x$",above=true);
yaxis("$y$",above=true);

dot("$(a,0)$",(1,0),N);
dot("$(2a,0)$",(2,0),N+E);


Mots-clefs : ,


Official Asymptote example – centroidfg

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 14 h 57 min

Figure 0032
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(0,150);

int a=-1, b=1;

real f(real x) {return x^3-x+2;}
real g(real x) {return x^2;}

draw(graph(f,a,b,operator ..),red);
draw(graph(g,a,b,operator ..),blue);
 
xaxis(); 

int n=5;

real width=(b-a)/(real) n;
for(int i=0; i <= n; ++i) {
  real x=a+width*i;
  draw((x,g(x))--(x,f(x)));
}
 
labelx("$a$",a);
labelx("$b$",b);
draw((a,0)--(a,g(a)),dotted);
draw((b,0)--(b,g(b)),dotted);

real m=a+0.73*(b-a);
arrow("$f(x)$",(m,f(m)),N,red);
arrow("$g(x)$",(m,g(m)),E,0.8cm,blue);

int j=2;
real xi=b-j*width;
real xp=xi+width;
real xm=0.5*(xi+xp);
pair dot=(xm,0.5*(f(xm)+g(xm)));
dot(dot,darkgreen+4.0);
arrow("$\left(x,\frac{f(x)+g(x)}{2}\right)$",dot,NE,2cm,darkgreen);


Mots-clefs :


Official Asymptote example – cheese

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 15 h 57 min

Figure 0033
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import palette;
import contour3;
size(400);

real f(real x, real y, real z) {
  return cos(x)*sin(y)+cos(y)*sin(z)+cos(z)*sin(x);
}

surface sf=surface(contour3(f,(-2pi,-2pi,-2pi),(2pi,2pi,2pi),12));
sf.colors(palette(sf.map(abs),Gradient(red,yellow)));
draw(sf,nolight);

Mots-clefs : , , , , ,


Official Asymptote example – circles

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 16 h 57 min

Figure 0034
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(6cm,0);
import math;

currentpen=magenta;

real r1=1;
real r2=sqrt(7);
real r3=4;
pair O=0;

path c1=circle(O,r1);
draw(c1,green);
draw(circle(O,r2),green);
draw(circle(O,r3),green);

real x=-0.6;
real y=-0.8;
real yD=0.3;
pair A=(sqrt(r1^2-y^2),y);
pair B=(-sqrt(r2^2-y^2),y);
pair C=(x,sqrt(r3^2-x^2));

pair d=A+r2*dir(B--C);
pair D=intersectionpoint(c1,A--d);

draw(A--B--C--cycle);
draw(interp(A,D,-0.5)--interp(A,D,1.5),blue);

dot("$O$",O,S,red);
dot("$A$",A,dir(C--A,B--A),red);
dot("$B$",B,dir(C--B,A--B),red);
dot("$C$",C,dir(A--C,B--C),red);
dot("$D$",D,red);

Mots-clefs : , , ,


Official Asymptote example – coag

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 17 h 57 min

Figure 0035
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,200);
import graph;

pair z0=(0,0);
pair m0=(0,1);
pair tg=(1.5,0);
pair mt=m0+tg;
pair tf=(3,0);

draw(m0--mt{dir(-70)}..{dir(0)}2tg+m0/4);
xtick("$T_g$",tg,N);
label("$M(t)$",mt,2NE);
labely("$M_0$",m0);

xaxis(Label("$t$",align=2S),Arrow);
yaxis(Arrow);

Mots-clefs : ,


Official Asymptote example – colons

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 18 h 57 min

Figure 0036
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
draw((0,0){up}::(100,25){right}::(200,0){down});

Mots-clefs : ,


Official Asymptote example – colorplanes

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

Figure 0037
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(6cm,0);
import bsp;

real u=2.5;
real v=1;

currentprojection=oblique;

path3 y=plane((2u,0,0),(0,2v,0),(-u,-v,0));
path3 l=rotate(90,Z)*rotate(90,Y)*y;
path3 g=rotate(90,X)*rotate(90,Y)*y;

face[] faces;
pen[] p={red,green,blue,black};
int[] edges={0,0,0,2};
gouraudshade(faces.push(y),project(y),p,edges);
gouraudshade(faces.push(l),project(l),p,edges);
gouraudshade(faces.push(g),project(g),new pen[]{cyan,magenta,yellow,black},
             edges);

add(faces);


Mots-clefs : ,


Official Asymptote example – colors

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

Figure 0038
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
int i=0;
int j=0;

bool components=false;

pen p;

void col(bool fill=false ... string[] s) {
  for(int n=0; n < s.length; ++n) {
    j -= 10;
    string s=s[n];
    eval("p="+s+";",true);
    if(components) {
      real[] a=colors(p);
      for(int i=0; i < a.length; ++i)
        s += " "+(string) a[i];
    }
    if(fill) label(s,(i+10,j),E,p,Fill(gray));
    else label(s,(i+10,j),E,p);
    fill(box((i,j-5),(i+10,j+5)),p);
  }
}

col("palered");
col("lightred");
col("mediumred");
col("red");
col("heavyred");
col("brown");
col("darkbrown");
j -= 10;

col("palegreen");
col("lightgreen");
col("mediumgreen");
col("green");
col("heavygreen");
col("deepgreen");
col("darkgreen");
j -= 10;

col("paleblue");
col("lightblue");
col("mediumblue");
col("blue");
col("heavyblue");
col("deepblue");
col("darkblue");
j -= 10;

i += 150;
j=0;

col("palecyan");
col("lightcyan");
col("mediumcyan");
col("cyan");
col("heavycyan");
col("deepcyan");
col("darkcyan");
j -= 10;

col("pink");
col("lightmagenta");
col("mediummagenta");
col("magenta");
col("heavymagenta");
col("deepmagenta");
col("darkmagenta");
j -= 10;

col("paleyellow");
col("lightyellow");
col("mediumyellow");
col("yellow");
col("lightolive");
col("olive");
col("darkolive");
j -= 10;

col("palegray");
col("lightgray");
col("mediumgray");
col("gray");
col("heavygray");
col("deepgray");
col("darkgray");
j -= 10;

i += 150;
j=0;

col("black");
col("white",fill=true);
j -= 10;

col("orange");
col("fuchsia");
j -= 10;
col("chartreuse");
col("springgreen");
j -= 10;
col("purple");
col("royalblue");
j -= 10;

col("Cyan");
col("Magenta");
col("Yellow");
col("Black");

j -= 10;

col("cmyk(red)");
col("cmyk(blue)");
col("cmyk(green)");

Mots-clefs :


Official Asymptote example – condor

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

Figure 0039
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
// Peter Luschny's Condor function
// http://www.luschny.de/math/asy/ElCondorYElGamma.html

import palette;
import graph3;

size(300,300,IgnoreAspect);
currentprojection=orthographic(0,-1,0,center=true);
currentlight=White;
real K=7;

triple condor(pair t)
{
  real y=t.y;
  real x=t.x*y;
  real e=gamma(y+1);
  real ymx=y-x;
  real ypx=y+x;
  real a=gamma((ymx+1)/2);
  real b=gamma((ymx+2)/2);
  real c=gamma((ypx+1)/2);
  real d=gamma((ypx+2)/2);
  real A=cos(pi*ymx);
  real B=cos(pi*ypx);
  return (x,y,log(e)+log(a)*((A-1)/2)+log(b)*((-A-1)/2)+log(c)*((B-1)/2)+
          log(d)*((-B-1)/2));
}

surface s=surface(condor,(-1,0),(1,K),16,Spline);
s.colors(palette(s.map(zpart),Rainbow()));

draw(s);

Mots-clefs : , , , ,


Official Asymptote example – cones

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

Figure 0040
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import solids;

size(200);
currentprojection=orthographic(5,4,2);

revolution upcone=cone(-Z,1,1);
revolution downcone=cone(Z,1,-1);
draw(surface(upcone),green);
draw(surface(downcone),green);
draw(upcone,5,blue,longitudinalpen=nullpen);
draw(downcone,5,blue,longitudinalpen=nullpen);

revolution cone=shift(2Y-2X)*cone(1,1);

draw(surface(cone),green);
draw(cone,5,blue);

Mots-clefs : , ,


Official Asymptote example – conicurv

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 23 h 57 min

Figure 0041
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
// Original name : conicurv.mp 
// Author : L. Nobre G.
// Translators : J. Pienaar (2004) and John Bowman (2005)

import three;
texpreamble("\usepackage{bm}");

size(300,0);

currentprojection=perspective(10,-5,5.44); 

real theta=30, width=3, shortradius=2, bord=2, refsize=1, vecsize=2;
real height=0.3, anglar=1.75, totup=3;
real longradius=shortradius+width*Cos(theta), updiff=width*Sin(theta);

triple iplow=(0,shortradius,0), iphig=(0,longradius,updiff);
triple oplow=(-shortradius,0,0), ophig=(-longradius,0,updiff);
triple aplow=-iplow, aphig=(0,-longradius,updiff);
triple eplow=-oplow, ephig=(longradius,0,updiff);
triple anglebase=(0,longradius,0), centre=interp(iplow,iphig,0.5)+(0,0,height);
triple central=(0,0,centre.z), refo=(0,0.5*centre.y,centre.z);
triple refx=refsize*(0,Cos(theta),Sin(theta));
triple refy=refsize*(0,-Sin(theta),Cos(theta));

draw("$\theta$",arc(iplow,iplow+0.58*(iphig-iplow),anglebase),E);

draw(central,linewidth(2bp));
draw(iplow--iphig);
draw(oplow--ophig);
draw(aplow--aphig);
draw(eplow--ephig);
draw(iphig--anglebase--aplow,dashed);
draw(oplow--eplow,dashed);
draw(central--centre,dashed);

draw((0,0,-bord)--(0,longradius+bord,-bord)--(0,longradius+bord,totup)
     --(0,0,totup)--cycle);
draw(Label("$y$",1),refo--refo+refy,SW,Arrow3);
draw(Label("$x$",1),refo--refo+refx,SE,Arrow3);

draw(Label("$\vec{R}_N$",1),centre--centre+vecsize*refy,E,Arrow3);
draw(Label("$\vec{F}_a$",1),centre--centre+vecsize*refx,N,Arrow3);
draw(Label("$\vec{F}_c$",1),centre--centre+vecsize*Y,NE,Arrow3);
draw(Label("$\vec{P}$",1),centre--centre-vecsize*Z,E,Arrow3);
draw(Label("$\vec{v}$",1),centre--centre+vecsize*X,E,Arrow3);
draw(centre,10pt+blue);

draw(circle((0,0,updiff),longradius),linewidth(2bp));
draw(circle(O,shortradius),linewidth(2bp));

Mots-clefs : , , ,


Official Asymptote example – controlsystem

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 0 h 57 min

Figure 0042
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,4cm);
import flowchart;

block delay=roundrectangle("$e^{-sT_t}$",(0.33,0));
block system=roundrectangle("$\frac{s+3}{s^2+0.3s+1}$",(0.6,0));
block controller=roundrectangle("$0.06\left( 1 + \frac{1}{s}\right)$",
                                (0.45,-0.25));
block sum1=circle("",(0.15,0),mindiameter=0.3cm);
block junction1=circle("",(0.75,0),fillpen=currentpen);

draw(delay);
draw(system);
draw(controller);
draw(sum1);
draw(junction1);

add(new void(picture pic, transform t) {
    draw(pic,Label("$u$",0.5,N),path(new pair[]{t*(0,0),sum1.left(t)},
                                     Horizontal),Arrow,PenMargin);

    draw(pic,path(new pair[]{sum1.right(t),delay.left(t)},Horizontal),Arrow,
         PenMargin);
    label(pic,"-",sum1.bottom(t),ESE);

    draw(pic,path(new pair[]{delay.right(t),system.left(t)},Horizontal),Arrow,
         PenMargin);

    draw(pic,path(new pair[]{system.right(t),junction1.left(t)},Horizontal),
         PenMargin);

    draw(pic,Label("$y$",0.5,N),path(new pair[]{junction1.right(t),t*(0.9,0)},
                                   Horizontal),Arrow,PenMargin);

    draw(pic,path(new pair[]{junction1.bottom(t),controller.right(t)},Vertical),
         Arrow,PenMargin);

    draw(pic,path(new pair[]{controller.left(t),sum1.bottom(t)},Horizontal),
         Arrow,PenMargin);
  });

Mots-clefs :


Official Asymptote example – cos2theta

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 1 h 57 min

Figure 0043
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(0,100);

real f(real t) {return cos(2*t);}

path g=polargraph(f,0,2pi,operator ..)--cycle;
fill(g,green+white);
xaxis("$x$",above=true);
yaxis("$y$",above=true);
draw(g);

dot(Label,(1,0),NE);
dot(Label,(0,1),NE);



Mots-clefs : ,


Official Asymptote example – cosaddition

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 2 h 57 min

Figure 0044
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,200);
import geometry;

real A=130;
real B=40;

pair O=(0,0); 
pair R=(1,0);
pair P=dir(A);
pair Q=dir(B);

draw(circle(O,1.0));
draw(Q--O--P);
draw(P--Q,red);
draw(O--Q--R--cycle);

draw("$A$",arc(R,O,P,0.3),blue,Arrow,PenMargin);
draw("$B$",arc(R,O,Q,0.6),blue,Arrow,PenMargin);
pair S=(Cos(B),0);
draw(Q--S,blue);
perpendicular(S,NE,blue);

dot(O);
dot("$R=(1,0)$",R);
dot("$P=(\cos A,\sin A)$",P,dir(O--P)+W);
dot("$Q=(\cos B,\sin B)$",Q,dir(O--Q));

Mots-clefs : , , ,


Official Asymptote example – cube

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 3 h 57 min

Figure 0045
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;
dotgranularity=0; // Render dots as spheres.

currentprojection=orthographic(5,4,2,center=true);

size(5cm);
size3(3cm,5cm,8cm);

draw(unitbox);

dot(unitbox,red);

label("$O$",(0,0,0),NW);
label("(1,0,0)",(1,0,0),S);
label("(0,1,0)",(0,1,0),E);
label("(0,0,1)",(0,0,1),Z);

Mots-clefs : , ,


Official Asymptote example – curvedlabel

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 4 h 57 min

Figure 0046
(Compiled with Asymptote version 1.87svn-r4643)
/* This code comes from The Official Asymptote Gallery */
    
size(200);
import labelpath;
labelpath("This is a test of curved labels in Asymptote (implemented with the {\tt PSTricks pstextpath} macro).",reverse(rotate(-90)*unitcircle));


Mots-clefs : , ,


Official Asymptote example – curvedlabel3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 5 h 57 min

Figure 0047
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);
import labelpath3;

path3 g=(1,0,0)..(0,1,1)..(-1,0,0)..(0,-1,1)..cycle;
path3 g2=shift(-Z)*reverse(unitcircle3);

string txt1="\hbox{This is a test of \emph{curved} 3D labels in
\textbf{Asymptote} (implemented with {\tt texpath}).}";

string txt2="This is a test of curved labels in Asymptote\\(implemented
without the {\tt PSTricks pstextpath} macro)."; 

draw(surface(g),paleblue+opacity(0.5));
draw(labelpath(txt1,subpath(g,0,reltime(g,0.95)),angle=-90),orange);

draw(g2,1bp+red);
draw(labelpath(txt2,subpath(g2,0,3.9),angle=180,optional=rotate(-70,X)*Z));

Mots-clefs : ,


Official Asymptote example – cyclohexane

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 6 h 57 min

Figure 0048
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

currentprojection = perspective(300,-650,500);

surface carbon = scale3(70)*unitsphere; // 70 pm
surface hydrogen = scale3(25)*unitsphere; // 25 pm

real alpha = 90+aSin(1/3);

real CCbond = 156; // 156 pm
real CHbond = 110; // 110 pm

triple c1 = (0,0,0);
triple h1 = c1+CHbond*Z;
triple c2 = rotate(alpha,c1,c1+Y)*(CCbond*Z);
triple h2 = rotate(120,c1,c2)*h1;
triple h3 = c2-CHbond*Z;
triple h4 = rotate(120,c2,c1)*h3;

triple c3 = rotate(120,c2,h3)*c1;
triple h5 = c3+CHbond*Z;
triple h6 = rotate(-120,c3,c2)*h5;

triple c4 = rotate(-120,c3,h5)*c2;
triple h7 = c4-CHbond*Z;
triple h8 = rotate(120,c4,c3)*h7;

triple c5 = rotate(120,c4,h7)*c3;
triple h9 = c5+CHbond*Z;
triple h10 = rotate(-120,c5,c4)*h9;

triple c6 = rotate(-120,c5,h9)*c4;
triple h11 = c6-CHbond*Z;
triple h12 = rotate(120,c6,c5)*h11;

draw(shift(c1)*carbon,black);
draw(shift(c2)*carbon,black);
draw(shift(c3)*carbon,black);
draw(shift(c4)*carbon,black);
draw(shift(c5)*carbon,black);
draw(shift(c6)*carbon,black);


draw(shift(h1)*hydrogen,lightgray);
draw(shift(h2)*hydrogen,lightgray);
draw(shift(h3)*hydrogen,lightgray);
draw(shift(h4)*hydrogen,lightgray);
draw(shift(h5)*hydrogen,lightgray);
draw(shift(h6)*hydrogen,lightgray);
draw(shift(h7)*hydrogen,lightgray);
draw(shift(h8)*hydrogen,lightgray);
draw(shift(h9)*hydrogen,lightgray);
draw(shift(h10)*hydrogen,lightgray);
draw(shift(h11)*hydrogen,lightgray);
draw(shift(h12)*hydrogen,lightgray);


pen thick = linewidth(10);

draw(c1--c2--c3--c4--c5--c6--cycle,thick);

draw(c1--h1,thick);
draw(c1--h2,thick);
draw(c2--h3,thick);
draw(c2--h4,thick);
draw(c3--h5,thick);
draw(c3--h6,thick);
draw(c4--h7,thick);
draw(c4--h8,thick);
draw(c5--h9,thick);
draw(c5--h10,thick);
draw(c6--h11,thick);
draw(c6--h12,thick);

Mots-clefs : , ,


Official Asymptote example – cylinder

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

Figure 0049
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import solids;

size(0,100);

revolution r=cylinder(O,1,1.5,Y+Z);
draw(surface(r),green);
draw(r,blue);

Mots-clefs : , ,


Official Asymptote example – cylinderskeleton

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 8 h 57 min

Figure 0050
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import solids;

size(0,100);

revolution r=cylinder(O,1,1.5,Y+Z);
draw(r,heavygreen);

Mots-clefs : , ,


Official Asymptote example – datagraph

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 9 h 57 min

Figure 0051
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(200,150,IgnoreAspect);

real[] x={0,1,2,3};
real[] y=x^2;

draw(graph(x,y),red);

xaxis("$x$",BottomTop,LeftTicks);
yaxis("$y$",LeftRight,
      RightTicks(Label(fontsize(8pt)),new real[]{0,4,9}));

Mots-clefs : ,


Official Asymptote example – delu

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 10 h 57 min

Figure 0052
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(7cm,0);

pair z1=(1,-0.25);
pair v1=dir(45);
pair z2=-z1;
pair v2=0.75*dir(260);
pair z3=(z1.x,-3);

// A centered random number
real crand() {return unitrand()-0.5;}

guide g;
pair lastz;
for(int i=0; i < 60; ++i) {
  pair z=0.75*lastz+(crand(),crand());
  g=g..2.5*z;
  lastz=z;
}
g=shift(0,-.5)*g..cycle;

draw(g,gray(0.7));

draw("$r$",z1--z2,RightSide,red,Arrows,DotMargins);
draw(z1--z1+v1,Arrow);
draw(z2--z2+v2,Arrow);
draw(z3--z3+v1-v2,green,Arrow);

dot("1",z1,S,blue);
dot("2",z2,NW,blue);

Mots-clefs : ,


Official Asymptote example – diatom

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 11 h 57 min

Figure 0053
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(15cm,12cm,IgnoreAspect);

real minpercent=20;
real ignorebelow=0;
string data="diatom.csv";
string[] group;
int[] begin,end;

defaultpen(fontsize(8pt)+overwrite(MoveQuiet));

file in=line(csv(input(data)));

string depthlabel=in;
string yearlabel=in;
string[] taxa=in;
group=in;
begin=in;
real[] depth;
int[] year;
real[][] percentage;

while(true) {
  real d=in;
  if(eof(in)) break;
  depth.push(d);
  year.push(in);
  percentage.push(in);
}

percentage=transpose(percentage);
real depthmin=-min(depth);
real depthmax=-max(depth);

int n=percentage.length;

int final;
for(int taxon=0; taxon < n; ++taxon) {
  real[] P=percentage[taxon];
  if(max(P) < ignorebelow) continue;
  final=taxon;
}  

real angle=45;
real L=3cm;
pair Ldir=L*dir(angle);
real ymax=-infinity;
real margin=labelmargin();

real location=0;

for(int i=0; i < begin.length-1; ++i) end[i]=begin[i+1]-1;
end[begin.length-1]=n-1;

typedef void drawfcn(frame f);
drawfcn[] draw=new drawfcn[begin.length];

pair z0;

for(int taxon=0; taxon < n; ++taxon) {
  real[] P=percentage[taxon];
  real maxP=max(P);
  if(maxP < ignorebelow) continue;
  picture pic;
  real x=1;
  if(maxP < minpercent) x=minpercent/maxP;
  if(maxP > 100) x=50/maxP;
  scale(pic,Linear(true,x),Linear(-1));
  filldraw(pic,(0,depthmin)--graph(pic,P,depth)--(0,depthmax)--cycle,
           gray(0.9));
  xaxis(pic,Bottom,LeftTicks("$%.3g$",beginlabel=false,0,2),above=true);
  xaxis(pic,Top,above=true);

  frame label;
  label(label,rotate(angle)*TeXify(taxa[taxon]),(0,0),N);

  pair z=point(pic,N);
  pair v=max(label);
  int taxon=taxon;
  pic.add(new void(frame f, transform t) {
      pair z1=t*z+v;
      ymax=max(ymax,z1.y+margin);
    });

  for(int i=0; i < begin.length; ++i) {
    pair z=point(pic,N);
    pair v=max(label);
    if(taxon == begin[i]) {
      pic.add(new void(frame f, transform t) {
          pair Z=t*z+v;
          z0=Z;
          pair w0=Z+Ldir;
        });
    } else if(taxon == end[i]) {
      int i=i;
      pair align=2N;
      pic.add(new void(frame, transform t) {
          pair z0=z0;
          pair z1=t*z+v;
          pair w1=z1+Ldir;
          draw[i]=new void(frame f) {
            path g=z0--(z0.x+(ymax-z0.y)/Tan(angle),ymax)--
            (z1.x+(ymax-z1.y)/Tan(angle),ymax)--z1;
            draw(f,g);
            label(f,group[i],point(g,1.5),align);
          };
        });
    }
  }

  add(pic,label,point(pic,N));

  if(taxon == 0) yaxis(pic,depthlabel,Left,RightTicks(0,10),above=true);
  if(taxon == final) yaxis(pic,Right,LeftTicks("%",0,10),above=true);
 
  add(shift(location,0)*pic);
  location += pic.userMax.x;
}

add(new void(frame f, transform) {
    for(int i=0; i < draw.length; ++i)
      draw[i](f);
  });

for(int i=0; i < year.length; ++i)
  if(year[i] != 0) label((string) year[i],(location,-depth[i]),E);

label("\%",(0.5*location,point(S).y),5*S);

Mots-clefs : , ,


Official Asymptote example – dimension

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 12 h 57 min

Figure 0054
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(12cm,0); 
 
void distance(picture pic=currentpicture, pair A, pair B, Label L="", real n=0,
              pen p=currentpen) 
{
  real d=3mm;
  path g=A--B;
  transform T=shift(-n*d*unit(B-A)*I);
  pic.add(new void(frame f, transform t) {
      picture opic;
      path G=T*t*g;
      draw(opic,Label(L,Center,UnFill(1)),G,p,Arrows(NoFill),Bars,PenMargins); 
      add(f,opic.fit());
    });
  pic.addBox(min(g),max(g),T*min(p),T*max(p));
} 
 
pair A=(0,0), B=(3,3); 
 
dot(A); 
dot(B); 
 
distance(A,B,"$\ell$",1); 

Mots-clefs : ,


Official Asymptote example – dots

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 13 h 57 min

Figure 0055
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
draw((0,0){up}..(100,25){right}..(200,0){down});

Mots-clefs : , ,


Official Asymptote example – dragon

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 14 h 57 min

Figure 0056
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
pair crease(pair z1, pair z2, bool left)
{
  pair dz = z2 - z1;

  if (left)
    return z1 + dz * (0.5, 0.5);
  else
    return z1 + dz * (0.5, -0.5);
}

pair[] fold(pair[] oldz)
{
  int n = oldz.length;
  pair[] newz = new pair[2n-1];

  for (int i = 0; i < n-1; ++i)
    {
      newz[2i] = oldz[i];
      newz[2i+1] = crease(oldz[i], oldz[i+1], i%2==0);
    }

  newz[2(n-1)] = oldz[n-1];

  return newz;
}

pair[] dragon(int n, pair[] base={})
{
  if (base.length == 0)
    if (n%2 == 0)
      base = new pair[] {(0,0), (1,1) };
    else
      base = new pair[] {(0,0), (1,0) };

  pair[] z = base;

  for (int i = 1; i < n; ++i)
    z = fold(z);

  return z;
}

void drawtris(pair[] z, pen p = currentpen)
{
  int n = z.length;

  for (int i = 0; i < n-2; i+=2)
    fill(z[i]--z[i+1]--z[i+2]--cycle, p);
}

void drawtris(pair[] z, pen p1, pen p2)
{
  int n = z.length;

  for (int i = 0; i < n-2; i+=2)
    fill(z[i]--z[i+1]--z[i+2]--cycle, 2i < n-1 ? p1 : p2);
}

size(500,0);

int n = 10;

drawtris(dragon(n, new pair[] {(0,0), (1,0)}), black);
drawtris(dragon(n, new pair[] {(0,0), (0,-1)}), blue);
drawtris(dragon(n, new pair[] {(0,0), (-1,0)}), red);
drawtris(dragon(n, new pair[] {(0,0), (0,1)}),  green);

Mots-clefs : ,


Official Asymptote example – eetomumu

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 15 h 57 min

Figure 0057
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import feynman;


// set default line width to 0.8bp
currentpen = linewidth(0.8);

// scale all other defaults of the feynman module appropriately
fmdefaults();

// define vertex and external points

real L = 50;

pair zl = (-0.75*L,0);
pair zr = (+0.75*L,0);

pair xu = zl + L*dir(+120);
pair xl = zl + L*dir(-120);

pair yu = zr + L*dir(+60);
pair yl = zr + L*dir(-60);


// draw propagators and vertices

drawFermion(xu--zl);
drawFermion(zl--xl);

drawPhoton(zl--zr);

drawFermion(yu--zr);
drawFermion(zr--yl);

drawVertex(zl);
drawVertex(zr);


// draw momentum arrows and momentum labels

drawMomArrow(xl--zl, Relative(left));
label(Label("$k'$",2RightSide), xl--zl);

label(Label("$k$",2LeftSide), xu--zl);

drawMomArrow(zl--zr, Relative(left));
label(Label("$q$",2RightSide), zl--zr);

drawMomArrow(zr--yu, Relative(right));
label(Label("$p'$",2LeftSide), zr--yu);

label(Label("$p$",2RightSide), zr--yl);


// draw particle labels

label("$e^-$", xu, left);
label("$e^+$", xl, left);

label("$\mu^+$", yu, right);
label("$\mu^-$", yl, right);

Mots-clefs : , ,


Official Asymptote example – electromagnetic

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 16 h 57 min

Figure 0058
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph; 
import palette;
texpreamble("\usepackage[amssymb,thinqspace,thinspace]{SIunits}"); 
 
size(800,200); 
 
real c=3e8;
real nm=1e-9;
real freq(real lambda) {return c/(lambda*nm);} 
real lambda(real f) {return c/(f*nm);} 
 
real fmin=10; 
real fmax=1e23; 
 
scale(Log(true),Linear(true)); 
xlimits(fmin,fmax); 
ylimits(0,1); 
 
real uv=freq(400);
real ir=freq(700);
 
bounds visible=bounds(Scale(uv).x,Scale(ir).x);
palette(visible,uv,ir+(0,2),Bottom,Rainbow(),invisible);

xaxis(Label("\hertz",1),Bottom,RightTicks,above=true); 
 
real log10Left(real x) {return -log10(x);}
real pow10Left(real x) {return pow10(-x);}

scaleT LogLeft=scaleT(log10Left,pow10Left,logarithmic=true);

picture q=secondaryX(new void(picture p) { 
    scale(p,LogLeft,Linear); 
    xlimits(p,lambda(fmax),lambda(fmin));
    ylimits(p,0,1); 
    xaxis(p,Label("\nano\metre",1),Top,LeftTicks(DefaultLogFormat,n=10)); 
  }); 
 
add(q,above=true); 

margin margin=PenMargin(0,0);
draw("radio",Scale((10,1))--Scale((5e12,1)),N,Arrow); 
draw("infrared",Scale((1e12,1.5))--Scale(shift(0,1.5)*ir),Arrows,margin);
draw("UV",Scale(shift(0,1.5)*uv)--Scale((1e17,1.5)),Arrows,margin);
draw("x-rays",Scale((1e16,1))--Scale((1e21,1)),N,Arrows); 
draw("$\gamma$-rays",Scale((fmax,1.5))--Scale((2e18,1.5)),Arrow); 


Mots-clefs : ,


Official Asymptote example – elevation

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 17 h 57 min

Figure 0059
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import grid3;
import palette;

currentprojection=orthographic(0.8,1,1);

size(400,300,IgnoreAspect);

real f(pair z) {return cos(2*pi*z.x)*sin(2*pi*z.y);}

surface s=surface(f,(-1/2,-1/2),(1/2,1/2),50,Spline);

draw(s,mean(palette(s.map(zpart),Rainbow())),black);

grid3(XYZgrid);

Mots-clefs : , , , ,


Official Asymptote example – elliptic

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 18 h 57 min

Figure 0060
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
struct curve {
  real a=0;
  real b=8;

  real y2(real x) {
    return x^3+a*x+b;
  }

  real disc() {
    return -16*(4*a*a*a+27*b*b);
  }

  real lowx () {
    return sqrt(-a/3);
  }

  int comps() {
    if (a < 0) {
      real x=sqrt(-a/3);
      return y2(x) < 0 ? 2 : 1;
    }
    return 1;
  }

  void locus(picture pic=currentpicture, real m, real M, int n=100,
             pen p=currentpen) {
    path flip(path p, bool close) {
      path pp=reverse(yscale(-1)*p)..p;
      return close ? pp..cycle : pp;
    }
    path section(real m, real M, int n) {
      guide g;
      real width=(M-m)/n;
      for(int i=0; i <= n; ++i) {
        real x=m+width*i;
        real yy=y2(x);
        if (yy > 0)
          g=g..(x,sqrt(yy));
      }
      return g;
    }

    if (comps() == 1) {
      draw(pic,flip(section(m,M,n),false),p);
    }
    else {
      real x=lowx(); // The minimum on x^3+ax+b
      if (m < x)
        draw(pic,flip(section(m,min(x,M),n),true),p);
      if (x < M)
        draw(pic,flip(section(max(x,m),M,n),false),p);
    }
  }

  pair neg(pair P) {
    return finite(P.y) ? yscale(-1)*P : P;
  }

  pair add(pair P, pair Q) {
    if (P.x == Q.x && P.x != Q.x)
      return (0,infinity);
    else {
      real lambda=P == Q ? (3*P.x^2+a)/(2*P.y) : (Q.y-P.y)/(Q.x-P.x);
      real Rx=lambda^2-P.x-Q.x;
      return (Rx,(P.x-Rx)*lambda-P.y);
    }
  }
}

import graph;
import math;

size(0,200);

curve c; c.a=-1; c.b=4;

pair oncurve(real x) 
{
  return (x,sqrt(c.y2(x)));
}

picture output;

axes();
c.locus(-4,3,.3red+.7blue);

pair P=oncurve(-1),Q=oncurve(1.2);
pair PP=c.add(P,P),sum=c.add(P,Q);

save();

drawline(P,Q,dashed);
drawline(c.neg(sum),sum,dashed);
dot("$P$", P, NW);
dot("$Q$", Q, SSE);
dot(c.neg(sum));
dot("$P+Q$", sum, 2SW);

add(output,currentpicture.fit(),(-0.5cm,0),W);

restore();

save();

drawline(P,c.neg(PP),dashed);
drawline(c.neg(PP),PP,dashed);
dot("$P$", P, NW);
dot(c.neg(PP));
dot("$2P$", PP, SW);

add(output,currentpicture.fit(),(0.5cm,0),E);

shipout(output);
    
restore();

Mots-clefs : , ,


Official Asymptote example – epix

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

Figure 0061
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(200,200,IgnoreAspect);

currentprojection=perspective(4,2,3);

real f(pair z) {return z.y^3/2-3z.x^2*z.y;}

draw(surface(f,(-1,-1),(1,1),nx=10,Spline),green);
draw(Label("$y$",1),(0,0,0)--(0,2,0),red,Arrow3);

draw(Label("$x$",1),(0,0,0)--(2,0,0),red,Arrow3);
draw(Label("$z$",1),(0,0,0)--(0,0,2.5),red,Arrow3);
label("$z=\frac{1}{2}y^3-3x^2y$",(1,1,1),NE);

Mots-clefs : , ,


Official Asymptote example – equilateral

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

Figure 0062
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(10cm,0);
import math;

pair b=(0,0), c=(1,0);
pair a=extension(b,b+dir(60),c,c+dir(120));
pair d=extension(b,b+dir(30),a,a+dir(270));

draw(a--b--c--a--d--b^^d--c);
label("$A$",a,N);
label("$B$",b,W);
label("$C$",c,E);
label("$D$",d,S);

Mots-clefs : , ,


Official Asymptote example – equilchord

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

Figure 0063
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(0,150);
currentprojection=perspective(5,-4,6);
currentlight=(-1,-1,2);
real t=0.5;

real F(pair z) {
  return (z.x^2+z.y^2 <= 1) ? sqrt(3)*(sqrt(1-z.x^2)-abs(z.y)) : 0; 
}

real a=1.5;
draw((-a,-a,0)--(-a,a,0)--(a,a,0)--(a,-a,0)--cycle,lightgray);

xaxis3(Label("$x$",1),red,Arrow3);
yaxis3(Label("$y$",1),red,Arrow3);
draw(circle((0,0,0),1),dashed);
draw(surface(F,(-1,-1),(t,1),20,monotonic),green,black);
real y=sqrt(1-t^2);
draw((t,y,0)--(t,-y,0)--(t,0,sqrt(3)*y)--cycle,blue);
label("$1$",(1,0,0),-Y+X);

Mots-clefs : , ,


Official Asymptote example – errorbars

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

Figure 0064
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

picture pic;
real xsize=200, ysize=140;
size(pic,xsize,ysize,IgnoreAspect);

pair[] f={(5,5),(50,20),(90,90)};
pair[] df={(0,0),(5,7),(0,5)};

errorbars(pic,f,df,red);
draw(pic,graph(pic,f),"legend",
     marker(scale(0.8mm)*unitcircle,red,FillDraw(blue),above=false));

scale(pic,true);

xaxis(pic,"$x$",BottomTop,LeftTicks);
yaxis(pic,"$y$",LeftRight,RightTicks);
add(pic,legend(pic),point(pic,NW),20SE,UnFill);

picture pic2;
size(pic2,xsize,ysize,IgnoreAspect);

frame mark;
filldraw(mark,scale(0.8mm)*polygon(6),green,green);
draw(mark,scale(0.8mm)*cross(6),blue);

draw(pic2,graph(pic2,f),marker(mark,markuniform(5)));

scale(pic2,true);

xaxis(pic2,"$x$",BottomTop,LeftTicks);
yaxis(pic2,"$y$",LeftRight,RightTicks);

yequals(pic2,55.0,red+Dotted);
xequals(pic2,70.0,red+Dotted);

// Fit pic to W of origin:
add(pic.fit(),(0,0),W);

// Fit pic2 to E of (5mm,0):
add(pic2.fit(),(5mm,0),E);


Mots-clefs : , , , ,


Official Asymptote example – exp

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 23 h 57 min

Figure 0065
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(150,0);

real f(real x) {return exp(x);}
pair F(real x) {return (x,f(x));}

xaxis("$x$");
yaxis("$y$",0);

draw(graph(f,-4,2,operator ..),red);

labely(1,E);
label("$e^x$",F(1),SE);


Mots-clefs : ,


Official Asymptote example – extrudedcontour

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 0 h 57 min

Figure 0066
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import contour;
import palette;
import graph3;
currentprojection=orthographic(25,10,10);
size(0,12cm);
real a=3;
real b=4;
real f(pair z) {return (z.x+z.y)/(2+cos(z.x)*sin(z.y));}
guide[][] g=contour(f,(-10,-10),(10,10),new real[]{8},150);

for(guide p:g[0]){
  draw(extrude(p,8Z),palered);
  draw(path3(p),red+2pt);
}

draw(lift(f,g),red+2pt);

surface s=surface(f,(0,0),(10,10),20,Spline);
s.colors(palette(s.map(zpart),Rainbow()+opacity(0.5)));
draw(s);
axes3("$x$","$y$","$z$",Arrow3);


Mots-clefs : , , , ,


Official Asymptote example – fano

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 1 h 57 min

Figure 0067
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import math;

size(100,0);

pair z4=(0,0);
pair z7=(2,0);
pair z1=point(rotate(60)*(z4--z7),1);

pair z5=interp(z4,z7,0.5);
pair z3=interp(z7,z1,0.5);
pair z2=interp(z1,z4,0.5);
pair z6=extension(z4,z3,z7,z2);

draw(z4--z7--z1--cycle);
draw(z4--z3);
draw(z7--z2);
draw(z1--z5);
draw(circle(z6,abs(z3-z6)));

label("1",z1,dir(z5--z1));
label("2",z2,dir(z7--z2));
label("3",z3,dir(z4--z3));
label("4",z4,dir(z3--z4));
label("5",z5,dir(z1--z5));
label("6",z6,2.5E+0.1*N);
label("7",z7,dir(z2--z7));



Mots-clefs : , , , ,


Official Asymptote example – fermi

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 2 h 57 min

Figure 0068
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import feynman;

// set default line width to 0.8bp
currentpen = linewidth(0.8);

// scale all other defaults of the feynman module appropriately
fmdefaults();

// disable middle arrows
currentarrow = None;

// define vertex and external points

pair xu = (-40,+45);
pair xl = (-40,-45);
pair yu = (+40,+45);
pair yl = (+40,-45);

pair zu = (  0,+ 5);
pair zl = (  0,- 5);

// define mid points

pair mxu = (xu+zu)/2;
pair mxl = (xl+zl)/2;
pair myu = (yu+zu)/2;
pair myl = (yl+zl)/2;

// draw fermion lines
drawFermion(xu--zu--yu);
drawFermion(xl--zl--yl);

// draw vertices
drawVertexOX(zu);
drawVertexOX(zl);

// draw gluon. Note that the underlying fermion line is blotted out.
drawGluon(arc((0,0),mxu,myl,CW));

// shipout

Mots-clefs : ,


Official Asymptote example – filegraph

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 3 h 57 min

Figure 0069
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(200,150,IgnoreAspect);

file in=line(input("filegraph.dat"));
real[][] a=dimension(in,0,0);
a=transpose(a);

real[] x=a[0];
real[] y=a[1];

draw(graph(x,y),red);

xaxis("$x$",BottomTop,LeftTicks);
yaxis("$y$",LeftRight,RightTicks);

Mots-clefs : ,


Official Asymptote example – filesurface

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 4 h 57 min

Figure 0070
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import palette;

size3(200,IgnoreAspect);

file in=line(input("filesurface.dat"));
real[] x=in;
real[] y=in;

real[][] f=dimension(in,0,0);

triple f(pair t) {
  int i=round(t.x);
  int j=round(t.y);
  return (x[i],y[j],f[i][j]);
}

surface s=surface(f,(0,0),(x.length-1,y.length-1),x.length-1,y.length-1);
real[] level=uniform(min(f)*(1-sqrtEpsilon),max(f)*(1+sqrtEpsilon),4);

s.colors(palette(s.map(new real(triple v) {return find(level >= v.z);}),
                 Rainbow())); 

draw(s,meshpen=thick());

triple m=currentpicture.userMin;
triple M=currentpicture.userMax;
triple target=0.5*(m+M);
currentprojection=perspective(camera=target+realmult(dir(68,225),M-m),
                              target=target);

xaxis3("$x$",Bounds,InTicks);
yaxis3("$y$",Bounds,InTicks(Step=1,step=0.1));
zaxis3("$z$",Bounds,InTicks);

Mots-clefs : , , , , ,


Official Asymptote example – fillcontour

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 5 h 57 min

Figure 0071
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
import palette;
import contour;

size(12cm,IgnoreAspect);

pair a=(pi/2,0);
pair b=(1.5*pi+epsilon,2pi);

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

int N=100;
int Divs=10;

defaultpen(1bp);

bounds range=bounds(-1,1);
    
real[] Cvals=uniform(range.min,range.max,Divs);
guide[][] g=contour(f,a,b,Cvals,N,operator --);

pen[] Palette=quantize(Rainbow(),Divs);

pen[][] interior=interior(g,extend(Palette,grey,black));
fill(g,interior);
draw(g);

palette("$f(x,y)$",range,point(SE)+(0.5,0),point(NE)+(1,0),Right,Palette,
        PaletteTicks("$%+#0.1f$",N=Divs));

Mots-clefs : , , , , ,


Official Asymptote example – fin

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 6 h 57 min

Figure 0072
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;
import palette;

int N = 26;
real[] C = array(N,0); 
real[][] A = new real[N][N];
for(int i = 0; i < N; ++i)
  for(int j = 0; j < N; ++j)
    A[i][j] = 0;

real Tb = 100; // deg C
real h = 240; // 240 W/m^2 K
real k = 240; // W/m K
real Tinf = 20; // deg C
real L = 12; // cm
real t = 2; // cm

real delta = 0.01; // 1 cm = 0.01 m

// (1,2)-(2,2)-(3,2)-...-(13,2)
//   |     |     |          |
// (1,1)-(2,1)-(3,1)-...-(13,1)
//
//        |
//       \ /
//        V
//
// 13-14-15-...-24-25
//  |  |  | ...  |  |
//  0- 1- 2-...-11-12

// but, note zero-based array indexing, so counting starts at 0
int indexof(int m, int n)
{
  return 13(n-1)+m-1;
}

int i = 0;

// fixed temperature bottom left
A[i][indexof(1,1)] = 1; C[i] = Tb;
++i;
// fixed temperature middle left
A[i][indexof(1,2)] = 1; C[i] = Tb;
++i;

// interior nodes
for(int m = 2; m<13; ++m)
{
  A[i][indexof(m,2)] = -4;
  A[i][indexof(m-1,2)] = A[i][indexof(m+1,2)] = 1;
  A[i][indexof(m,1)] = 2;
  C[i] = 0;
  ++i;
}

// convective bottom side nodes
for(int m = 2; m<13; ++m)
{
  A[i][indexof(m,1)] = -(2+h*delta/k);
  A[i][indexof(m-1,1)] = A[i][indexof(m+1,1)] = 0.5;
  A[i][indexof(m,2)] = 1;
  C[i] = -h*delta*Tinf/k;
  ++i;
}

// convective bottom right corner node
A[i][indexof(13,2)] = A[i][indexof(12,1)] = 0.5;
A[i][indexof(13,1)] = -(1+h*delta/k);
C[i] = -h*delta*Tinf/k;
++i;

// convective middle right side node
A[i][indexof(13,2)] = -(2+h*delta/k);
A[i][indexof(13,1)] = 1;
A[i][indexof(12,2)] = 1;
C[i] = -h*delta*Tinf/k;
++i;

real[] T = solve(A,C);

pen[] Palette = Gradient(256,blue,cyan,yellow,orange,red);

real[][] T = {T[0:13],T[13:26],T[0:13]};
T = transpose(T);

size3(15cm);
real w = 10;
real h = 5;
currentprojection = orthographic(2*(L,h,w),Y);
draw((L,t,0)--(L,0,0)--(L,0,w)--(0,0,w)--(0,-h,w));
draw((0,t,w)--(0,t+h,w)--(0,t+h,0)--(0,t,0));
draw((L,0,w)--(L,t,w)--(0,t,w)--(0,t,0)--(L,t,0)--(L,t,w));

real wo2 = 0.5*w;
draw((0,0,wo2)--(0,t,wo2)--(L,t,wo2)--(L,0,wo2)--cycle);

// centre points
surface square = surface(shift(-0.5,-0.5,wo2)*unitsquare3);
surface bottomsquare = surface(shift(-0.5,-0.5,wo2)*scale(1,0.5,1)*unitsquare3);
surface topsquare = surface(shift(-0.5,0,wo2)*scale(1,0.5,1)*unitsquare3);
surface leftsquare = surface(shift(-0.5,-0.5,wo2)*scale(0.5,1,1)*unitsquare3);
surface rightsquare = surface(shift(0,-0.5,wo2)*scale(0.5,1,1)*unitsquare3);
surface NEcorner = surface(shift(0,0,wo2)*scale(0.5,0.5,1)*unitsquare3);
surface SEcorner = surface(shift(0,-0.5,wo2)*scale(0.5,0.5,1)*unitsquare3);
surface SWcorner = surface(shift(-0.5,-0.5,wo2)*scale(0.5,0.5,1)*unitsquare3);
surface NWcorner = surface(shift(-0.5,0,wo2)*scale(0.5,0.5,1)*unitsquare3);

material lookupColour(int m,int n)
{
  int index = round(Palette.length*(T[m-1][n-1]-60)/(100-60));
  if(index >= Palette.length) index = Palette.length-1;
  return emissive(Palette[index]);
}

draw(shift(0,1,0)*rightsquare,lookupColour(1,2));
for(int i = 2; i < 13; ++i)
{
  draw(shift(i-1,1,0)*square,lookupColour(i,2));
}
draw(shift(12,1,0)*leftsquare,lookupColour(13,2));

draw(shift(0,2,0)*SEcorner,lookupColour(1,3));
draw(shift(0,0,0)*NEcorner,lookupColour(1,1));
for(int i = 2; i < 13; ++i)
{
  draw(shift(i-1,0,0)*topsquare,lookupColour(i,1));
  draw(shift(i-1,2,0)*bottomsquare,lookupColour(i,3));
}
draw(shift(12,2,0)*SWcorner,lookupColour(13,3));
draw(shift(12,0,0)*NWcorner,lookupColour(13,1));

// annotations
draw("$x$",(0,-h/2,w)--(L/4,-h/2,w),Y,Arrow3(HookHead2(normal=Z)),BeginBar3(Y));
draw("$y$",(0,0,1.05*w)--(0,2t,1.05*w),Z,Arrow3(HookHead2(normal=X)),
     BeginBar3(Z));
draw("$z$",(L,-h/2,0)--(L,-h/2,w/4),Y,Arrow3(HookHead2(normal=X)),BeginBar3(Y));

draw("$L$",(0,-h/4,w)--(L,-h/4,w),-Y,Arrows3(HookHead2(normal=Z)),
     Bars3(Y),PenMargins2);
draw("$w$",(L,-h/4,0)--(L,-h/4,w),-Y,Arrows3(HookHead2(normal=X)),
     Bars3(Y),PenMargins2);
draw("$t$",(1.05*L,0,0)--(1.05*L,t,0),-2Z,Arrows3(HookHead2(normal=Z)),
     Bars3(X),PenMargins2);

label(ZY()*"$T_b$",(0,t+h/2,wo2));

label("$h$,$T_\infty$",(L/2,t+h/2,0),Y);
path3 air = (L/2,t+h/3,w/3.5)--(1.5*L/2,t+2*h/3,w/8);
draw(air,EndArrow3(TeXHead2));
draw(shift(0.5,0,0)*air,EndArrow3(TeXHead2));
draw(shift(1.0,0,0)*air,EndArrow3(TeXHead2));

Mots-clefs : , , ,


Official Asymptote example – fjortoft

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

Figure 0073
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(15cm,0);

pair d=(1.5,1);
real s=d.x+1;

picture box(string s) {
  picture pic;
  draw(pic,box(0,d));
  label(pic,s,d/2);
  return pic;
}

add(box("$k_1$"));
add(shift(s)*box("$k_2$"));
add(shift(s)^2*box("$k_3$"));

path g=(d.x,d.y/2)--(s,d.y/2);
path G=(d.x/2,-(s-d.x))--(d.x/2,0);

draw(Label(baseline("$\ldots$")),shift(-s)*g,BeginArrow,BeginPenMargin);
draw(Label("$Z_1$"),g,BeginArrow,BeginPenMargin);
draw(Label("$E_1$",LeftSide),g,Blank);
draw(Label("$Z_3$"),shift(s)*g,Arrow,PenMargin);
draw(Label("$E_3$",LeftSide),shift(s)*g,Blank);
draw(Label("$Z_2$"),shift(s)*G,Arrow,PenMargin);
draw(Label("$E_2$",LeftSide),shift(s)*G,Blank);
draw(Label(baseline("$\ldots$")),shift(s)^2*g,Arrow,PenMargin);

Mots-clefs : ,


Official Asymptote example – floatingdisk

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 8 h 57 min

Figure 0074
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import trembling; 
settings.outformat="pdf"; 
size(6cm,0); 
 
real R=1/5; 
real h=0.5; 
real d=1/12; 
real l=.7; 
 
pair pA=(-l,0); 
pair pB=(l,0); 
 
path waterline=tremble(addnodes(pA..pB,1),angle=10,frequency=0.1,random=50); 
path disk=shift(0,-d)*(scale(R)*unitcircle); 
path water=waterline--(l,-h)--(-l,-h)--(-l,0)--cycle; 
path container=(l,1/7)--(l,-h)--(-l,-h)--(-l,1/7); 
 
filldraw(disk,red,linewidth(.3)); 
fill(water,mediumgrey+opacity(0.5)); 
draw(waterline); 
 
draw(container,linewidth(1.5)); 
 
shipout(bbox(2mm,Fill(white))); 

Mots-clefs : ,


Official Asymptote example – floor

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 9 h 57 min

Figure 0075
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
unitsize(1cm);

real Floor(real x) {return floor(x);}

pair[] Close;
pair[] Open;

bool3 branch(real x) {
  static real lasty;
  static bool first=true;
  real y=floor(x);
  bool samebranch=first || lasty == y; 
  first=false;
  if(samebranch) lasty=x;
  else {
    Close.push((x,lasty));
    Open.push((x,y));
  }
  lasty=y;
  return samebranch ? true : default;
};

draw(graph(Floor,-5.5,5.5,500,branch)); 
axes("$x$",rotate(0)*"$\lfloor x\rfloor$",red);

dot(Close);
dot(Open,UnFill);

Mots-clefs : ,


Official Asymptote example – flow

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 10 h 57 min

Figure 0076
(Compiled with Asymptote version 1.87svn-r4652)
/* 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));


Mots-clefs :


Official Asymptote example – flowchartdemo

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 11 h 57 min

Figure 0077
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,300);

import flowchart;

block block1=rectangle(Label("Example",magenta),
                       pack(Label("Start:",heavygreen),"",Label("$A:=0$",blue),
                            "$B:=1$"),(-0.5,3),palegreen,paleblue,red);
block block2=diamond(Label("Choice?",blue),(0,2),palegreen,red);
block block3=roundrectangle("Do something",(-1,1));
block block4=bevel("Don't do something",(1,1));
block block5=circle("End",(0,0));

draw(block1);
draw(block2);
draw(block3);
draw(block4);
draw(block5);

add(new void(picture pic, transform t) {
    draw(pic,path(new pair[]{block1.right(t),block2.top(t)},Horizontal),
         Arrow,PenMargin);
    draw(pic,Label("Yes",0.5,NW),path(new pair[]{block2.left(t),block3.top(t)},
                                   Horizontal),Arrow,PenMargin);
    draw(pic,Label("No",0.5,NE),path(new pair[]{block2.right(t),block4.top(t)},
                                    Horizontal),Arrow,PenMargin);
    draw(pic,path(new pair[]{block3.bottom(t),block5.left(t)},Vertical),
         Arrow,PenMargin);
    draw(pic,path(new pair[]{block4.bottom(t),block5.right(t)},Vertical),
         Arrow,PenMargin);
  });

Mots-clefs :


Official Asymptote example – fractaltree

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 12 h 57 min

Figure 0078
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);

path ltrans(path p,int d)
{
  path a=rotate(65)*scale(0.4)*p;
  return shift(point(p,(1/d)*length(p))-point(a,0))*a;
}
path rtrans(path p, int d)
{
  path a=reflect(point(p,0),point(p,length(p)))*rotate(65)*scale(0.35)*p;
  return shift(point(p,(1/d)*length(p))-point(a,0))*a;
}

void drawtree(int depth, path branch)
{
  if(depth == 0) return;
  real breakp=(1/depth)*length(branch);
  draw(subpath(branch,0,breakp),deepgreen);
  drawtree(depth-1,subpath(branch,breakp,length(branch)));
  drawtree(depth-1,ltrans(branch,depth));
  drawtree(depth-1,rtrans(branch,depth));
  return;
}

path start=(0,0)..controls (-1/10,1/3) and (-1/20,2/3)..(1/20,1);
drawtree(6,start);


Mots-clefs : ,


Official Asymptote example – functionshading

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 13 h 57 min

Figure 0079
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);

settings.tex="pdflatex";

// PostScript Calculator routine to convert from [0,1]x[0,1] to RG:
string redgreen="0";

// PostScript Calculator routine to convert from [0,1]x[0,1] to HS to RGB:
// (http://www.texample.net/tikz/examples/hsv-shading):
string hsv="0.5 sub exch 0.5 sub exch
2 copy 2 copy 0 eq exch 0 eq and { pop pop 0.0 } {atan 360.0 div}
ifelse dup 360 eq { pop 0.0 }{} ifelse 3 1 roll dup mul exch dup mul add
sqrt 2.5 mul 0.25 sub 1 1 index 1.0
eq { 3 1 roll pop pop dup dup } { 3 -1 roll 6.0 mul dup 4 1 roll floor dup
5 1 roll 3 index sub neg 1.0 3 index sub 2 index mul 6 1 roll dup 3 index
mul neg 1.0 add 2 index mul 7 1 roll neg 1.0 add 2 index mul neg 1.0 add 1
index mul 7 2 roll pop pop dup 0 eq { pop exch pop } { dup 1 eq { pop exch
4 1 roll exch pop } { dup 2 eq { pop 4 1 roll pop } { dup 3 eq { pop exch 4
2 roll pop } { dup 4 eq { pop exch pop 3 -1 roll } { pop 3 1 roll exch pop
} ifelse } ifelse } ifelse } ifelse } ifelse } ifelse cvr 3 1 roll cvr 3 1
roll cvr 3 1 roll";

path p=unitcircle;
functionshade(p,rgb(zerowinding),redgreen);
layer();
draw(p);

path g=shift(2*dir(-45))*p;
functionshade(g,rgb(zerowinding),hsv);
layer();
draw(g);

Mots-clefs :


Official Asymptote example – galleon

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 14 h 57 min

Figure 0080
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import obj;

size(15cm);
currentprojection=orthographic(0,2,5,up=Y);

// A compressed version of the required data file may be obtained from:
// http://www.cs.technion.ac.il/~irit/data/Viewpoint/galleon.obj.gz

pen[] surfacepen={darkred,brown,darkred+orange,heavyred,heavyred,darkred+orange,
                  palegreen+blue+lightgrey,darkred,darkred,yellow,darkred,white,
                  white,white,white,white,white};
surfacepen.cyclic=true;

draw(obj("galleon.obj",verbose=false,surfacepen));

Mots-clefs : , ,


Official Asymptote example – gamma

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 15 h 57 min

Figure 0081
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(300,IgnoreAspect);

bool3 branch(real x)
{
  static int lastsign=0;
  if(x <= 0 && x == floor(x)) return false;
  int sign=sgn(gamma(x));
  bool b=lastsign == 0 || sign == lastsign;
  lastsign=sign;
  return b ? true : default;
}

draw(graph(gamma,-4,4,n=2000,branch),red);
 
scale(false);
xlimits(-4,4);
ylimits(-6,6);
crop();

xaxis("$x$",RightTicks(NoZero));
yaxis(LeftTicks(NoZero));

label("$\Gamma(x)$",(1,2),red);

Mots-clefs : ,


Official Asymptote example – gamma3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 16 h 57 min

Figure 0082
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import palette;

size(12cm,IgnoreAspect);
currentprojection=orthographic(1,-2,1);

real X=4.5;
real M=abs(gamma((X,0)));

pair Gamma(pair z) 
{
  return (z.x > 0 || z != floor(z.x)) ? gamma(z) : M;
}

real f(pair z) {return min(abs(Gamma(z)),M);}

surface s=surface(f,(-2.1,-2),(X,2),70,Spline);

real Arg(triple v)
{
  return degrees(Gamma((v.x,v.y)),warn=false);
}

s.colors(palette(s.map(Arg),Wheel()));
draw(s);

xaxis3("$\mathop{\rm Re} z$",Bounds,InTicks);
yaxis3("$\mathop{\rm Im} z$",Bounds,InTicks(beginlabel=false));
zaxis3("$|\Gamma(z)|$",Bounds,InTicks);

Mots-clefs : , , , ,


Official Asymptote example – generalaxis

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 17 h 57 min

Figure 0083
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(0,100);

path g=ellipse((0,0),1,2);

scale(true);

axis(Label("C",align=10W),g,LeftTicks(endlabel=false,8,end=false),
     ticklocate(0,360,new real(real v) {
         path h=(0,0)--max(abs(max(g)),abs(min(g)))*dir(v);
         return intersect(g,h)[0];}));

Mots-clefs : ,


Official Asymptote example – generalaxis3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 18 h 57 min

Figure 0084
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(0,100);

path3 g=yscale3(2)*unitcircle3;
currentprojection=perspective(10,10,10);

axis(Label("C",position=0,align=15X),g,InTicks(endlabel=false,8,end=false),
     ticklocate(0,360,new real(real v) {
         path3 h=O--max(abs(max(g)),abs(min(g)))*dir(90,v);
         return intersect(g,h)[0];},
       new triple(real t) {return cross(dir(g,t),Z);}));


Mots-clefs : ,


Official Asymptote example – graphmarkers

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

Figure 0085
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(200,100,IgnoreAspect);

markroutine marks() {
  return new void(picture pic=currentpicture, frame f, path g) {
    path p=scale(1mm)*unitcircle;
    for(int i=0; i <= length(g); ++i) {
      pair z=point(g,i);
      frame f;
      if(i % 4 == 0) {
        fill(f,p);
        add(pic,f,z);
      } else {
        if(z.y > 50) {
          pic.add(new void(frame F, transform t) {
              path q=shift(t*z)*p;
              unfill(F,q);
              draw(F,q);
            });
        } else {
          draw(f,p);
          add(pic,f,z);
        }
      }
    }
  };
}

pair[] f={(5,5),(40,20),(55,51),(90,30)};

draw(graph(f),marker(marks()));

scale(true);

xaxis("$x$",BottomTop,LeftTicks);
yaxis("$y$",LeftRight,RightTicks);

Mots-clefs : ,


Official Asymptote example – grid

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

Figure 0086
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import math;
size(100,0);

add(shift(-5,-5)*grid(10,10));

dot((0,0),red);


Mots-clefs :


Official Asymptote example – grid3xyz

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

Figure 0087
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import grid3;

size(8cm,0,IgnoreAspect);
currentprojection=orthographic(0.5,1,0.5);

scale(Linear, Linear, Log);

limits((-2,-2,1),(0,2,100));

grid3(XYZgrid);

xaxis3(Label("$x$",position=EndPoint,align=S),Bounds(Min,Min),
       OutTicks());
yaxis3(Label("$y$",position=EndPoint,align=S),Bounds(Min,Min),OutTicks());
zaxis3(Label("$z$",position=EndPoint,align=(-1,0.5)),Bounds(Min,Min),
       OutTicks(beginlabel=false));


Mots-clefs : ,


Official Asymptote example – hatch

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

Figure 0088
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,100);
import patterns;

add("hatch",hatch());
add("hatchback",hatch(NW));
add("crosshatch",crosshatch(3mm));

real s=1.25;
filldraw(unitsquare,pattern("hatch"));
filldraw(shift(s,0)*unitsquare,pattern("hatchback"));
filldraw(shift(2s,0)*unitsquare,pattern("crosshatch"));

Mots-clefs : , ,


Official Asymptote example – helix

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 23 h 57 min

Figure 0089
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(0,200);
size3(200,IgnoreAspect);

currentprojection=orthographic(4,6,3);

real x(real t) {return cos(2pi*t);}
real y(real t) {return sin(2pi*t);}
real z(real t) {return t;}

path3 p=graph(x,y,z,0,2.7,operator ..);

draw(p,Arrow3);

scale(true);

xaxis3(XZ()*"$x$",Bounds,red,InTicks(Label,2,2));
yaxis3(YZ()*"$y$",Bounds,red,InTicks(beginlabel=false,Label,2,2));
zaxis3(XZ()*"$z$",Bounds,red,InTicks);

Mots-clefs :


Official Asymptote example – hierarchy

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 0 h 57 min

Figure 0090
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
texpreamble("\def\Ham{\mathop {\rm Ham}\nolimits}");
pair align=2N;
frame f;
ellipse(f,Label("$\Ham(r,2)$",(0,0)),lightblue,Fill,above=false);
ellipse(f,Label("BCH Codes",point(f,N),align),green,Fill,above=false);
ellipse(f,Label("Cyclic Codes",point(f,N),align),lightmagenta,Fill,above=false);
ellipse(f,Label("Linear Codes",point(f,N),align),-4mm,orange,Fill,above=false);
box(f,Label("General Codes",point(f,N),align),2mm,yellow,Fill,above=false);
add(f);

Mots-clefs : , , ,


Official Asymptote example – histogram

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 1 h 57 min

Figure 0091
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
import stats;

size(400,200,IgnoreAspect);

int n=10000;
real[] a=new real[n];
for(int i=0; i < n; ++i) a[i]=Gaussrand();

draw(graph(Gaussian,min(a),max(a)),blue);

// Optionally calculate "optimal" number of bins a la Shimazaki and Shinomoto.
int N=bins(a);

histogram(a,min(a),max(a),N,normalize=true,low=0,lightred,black,bars=false);

xaxis("$x$",BottomTop,LeftTicks);
yaxis("$dP/dx$",LeftRight,RightTicks(trailingzero));


Mots-clefs : ,


Official Asymptote example – hyperboloid

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 2 h 57 min

Figure 0092
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);
import solids;

currentprojection=perspective(4,4,3);
revolution hyperboloid=revolution(new real(real x) {return sqrt(1+x*x);},
                                  -2,2,20,operator..,X);
draw(surface(hyperboloid),green);
draw(hyperboloid,6,blue,longitudinalpen=nullpen);

Mots-clefs : , , ,


Official Asymptote example – hyperboloidsilhouette

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 3 h 57 min

Figure 0093
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);
import solids;
settings.render=0;
settings.prc=false;

currentprojection=perspective(4,4,3);
revolution hyperboloid=revolution(new real(real x) {return sqrt(1+x*x);},
                                  -2,2,20,operator..,X);
draw(hyperboloid.silhouette(64),blue);

Mots-clefs : , , ,


Official Asymptote example – icon

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 4 h 57 min

Figure 0094
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(30,30,IgnoreAspect);

real f(real t) {return t < 0 ? -1/t : -0.5/t;}

picture logo(pair s=0, pen q) 
{
  picture pic;
  pen p=linewidth(3)+q;
  real a=-0.5;
  real b=1;
  real eps=0.1;
  draw(pic,shift((eps,-f(a)))*graph(f,a,-eps),p);
  real c=0.5*a;
  pair z=(0,f(c)-f(a));
  draw(pic,z+c+eps--z,p);
  yaxis(pic,p);
  return shift(s)*pic;
} 

add(logo(red));

Mots-clefs : ,


Official Asymptote example – image

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 5 h 57 min

Figure 0095
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(12cm,12cm);

import graph;
import palette;

int n=256;
real ninv=2pi/n;
real[][] v=new real[n][n];

for(int i=0; i < n; ++i)
  for(int j=0; j < n; ++j)
    v[i][j]=sin(i*ninv)*cos(j*ninv);

pen[] Palette=BWRainbow();

picture bar;

bounds range=image(v,(0,0),(1,1),Palette);
palette(bar,"$A$",range,(0,0),(0.5cm,8cm),Right,Palette,
        PaletteTicks("$%+#.1f$"));
add(bar.fit(),point(E),30E);


Mots-clefs : , ,


Official Asymptote example – imagecontour

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 6 h 57 min

Figure 0096
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
import palette;
import contour;

size(10cm,10cm,IgnoreAspect);

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

real f(real x, real y) {return cos(x)*sin(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);
    
// Major contours

real[] Cvals=uniform(range.min,range.max,Divs);
draw(contour(f,a,b,Cvals,N,operator --),Tickpen);

// Minor contours
real[] cvals;
for(int i=0; i < Cvals.length-1; ++i)
  cvals.append(uniform(Cvals[i],Cvals[i+1],divs)[1:divs]);
draw(contour(f,a,b,cvals,N,operator --),tickpen);

xaxis("$x$",BottomTop,LeftTicks,above=true);
yaxis("$y$",LeftRight,RightTicks,above=true);

palette("$f(x,y)$",range,point(NW)+(0,0.5),point(NE)+(0,1),Top,Palette,
        PaletteTicks(N=Divs,n=divs,Tickpen,tickpen));

Mots-clefs : , , , ,


Official Asymptote example – imagehistogram

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

Figure 0097
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import stats;
import graph; 
import palette; 
import contour; 
 
size(20cm);

scale(false);

pair[] data=new pair[50000];
for(int i=0; i < data.length; ++i)
  data[i]=Gaussrandpair(); 
 
// Histogram limits and number of bins 
pair datamin=(-0.15,-0.15); 
pair datamax=(0.15,0.15); 
int Nx=30; 
int Ny=30; 

int[][] bins=frequency(data,datamin,datamax,Nx,Ny);
 
real[] values=new real[Nx*Ny]; 
pair[] points=new pair[Nx*Ny];
int k=0; 
real dx=(datamax.x-datamin.x)/Nx;
real dy=(datamax.y-datamin.y)/Ny;
for(int i=0; i < Nx; ++i) {
  for(int j=0; j < Ny; ++j) {
    values[k]=bins[i][j]; 
    points[k]=(datamin.x+(i+0.5)*dx,datamin.y+(j+0.5)*dy); 
    ++k; 
  }
} 
 
// Create a color palette 
pen[] InvGrayscale(int NColors=256) {
  real ninv=1.0/(NColors-1.0); 
  return sequence(new pen(int i) {return gray(1-17*i*ninv);},NColors); 
} 
 
// Draw the histogram, with axes 
bounds range=image(points,values,Range(0,40),InvGrayscale()); 
draw(contour(points,values,new real[] {1,2,3,4,8,12,16,20,24,28,32,36,40},
             operator--),blue); 
xaxis("$x$",BottomTop,LeftTicks,above=true); 
yaxis("$y$",LeftRight,RightTicks,above=true); 


Mots-clefs : , , , ,


Official Asymptote example – impact

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 8 h 57 min

Figure 0098
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
// Contributed by Philippe Ivaldi.

import graph3 ;
import contour;
size (6cm,0);
currentprojection=orthographic(1,1,1) ;

real rc=1, hc=2, c=rc/hc;
draw(shift(hc*Z)*scale(rc,rc,-hc)*unitcone,blue);

triple Os=(0.5,0.5,1);
real r=0.5;
draw(shift(Os)*scale3(r)*unitsphere,red);

real a=1+1/c^2;
real b=abs(Os)^2-r^2;

real f(pair z)
{
  real x=z.x, y=z.y;
  return a*x^2-2*Os.x*x+a*y^2-2*Os.y*y-2*Os.z*sqrt(x^2+y^2)/c+b;
}

real g(pair z){return (sqrt(z.x^2+z.y^2))/c;}

draw(lift(g,contour(f,(-rc,-rc),(rc,rc),new real[]{0})),linewidth(2bp)+yellow);

axes3("$x$","$y$","$z$",Arrow3);

Mots-clefs : , , , ,


Official Asymptote example – integraltest

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 9 h 57 min

Figure 0099
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(300,150,IgnoreAspect);

real f(real x) {return 1/x^(1.1);}
pair F(real x) {return (x,f(x));}

dotfactor=7;

void subinterval(real a, real b)
{
  path g=box((a,0),(b,f(b)));
  filldraw(g,lightgray); 
  draw(box((a,f(a)),(b,0)));
}

int a=1, b=9;
  
xaxis("$x$",0,b); 
yaxis("$y$",0); 
 
draw(graph(f,a,b,operator ..),red);
 
int n=2;

for(int i=a; i <= b; ++i) {
  if(i < b) subinterval(i,i+1);
  if(i <= n) labelx(i);
  dot(F(i));
}

int i=n;
labelx("$\ldots$",++i);
labelx("$k$",++i);
labelx("$k+1$",++i);
labelx("$\ldots$",++i);

arrow("$f(x)$",F(i-1.5),NE,1.5cm,red,Margin(0,0.5));


Mots-clefs : ,


Official Asymptote example – irregularcontour

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 10 h 57 min

Figure 0100
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import contour;

size(200);

int n=100;

pair[] points=new pair[n];
real[] values=new real[n];

real f(real a, real b) {return a^2+b^2;}

real r() {return 1.1*(rand()/randMax*2-1);}

for(int i=0; i < n; ++i) {
  points[i]=(r(),r());
  values[i]=f(points[i].x,points[i].y);
}

draw(contour(points,values,new real[]{0.25,0.5,1},operator ..),blue);

Mots-clefs : ,


Official Asymptote example – join

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 11 h 57 min

Figure 0101
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(300,0);
pair[] z=new pair[10];

z[0]=(0,100); z[1]=(50,0); z[2]=(180,0);

for(int n=3; n <= 9; ++n)
  z[n]=z[n-3]+(200,0);

path p=z[0]..z[1]---z[2]::{up}z[3]
&z[3]..z[4]--z[5]::{up}z[6]
&z[6]::z[7]---z[8]..{up}z[9];

draw(p,grey+linewidth(4mm));

dot(z);

Mots-clefs :


Official Asymptote example – join3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 12 h 57 min

Figure 0102
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(200);

currentprojection=orthographic(500,-500,500);

triple[] z=new triple[10];

z[0]=(0,100,0); z[1]=(50,0,0); z[2]=(180,0,0);

for(int n=3; n <= 9; ++n)
  z[n]=z[n-3]+(200,0,0);

path3 p=z[0]..z[1]---z[2]::{Y}z[3]
&z[3]..z[4]--z[5]::{Y}z[6]
&z[6]::z[7]---z[8]..{Y}z[9];

draw(p,grey+linewidth(4mm)+opacity(0.5));

xaxis3(Label(XY()*"$x$",align=-3Y),red,above=true);
yaxis3(Label(XY()*"$y$",align=-3X),red,above=true);

dot(z);


Mots-clefs :


Official Asymptote example – jump

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 13 h 57 min

Figure 0103
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(4inches,0);

real f1(real x) {return (1+x^2);} 
real f2(real x) {return (4-x);}

xaxis("$x$",LeftTicks,Arrow);
yaxis("$y$",RightTicks,Arrow);

draw("$y=1+x^2$",graph(f1,-2,1)); 
dot((1,f1(1)),UnFill);

draw("$y=4-x$",graph(f2,1,5),LeftSide,red,Arrow);
dot((1,f2(1)),red);

Mots-clefs : ,


Official Asymptote example – knots

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 14 h 57 min

Figure 0104
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import syzygy;

Braid initial;
initial.n = 4;
initial.add(bp,1);
initial.add(bp,0);
initial.add(bp,2);
initial.add(bp,1);
initial.add(phi,2);
initial.add(phi,0);

Syzygy pp;
pp.lsym="\Phi\Phi"; pp.codename="PhiAroundPhi";

pp.number=true;
pp.initial=initial;
pp.apply(r4b,2,1);
pp.apply(r4b,0,0);
pp.apply(r4a,1,0);
pp.swap(0,1);
pp.apply(-r4b,1,0);
pp.apply(-r4a,0,1);
pp.apply(-r4a,2,0);
pp.swap(4,5);

pp.draw();


Mots-clefs :


Official Asymptote example – label3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 15 h 57 min

Figure 0105
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

currentprojection=perspective(1,1,1,up=Y);
currentlight=Headlamp;

label(scale(4)*"$\displaystyle\int_{-\infty}^{+\infty} e^{-\alpha x^2}\,dx=
\sqrt{\frac{\pi}{\alpha}}$",O,blue);


Mots-clefs : , ,


Official Asymptote example – label3solid

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 16 h 57 min

Figure 0106
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

currentprojection=perspective(100,100,200,up=Y);
currentlight=Headlamp;

draw(scale3(4)*extrude("$\displaystyle\int_{-\infty}^{+\infty}
e^{-\alpha x^2}\,dx=\sqrt{\frac{\pi}{\alpha}}$",2Z),blue);

Mots-clefs : , , ,


Official Asymptote example – labelbox

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 17 h 57 min

Figure 0107
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,100);
real margin=2mm;
pair z1=(0,1);
pair z0=(0,0);

object label1=draw("small box",box,z1,margin);
object label0=draw("LARGE ELLIPSE",ellipse,z0,margin);

add(new void(frame f, transform t) {
    draw(f,point(label1,SW,t){SW}..{SW}point(label0,NNE,t));
  });

Mots-clefs :


Official Asymptote example – labelsquare

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 18 h 57 min

Figure 0108
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,3cm);
draw(unitsquare);
label("$A$",(0,0),SW);
label("$B$",(1,0),SE);
label("$C$",(1,1),NE);
label("$D$",(0,1),NW);

Mots-clefs : , ,


Official Asymptote example – laserlattice

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

Figure 0109
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
import palette;

int n=256;
pen[] Palette=BWRainbow();

real w(real w0, real z0, real z) {return w0*sqrt(1+(z/z0)^2);}

real pot(real lambda, real w0, real r, real z)
{
  real z0=pi*w0^2/lambda, kappa=2pi/lambda;
  return exp(-2*(r/w(w0,z0,z))^2)*cos(kappa*z)^2;
}

picture make_field(real lambda, real w0)
{
  real[][] v=new real[n][n];
  for(int i=0; i < n; ++i)
    for(int j=0; j < n; ++j)
      v[i][j]=pot(lambda,w0,i-n/2,abs(j-n/2));

  picture p=new picture;
  size(p,250,250,IgnoreAspect);
  real xm=-n/lambda, ym=-n/(2*w0), xx=n/lambda, yx=n/(2*w0);
  image(p,v,(xm,ym),(xx,yx),Palette);
  xlimits(p,xm,xx);
  ylimits(p,ym,yx);
  xaxis(p,"{\Large $z/\frac{\lambda}{2}$}",BottomTop,LeftTicks);
  yaxis(p,"{\Large $r/w_0$}",LeftRight,RightTicks);
  label(p,format("{\LARGE $w_0/\lambda=%.2f$}",w0/lambda),point(p,NW),5N);

  return p;
}

picture p=make_field(160,80);
picture q=make_field(80,80);
picture r=make_field(16,80);
picture s=make_field(2,80);

real margin=1cm;
add(p.fit(),(0,0),margin*NW);
add(q.fit(),(0,0),margin*NE);
add(r.fit(),(0,0),margin*SW);
add(s.fit(),(0,0),margin*SE);

Mots-clefs : , , , , ,


Official Asymptote example – latticeshading

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

Figure 0110
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);

pen[][] p={{white,grey,black},
           {red,green,blue},
           {cyan,magenta,yellow}};

latticeshade(unitsquare,p);

Mots-clefs : , ,


Official Asymptote example – layers

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

Figure 0111
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
usepackage("ocg");
settings.tex="pdflatex";

size(0,150);

pen colour1=red;
pen colour2=green;

pair z0=(0,0);
pair z1=(-1,0);
pair z2=(1,0);
real r=1.5;
path c1=circle(z1,r);
path c2=circle(z2,r);

begin("A");
fill(c1,colour1);
end();

fill(c2,colour2);

picture intersection;
fill(intersection,c1,colour1+colour2);
clip(intersection,c2);

add(intersection);

draw(c1);
draw(c2);

label("$A$",z1);

begin("B");
label("$B$",z2);
end();

pair z=(0,-2);
real m=3;
margin BigMargin=Margin(0,m*dot(unit(z1-z),unit(z0-z)));

draw(Label("$A\cap B$",0),conj(z)--z0,Arrow,BigMargin);
draw(Label("$A\cup B$",0),z--z0,Arrow,BigMargin);
draw(z--z1,Arrow,Margin(0,m));
draw(z--z2,Arrow,Margin(0,m));

Mots-clefs : , , ,


Official Asymptote example – leastsquares

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

Figure 0112
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(400,200,IgnoreAspect);

import graph;
import stats;

file fin=line(input("leastsquares.dat"));

real[][] a=dimension(fin,0,0);
a=transpose(a);

real[] t=a[0], rho=a[1];

// Read in parameters from the keyboard:
//real first=getreal("first");
//real step=getreal("step");
//real last=getreal("last");

real first=100;
real step=50;
real last=700;

// Remove negative or zero values of rho:
t=rho > 0 ? t : null;
rho=rho > 0 ? rho : null;
    
scale(Log(true),Linear(true));

int n=step > 0 ? ceil((last-first)/step) : 0;

real[] T,xi,dxi;

for(int i=0; i <= n; ++i) {
  real first=first+i*step;
  real[] logrho=(t >= first & t <= last) ? log(rho) : null;
  real[] logt=(t >= first & t <= last) ? -log(t) : null;
  
  if(logt.length < 2) break;
  
  // Fit to the line logt=L.m*logrho+L.b:
  linefit L=leastsquares(logt,logrho);
    
  T.push(first);
  xi.push(L.m);
  dxi.push(L.dm);
} 
    
draw(graph(T,xi),blue);
errorbars(T,xi,dxi,red);

crop();

ylimits(0);

xaxis("$T$",BottomTop,LeftTicks);
yaxis("$\xi$",LeftRight,RightTicks);

Mots-clefs : , , ,


Official Asymptote example – legend

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 23 h 57 min

Figure 0113
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph; 
size(8cm,6cm,IgnoreAspect); 
 
typedef real realfcn(real); 
realfcn F(real p) { 
  return new real(real x) {return sin(p*x);}; 
}; 
 
for(int i=1; i < 5; ++i)
  draw(graph(F(i*pi),0,1),Pen(i),
       "$\sin("+(i == 1 ? "" : (string) i)+"\pi x)$"); 
xaxis("$x$",BottomTop,LeftTicks); 
yaxis("$y$",LeftRight,RightTicks(trailingzero)); 
 
attach(legend(2),(point(S).x,truepoint(S).y),10S,UnFill); 

Mots-clefs : , , ,


Official Asymptote example – lever

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 0 h 57 min

Figure 0114
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200,0);

pair z0=(0,0);
pair z1=(2,0);
pair z2=(5,0);
pair zf=z1+0.75*(z2-z1);

draw(z1--z2);
dot(z1,red+0.15cm);
dot(z2,darkgreen+0.3cm);
label("$m$",z1,1.2N,red);
label("$M$",z2,1.5N,darkgreen);
label("$\hat{\ }$",zf,0.2*S,fontsize(24pt)+blue);

pair s=-0.2*I;
draw("$x$",z0+s--z1+s,N,red,Arrows,Bars,PenMargins);

s=-0.5*I;
draw("$\bar{x}$",z0+s--zf+s,blue,Arrows,Bars,PenMargins);

s=-0.95*I;
draw("$X$",z0+s--z2+s,darkgreen,Arrows,Bars,PenMargins);


Mots-clefs : , , ,


Official Asymptote example – limit

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 1 h 57 min

Figure 0115
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200,200,IgnoreAspect);
import graph;

real L=1;
real epsilon=0.25;

real a(int n) {return L+1/n;}

for(int i=1; i < 20; ++i)
  dot((i,a(i)));

real N=1/epsilon;

xaxis(Label("$n$",align=2S));
yaxis(Label("$a_n$",0.85));

xtick("$2$",2);
ytick("$\frac{3}{2}$",3/2);
ytick("$2$",2);

yequals(Label("$L$",0,up),L,extend=true,blue);
yequals(Label("$L+\epsilon$",1,NW),L+epsilon,extend=true,red+dashed);
yequals(Label("$L-\epsilon$",1,SW),L-epsilon,extend=true,red+dashed);

xequals(N,extend=true,darkgreen+dashed);
labelx(shift(0,-10)*"$N=\frac{1}{\epsilon}$",N,E,darkgreen);

label("$a_n=1+\frac{1}{n},\quad \epsilon=\frac{1}{4}$",point((0,1)),10S+E);

Mots-clefs : , ,


Official Asymptote example – lineargraph

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 2 h 57 min

Figure 0116
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(250,200,IgnoreAspect);

real Sin(real t) {return sin(2pi*t);}
real Cos(real t) {return cos(2pi*t);}

draw(graph(Sin,0,1),red,"$\sin(2\pi x)$");
draw(graph(Cos,0,1),blue,"$\cos(2\pi x)$");

xaxis("$x$",BottomTop,LeftTicks);
yaxis("$y$",LeftRight,RightTicks(trailingzero));

label("LABEL",point(0),UnFill(1mm));

attach(legend(),truepoint(E),20E,UnFill);

Mots-clefs : , , , ,


Official Asymptote example – lineargraph0

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 3 h 57 min

Figure 0117
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(400,200,IgnoreAspect);

real Sin(real t) {return sin(2pi*t);}
real Cos(real t) {return cos(2pi*t);}

draw(graph(Sin,0,1),red,"$\sin(2\pi x)$");
draw(graph(Cos,0,1),blue,"$\cos(2\pi x)$");

xaxis("$x$",BottomTop,LeftTicks);
yaxis("$y$",LeftRight,RightTicks(trailingzero));

label("LABEL",point(0),UnFill(1mm));

add(legend(),point(E),20E,UnFill);

Mots-clefs : , , , ,


Official Asymptote example – lines

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 4 h 57 min

Figure 0118
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import math;

int n=7;

size(200,0);

draw(unitcircle,red);
for (int i=0; i < n-1; ++i)
  for (int j=i+1; j < n; ++j)
    drawline(unityroot(n,i),unityroot(n,j),blue);

Mots-clefs : , ,


Official Asymptote example – linetype

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 5 h 57 min

Figure 0119
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
void testline(real y) {
  draw((0,y)--(100,y),currentpen+solid);
  draw((0,y-10)--(100,y-10),currentpen+dotted);
  draw((0,y-20)--(100,y-20),currentpen+dashed);
  draw((0,y-30)--(100,y-30),currentpen+longdashed);
  draw((0,y-40)--(100,y-40),currentpen+dashdotted);
  draw((0,y-50)--(100,y-50),currentpen+longdashdotted);
  draw((0,y-60)--(100,y-60),currentpen+Dotted);
} 

currentpen=linewidth(0.5);
testline(100);


Mots-clefs : , ,


Official Asymptote example – lmfit1

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 6 h 57 min

Figure 0120
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import lmfit;
import graph;

size(10cm, 7cm, IgnoreAspect);

real[] date = { 1790, 1800, 1810, 1820, 1830, 1840, 1850, 1860, 1870, 1880,
1890, 1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990 };
real[] population = { 3.929, 5.308, 7.240, 9.638, 12.866, 17.069, 23.192, 31.443,
38.558, 50.156, 62.948, 75.996, 91.972, 105.711, 122.775, 131.669, 150.697,
179.323, 203.185, 226.546, 248.710 };

real t0 = 1776;

real P(real[] params, real t) {
  real P0 = params[0];
  real K = params[1];
  real r = params[2];
  return (K * P0) / (P0 + (K - P0) * exp(-r * (t - t0)));
}

real[] params = { 10, 500, 0.1 };

real res = lmfit.fit(date, population, P, params).norm;

write("P_0 = ", params[0]);
write("K = ", params[1]);
write("r = ", params[2]);
write("error = ", res);

real P(real t) {
  return P(params, t);
}

draw(graph(date, population), blue);
draw(graph(P, t0, 2000), red);
xaxis("Year", BottomTop, LeftTicks);
yaxis("Population in millions", LeftRight, RightTicks);

Mots-clefs : , , ,


Official Asymptote example – log

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

Figure 0121
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(150,0);

real f(real x) {return log(x);}
pair F(real x) {return (x,f(x));}

xaxis("$x$",0);
yaxis("$y$");

draw(graph(f,0.01,10,operator ..));

labelx(1,SSE);
label("$\log x$",F(7),SE);

Mots-clefs : ,


Official Asymptote example – log2graph

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 8 h 57 min

Figure 0122
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(200,IgnoreAspect);

// Base-2 logarithmic scale on y-axis:

real log2(real x) {static real log2=log(2); return log(x)/log2;}
real pow2(real x) {return 2^x;}

scaleT yscale=scaleT(log2,pow2,logarithmic=true);
scale(Linear,yscale);

real f(real x) {return 1+x^2;}

draw(graph(f,-4,4));

yaxis("$y$",ymin=1,ymax=f(5),RightTicks(Label(Fill(white))),EndArrow);
xaxis("$x$",xmin=-5,xmax=5,LeftTicks,EndArrow);

Mots-clefs : , ,


Official Asymptote example – logdown

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 9 h 57 min

Figure 0123
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(200,IgnoreAspect);

real log10Down(real x) {return -log10(x);}
real pow10Down(real x) {return pow10(-x);}

scaleT LogDown=scaleT(log10Down,pow10Down,logarithmic=true);
scale(Linear,LogDown);

draw(graph(exp,-5,5));

yaxis("$y$",RightTicks(Label(Fill(white)),DefaultLogFormat),BeginArrow);
xaxis("$x$",LeftTicks(NoZero),EndArrow);

Mots-clefs : , ,


Official Asymptote example – loggraph

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 10 h 57 min

Figure 0124
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(200,200,IgnoreAspect);

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

scale(Log,Log);

draw(graph(f,0.1,10));

//xlimits(1,10,Crop);
//ylimits(0.1,1,Crop);

dot(Label("(3,5)",align=S),Scale((3,5)));

xaxis("$x$",BottomTop,LeftTicks);
yaxis("$y$",LeftRight,RightTicks);


Mots-clefs : , ,


Official Asymptote example – loggrid

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 11 h 57 min

Figure 0125
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(200,200,IgnoreAspect);

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

scale(Log,Log);
draw(graph(f,0.1,10),red);
pen thin=linewidth(0.5*linewidth());
xaxis("$x$",BottomTop,LeftTicks(begin=false,end=false,extend=true,
                                ptick=thin));
yaxis("$y$",LeftRight,RightTicks(begin=false,end=false,extend=true,
                                 ptick=thin));


Mots-clefs : , , ,


Official Asymptote example – logimage

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 12 h 57 min

Figure 0126
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
import palette;

size(10cm,10cm,IgnoreAspect);

real f(real x, real y) {
  return 0.9*pow10(2*sin(x/5+2*y^0.25)) + 0.1*(1+cos(10*log(y)));
}

scale(Linear,Log,Log);

pen[] Palette=BWRainbow();

bounds range=image(f,Automatic,(0,1),(100,100),nx=200,Palette);

xaxis("$x$",BottomTop,LeftTicks,above=true);
yaxis("$y$",LeftRight,RightTicks,above=true);

palette("$f(x,y)$",range,(0,200),(100,250),Top,Palette,
        PaletteTicks(ptick=linewidth(0.5*linewidth())));



Mots-clefs : , , ,


Official Asymptote example – logo

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 13 h 57 min

Figure 0127
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(140,80,IgnoreAspect);

picture logo(pair s=0, pen q) 
{
  picture pic;
  pen p=linewidth(2)+fontsize(24pt)+q;
  real a=-0.4;
  real b=0.95;
  real y1=-5;
  real y2=-3y1/2;
  path A=(a,0){dir(10)}::{dir(89.5)}(0,y2);
  draw(pic,A,p);
  draw(pic,(0,y1){dir(88.3)}::{dir(20)}(b,0),p);
  real c=0.5*a;
  pair z=(0,2.5);
  label(pic,"{\it symptote}",z,0.25*E+0.169S,p);
  pair w=(0,1.7);
  draw(pic,intersectionpoint(A,w-1--w)--w,p);
  draw(pic,(0,y1)--(0,y2),p);
  draw(pic,(a,0)--(b,0),p);
  return shift(s)*pic;
} 

pair z=(-0.015,0.08);
for(int x=0; x < 10; ++x)
  add(logo(0.1*x*z,gray(0.04*x)));

add(logo(red));

Mots-clefs :


Official Asymptote example – logo3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 14 h 57 min

Figure 0128
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

size(560,320,IgnoreAspect);
size3(140,80,15);
currentprojection=perspective(-3,20,10,up=Y);
currentlight=White;

path[] outline;

real a=-0.4;
real b=0.95;
real y1=-5;
real y2=-3y1/2;
path A=(a,0){dir(10)}::{dir(89.5)}(0,y2);
outline.push(A);
outline.push((0,y1){dir(88.3)}::{dir(20)}(b,0));
real c=0.5*a;
pair z=(0,2.5);
path[] text = shift(0,2)*scale(0.01,0.15)*
  texpath(Label("{\it symptote}",z,0.25*E+0.169S,fontsize(24pt)));
outline.append(text);
pair w=(0,1.7);
outline.push(intersectionpoint(A,w-1--w)--w);
outline.push((0,y1)--(0,y2));
outline.push((a,0)--(b,0));

for(path p : outline)
  draw(extrude(p,-0.1Z),material(lightgray,shininess=1.0));

draw(path3(outline),red+linewidth(0));

draw(surface(text),red,nolight);


Mots-clefs : , ,


Official Asymptote example – logticks

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 15 h 57 min

Figure 0129
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(300,175,IgnoreAspect);
scale(Log,Log);
draw(graph(identity,5,20));
xlimits(5,20);
ylimits(1,100);
xaxis("$M/M_\odot$",BottomTop,LeftTicks(DefaultFormat,
                                        new real[] {6,10,12,14,16,18}));
yaxis("$\nu_{\rm upp}$ [Hz]",LeftRight,RightTicks(DefaultFormat));


Mots-clefs : ,


Official Asymptote example – lowint

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 16 h 57 min

Figure 0130
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(100,0);
import graph;
import lowupint;

real a=-0.8, b=1.2;
real c=1.0/sqrt(3.0);

partition(a,b,c,min);

arrow("$f(x)$",F(0.5*(a+b)),NNE,red);
label("$\cal{L}$",(0.5*(a+b),f(0.5*(a+b))/2));

Mots-clefs :


Official Asymptote example – magnetic

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 17 h 57 min

Figure 0131
(Compiled with Asymptote version 1.87svn-r4652)
/* 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));

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

Mots-clefs : , , ,


Official Asymptote example – makepen

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 18 h 57 min

Figure 0132
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);
pen convex=makepen(scale(10)*polygon(8))+grey;
draw((1,0.4),convex);
draw((0,0)---(1,1)..(2,0)--cycle,convex);

pen nonconvex=scale(10)*
  makepen((0,0)--(0.25,-1)--(0.5,0.25)--(1,0)--(0.5,1.25)--cycle)+red;
draw((0.5,-1.5),nonconvex);
draw((0,-1.5)..(1,-0.5)..(2,-1.5),nonconvex);

Mots-clefs : ,


Official Asymptote example – markers1

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

Figure 0133
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(12cm,0);
import markers;

pair A=(0,0), B=(1,0), C=(2,0), D=(3,0);
path p=A--B--C--D;
transform T=shift(-4,-1);
transform t=shift(4,0);

//line 1 **********
draw(p,marker(markinterval(3,dotframe,true)));
label("$1$",point(p,0),3W);

//line 2 **********
p=t*p;
draw(p,marker(stickframe,markuniform(4)));
label("$2$",point(p,0),3W);

//line 3 **********
p=T*p;
draw(p,marker(stickframe(red),markinterval(3,dotframe(blue),true)));
label("$3$",point(p,0),3W);

//line 4 **********
p=t*p;
draw(p,StickIntervalMarker(3,2,blue,dotframe(red)));
label("$4$",point(p,0),3W);

//line 5 **********
p=T*p;
pen pn=linewidth(4bp);
draw(p,pn,StickIntervalMarker(3,3,angle=25,pn,dotframe(red+pn)));
label("$5$",point(p,0),3W);

//line 6 **********
p=t*p;
draw(p,StickIntervalMarker(3,5,angle=25,size=4mm,space=2mm,offset=I*2mm,
                           scale(2)*dotframe(red)));
label("$6$",point(p,0),3W);

//line 7 **********
p=T*p;
draw(p,StickIntervalMarker(n=3,angle=45,size=10mm,space=3mm,dotframe));
label("$7$",point(p,0),3W);

//line 8 **********
p=t*p;
draw(p,CircleBarIntervalMarker(n=2,dotframe));
label("$8$",point(p,0),3W);

//line 9 **********
p=T*p;
draw(p,CircleBarIntervalMarker(n=3,angle=30,barsize=8mm,radius=2mm,
                               FillDraw(.8red),
                               dotframe));
label("$9$",point(p,0),3W);

//line 10 **********
p=t*p;
draw(p,CircleBarIntervalMarker(n=3,angle=30,barsize=8mm,radius=2mm,
                               FillDraw(.8red),circleabove=true,dotframe));
label("$10$",point(p,0),3W);

//line 11 **********
p=T*p;
draw(p,CircleBarIntervalMarker(n=3,angle=30,barsize=8mm,radius=2mm,
                               FillDraw(.8red),circleabove=true,dotframe,
                               above=false));
label("$11$",point(p,0),3W);

//line 12 **********
p=t*p;
draw(p,TildeIntervalMarker(i=3,dotframe));
label("$12$",point(p,0),3W);

//line 13 **********
p=T*p;
draw(p,TildeIntervalMarker(i=3,n=2,angle=-20,dotframe));
label("$13$",point(p,0),3W);

//line 14 **********
p=t*p;
draw(p,CrossIntervalMarker(3,3,dotframe));
label("$14$",point(p,0),3W);

//line 15 **********
p=shift(.25S)*T*p;
path cle=shift(relpoint(p,.5))*scale(abs(A-D)/4)*unitcircle;
draw(cle,StickIntervalMarker(5,3,dotframe(6bp+red)));
label("$15$",point(p,0),3W);

//line 16 **********
cle=t*cle;
p=t*p;
frame a;
label(a,"$a$",(0,-2labelmargin()));
draw(cle,marker(dotframe(6bp+red),markinterval(5,a,true)));
label("$16$",point(p,0),3W);

// line 17 **********
p=T*shift(relpoint(p,.5)+.65S)*scale(.5)*shift(-relpoint(p,.5))*rotate(45,relpoint(p,.5))*p;
draw(p,TildeIntervalMarker(size=5mm,rotated=false,dotframe));
label("$17$",point(p,0),3W);

Mots-clefs :


Official Asymptote example – markers2

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

Figure 0134
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(10cm,0);
import markers;
import geometry;
import math;

pair A=0, B=(1,0), C=(0.7,1), D=(-0.5,0), F=rotate(-90)*(C-B)/2+B;

draw(A--B);
draw(A--C);
pen p=linewidth(1mm);
draw(B--C,p);
draw(A--D);
draw(B--F,p);
label("$A$",A,SW);
label("$B$",B,S);
label("$C$",C,N);
dot(Label("$D$",D,S));
dot(Label("$F$",F,N+NW));

markangle(A,C,B);

markangle(scale(1.5)*"$\theta$",radius=40,C,B,A,ArcArrow(2mm),1mm+red);
markangle(scale(1.5)*"$-\theta$",radius=-70,A,B,C,ArcArrow,green);

markangle(Label("$\gamma$",Relative(0.25)),n=2,radius=-30,A,C,B,p=0.7blue+2);

markangle(n=3,B,A,C,marker(markinterval(stickframe(n=2),true)));

pen RedPen=0.7red+1bp;
markangle(C,A,D,RedPen,marker(markinterval(2,stickframe(3,4mm,RedPen),true)));
drawline(A,A+dir(A--D,A--C),dotted);

perpendicular(B,NE,F-B,size=10mm,1mm+red,
              TrueMargin(linewidth(p)/2,linewidth(p)/2),Fill(yellow));

Mots-clefs : ,


Official Asymptote example – markregular

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

Figure 0135
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(10cm,0);

real xmin=-4,xmax=4;
real ymin=-2,ymax=10;

real f(real x) {return x^2;}

marker cross=marker(scale(4)*rotate(45)*cross(4),
                    markuniform(new pair(real t) {return Scale((t,f(t)));},
                                xmin,xmax,round(2*(xmax-xmin))),1bp+red);

draw(graph(f,xmin,xmax,n=400),linewidth(1bp),cross);

ylimits(-2.5,10,Crop);

xaxis(Label("$x$",position=EndPoint, align=NE),xmin=xmin,xmax=xmax,
      Ticks(scale(.7)*Label(align=E),NoZero,begin=false,beginlabel=false,
            end=false,endlabel=false,Step=1,step=.25,
            Size=1mm, size=.5mm,pTick=black,ptick=gray),Arrow);

yaxis(Label("$y$",position=EndPoint, align=NE),ymin=ymin,ymax=ymax,
      Ticks(scale(.7)*Label(),NoZero,begin=false,beginlabel=false,
            end=false,endlabel=false,Step=1,step=.25,Size=1mm,size=.5mm,
            pTick=black,ptick=gray),Arrow);

Mots-clefs : , ,


Official Asymptote example – mexicanhat

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

Figure 0136
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);

real mexican(real x) {return (1-8x^2)*exp(-(4x^2));}

int n=30;
real a=1.5;
real width=2a/n;

guide hat;
path solved;

for(int i=0; i < n; ++i) {
  real t=-a+i*width;
  pair z=(t,mexican(t));
  hat=hat..z;
  solved=solved..z;
}

draw(hat);
dot(hat,red);
draw(solved,dashed);


Mots-clefs :


Official Asymptote example – monthaxis

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 23 h 57 min

Figure 0137
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(400,150,IgnoreAspect);

real[] x=sequence(12);
real[] y=sin(2pi*x/12);

scale(false);

string[] month={"Jan","Feb","Mar","Apr","May","Jun",
                "Jul","Aug","Sep","Oct","Nov","Dec"};

draw(graph(x,y),red,MarkFill[0]);

xaxis(BottomTop,LeftTicks(new string(real x) {
      return month[round(x % 12)];}));
yaxis("$y$",LeftRight,RightTicks(4));

Mots-clefs : , ,


Official Asymptote example – mosaic

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 0 h 57 min

Figure 0138
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
// Calendar example contributed by Jens Schwaiger

// transformations
path similarpath(pair a, pair b, path p) {
  // transform p into a path starting at a and ending at b
  pair first;
  pair last;
  path p_;
  first=point(p,0);
  last=point(p,length(p));
  p_=shift(-first)*p;
  p_=rotate(degrees(b-a))*p_;
  p_=scale(abs(b-a)/abs(last-first))*p_;
  p_=shift(a)*p_;
  return p_;
}

path c_line(path p) {
  // returns the path obtained by adding to p a copy rotated
  // around the endpoint of p by 180 degrees
  // works only if the initial point and the endpoint of p are different
  // a c_line is symetric with respect to the center of 
  // the straight line between its endpoints
  //
  return p..rotate(180,point(p,length(p)))*reverse(p);
}

path tounitcircle(path p, int n=300) {
  // the transformation pair x --> x/sqrt(1+abs(x)^2)
  // is a bijection from the plane to the open unitdisk
  real l=arclength(p);
  path ghlp;
  for(int i=0; i <= n; ++i) {
    real at=arctime(p,l/n*i);
    pair phlp=point(p,at);
    real trhlp=1/(1+abs(phlp)^2)^(1/2);
    ghlp=ghlp--trhlp*phlp;
  }
  if(cyclic(p)) {ghlp=ghlp--cycle;}
  return ghlp;
}

void centershade(picture pic=currentpicture, path p, pen in, pen out,
                 pen drawpen=currentpen) { 
  pair center=0.5(max(p)+min(p));
  real radius=0.5abs(max(p)-min(p));
  radialshade(pic,p,in,center,0,out,center,radius);
  draw(pic,p,drawpen);
}

pair zentrum(path p) {return 0.5(min(p)+max(p));}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

real scalefactor=19/13; // For output: height=scalefactor*width
real outputwidth=13cm;
picture kalender;// at first we produce a calendar for february 2006
texpreamble("\usepackage[latin1]{inputenc}");
size(outputwidth,0);
real yc=0.5;
pair diff=(-3.5,5*yc);
pen farbe(int j) {
  pen hlp=0.8white;
  if(j % 7 == 6) {hlp=red+white;}
  return hlp;}

// farbe=German word for color
path kasten=yscale(yc)*unitsquare;
// Kasten is a German word meaning something like box
path Gkasten=shift((0,2*yc)+diff)*xscale(7)*yscale(2)*kasten;
path tage[]= new path[7]; // Tag=day
string wochentag[]={"MO","DI","MI","DO","FR","SA","SO"};
path[][] bx= new path[6][7];
string[][] entry= new string[6][7];
bool[][] holiday=new bool[6][7];

// Now the necessary information for February 2006
int start=2;
int days=28;
for(int i=0; i < entry.length; ++i) {
  for(int j=0; j < entry[0].length; ++j) {
    int day=i*7+j-start+1;
    entry[i][j]=(day > 0 && day <= days ? (string) day : "");
    holiday[i][j]=false;
  }
}

for(int j=0; j < 7; ++j) {
  tage[j]=shift((j,yc)+diff)*kasten; 
  filldraw(tage[j],farbe(j),black+2bp);
  label(wochentag[j],zentrum(tage[j]),Palatino());
  for(int i=0; i < 6; ++i) {bx[i][j]=shift((j,-yc*i)+diff)*kasten;
    filldraw(bx[i][j],farbe(j),black+2bp);
    if(holiday[i][j]) {filldraw(bx[i][j],farbe(6),black+2bp);};
  };
};
filldraw(Gkasten,0.3white,black+2bp); 
for(int j=0; j < 7; ++j)
  for(int i=0; i < 6 ; ++i) {label(entry[i][j],zentrum(bx[i][j]),Palatino());}
label("\Huge Februar 2006",zentrum(Gkasten),Palatino()+white); 
// Zentrum=center; Februar=february
add(kalender,currentpicture);
erase();

// Now the mosaic is constructed
pair a[]=new pair[4];
path p[]=new path[4];
path q[]=new path[4];
path kontur[]=new path[5];
picture temppic;

a[1]=(0,0);
a[2]=(1,0);
a[3]=(0,1); // a triangle with abs(a[2]-a[1])=abs(a[3]-a[1]
            // and a right angle at a[1];
q[1]=(0,0){dir(-20)}::{dir(20)}(0.2,0){dir(-140)}..{dir(0)}(0.3,-0.2){dir(0)}..
{dir(140)}(0.4,0){dir(20)}..{dir(-20)}(1,0);
q[2]=(0,0){dir(20)}..{dir(-20)}(0.8,0){dir(-140)}..{dir(0)}(0.9,-0.3){dir(0)}..
{dir(140)}(1,0);
q[2]=c_line(q[2]);
p[1]=similarpath(a[1],a[2],q[1]);// arbitrary path from a[1] to a[2]
p[2]=similarpath(a[2],a[3],q[2]);// arbitrary c_line from a[2] to a[3]
p[3]=rotate(90,a[1])*reverse(p[1]);//
kontur[1]=p[1]..p[2]..p[3]..cycle;// first tile
kontur[2]=rotate(90,a[1])*kontur[1];// second
kontur[3]=rotate(180,a[1])*kontur[1];// third
kontur[4]=rotate(270,a[1])*kontur[1];// fourth
pair tri=2*(interp(a[2],a[3],0.5)-a[1]);
pair trii=rotate(90)*tri;
// translations of kontur[i], i=1,2,3,4, with respect to
// j*tri+k*trii
// fill the plane

for(int j=-4; j < 4; ++j)
  for(int k=-4; k < 4; ++k) {
    transform tr=shift(j*tri+k*trii);
    for(int i=1; i < 5; ++i) {
      centershade(temppic,tr*kontur[i],(1-i/10)*white,
                  (1-i/10)*chartreuse,black+2bp);
    }
  }
  
// Now we produce the bijective images inside 
// a suitably scaled unitcircle            
for(int k=-1; k < 2; ++k)
  for(int l=-1; l < 2; ++l) {
    transform tr=shift(k*tri+l*trii);
    for(int i=1; i < 5; ++i) {
      centershade(temppic,scale(2.5)*tounitcircle(tr*kontur[i],380),
                  (1-i/10)*white,(1-i/10)*orange,black+2bp);
    }
  }         
          
add(temppic); 

// We clip the picture to a suitable box 
pair piccenter=0.5*(temppic.min()+temppic.max());
pair picbox=temppic.max()-temppic.min();
real picwidth=picbox.x;
transform trialtrans=shift(0,-1.5)*shift(piccenter)*yscale(scalefactor)*
  scale(0.25picwidth)*shift((-0.5,-0.5))*identity();
clip(trialtrans*unitsquare);

// add the calendar at a suitable position
add(kalender.fit(0.75*outputwidth),interp(point(S),point(N),1/13)); 

Mots-clefs :


Official Asymptote example – mosquito

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 1 h 57 min

Figure 0139
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(9cm,10cm,IgnoreAspect);

pair d=(1,0.25);
real s=1.6d.x;
real y=0.6;
defaultpen(fontsize(8pt));

picture box(string s, pair z=(0,0)) {
  picture pic;
  draw(pic,box(-d/2,d/2));
  label(pic,s,(0,0));
  return shift(z)*pic;
}

label("Birds",(0,y));
picture removed=box("Removed ($R_B$)");
picture infectious=box("Infectious ($I_B$)",(0,-1.5));
picture susceptible=box("Susceptible ($S_B$)",(0,-3));

add(removed);
add(infectious);
add(susceptible);

label("Mosquitoes",(s,y));
picture larval=box("Larval ($L_M$)",(s,0));
picture susceptibleM=box("Susceptible ($S_M$)",(s,-1));
picture exposed=box("Exposed ($E_M$)",(s,-2));
picture infectiousM=box("Infectious ($I_M$)",(s,-3));

add(larval);
add(susceptibleM);
add(exposed);
add(infectiousM);

path ls=point(larval,S)--point(susceptibleM,N);
path se=point(susceptibleM,S)--point(exposed,N);
path ei=point(exposed,S)--point(infectiousM,N);
path si=point(susceptible,N)--point(infectious,S);

draw(minipage("\flushright{recovery rate ($g$) \& death rate from virus
($\mu_V$)}",40pt),point(infectious,N)--point(removed,S),LeftSide,Arrow,
     PenMargin);

draw(si,LeftSide,Arrow,PenMargin);

draw(minipage("\flushright{maturation rate ($m$)}",50pt),ls,RightSide,
     Arrow,PenMargin);
draw(minipage("\flushright{viral incubation rate ($k$)}",40pt),ei,
     RightSide,Arrow,PenMargin);

path ise=point(infectious,E)--point(se,0.5);
  
draw("$(ac)$",ise,LeftSide,dashed,Arrow,PenMargin);
label(minipage("\flushleft{biting rate $\times$ transmission
probability}",50pt),point(infectious,SE),dir(-60)+S);

path isi=point(infectiousM,W)--point(si,2.0/3);

draw("$(ab)$",isi,LeftSide,dashed,Arrow,PenMargin);
draw(se,LeftSide,Arrow,PenMargin);
      
real t=2.0;
draw("$\beta_M$",
     point(susceptibleM,E){right}..tension t..{left}point(larval,E),
     2*(S+SE),red,Arrow(Fill,0.5));
draw(minipage("\flushleft{birth rate ($\beta_M$)}",20pt),
     point(exposed,E){right}..tension t..{left}point(larval,E),2SW,red,
     Arrow(Fill,0.5));
draw("$\beta_M$",
     point(infectiousM,E){right}..tension t..{left}point(larval,E),2SW,
     red,Arrow(Fill,0.5));

path arrow=(0,0)--0.75cm*dir(35);
draw(point(larval,NNE),
     Label(minipage("\flushleft{larval death rate ($\mu_L$)}",45pt),1),
     arrow,blue,Arrow);
draw(point(susceptibleM,NNE),
     Label(minipage("\flushleft{adult death rate ($\mu_A$)}",20pt),1),
     arrow,N,blue,Arrow);
draw(point(exposed,NNE),Label("$\mu_A$",1),arrow,blue,Arrow);
draw(point(infectiousM,NNE),Label("$\mu_A$",1),arrow,blue,Arrow);


Mots-clefs : ,


Official Asymptote example – multicontour

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 2 h 57 min

Figure 0140
(Compiled with Asymptote version 1.87svn-r4652)
/* 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);

Mots-clefs : , , , ,


Official Asymptote example – near_earth

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 3 h 57 min

Figure 0141
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;
import math;
texpreamble("\usepackage{bm}");

size(300,0);

pen thickp=linewidth(0.5mm);
real radius=0.8, lambda=37, aux=60;

currentprojection=perspective(4,1,2); 

// Planes
pen bg=gray(0.9)+opacity(0.5);
draw(surface((1.2,0,0)--(1.2,0,1.2)--(0,0,1.2)--(0,0,0)--cycle),bg);
draw(surface((0,1.2,0)--(0,1.2,1.2)--(0,0,1.2)--(0,0,0)--cycle),bg);
draw(surface((1.2,0,0)--(1.2,1.2,0)--(0,1.2,0)--(0,0,0)--cycle),bg);

real r=1.5;
pen p=rgb(0,0.7,0);
draw(Label("$x$",1),O--r*X,p,Arrow3);
draw(Label("$y$",1),O--r*Y,p,Arrow3);
draw(Label("$z$",1),O--r*Z,p,Arrow3);
label("$\rm O$",(0,0,0),W);
  
// Point Q
triple pQ=radius*dir(lambda,aux);
draw(O--radius*dir(90,aux),dashed);
label("$\rm Q$",pQ,N+3*W);
draw("$\lambda$",arc(O,0.15pQ,0.15*Z),N+0.3E);

// Particle
triple m=pQ-(0.26,-0.4,0.28);
real width=5;
dot("$m$",m,SE,linewidth(width));
draw("$\bm{\rho}$",(0,0,0)--m,Arrow3,PenMargin3(0,width));
draw("$\bm{r}$",pQ--m,Arrow3,PenMargin3(0,width));

// Spherical octant
real r=sqrt(pQ.x^2+pQ.y^2);
draw(arc((0,0,pQ.z),(r,0,pQ.z),(0,r,pQ.z)),dashed);
draw(arc(O,radius*Z,radius*dir(90,aux)),dashed);
draw(arc(O,radius*Z,radius*X),thickp);
draw(arc(O,radius*Z,radius*Y),thickp);
draw(arc(O,radius*X,radius*Y),thickp);

// Moving axes
triple i=dir(90+lambda,aux);
triple k=unit(pQ);
triple j=cross(k,i);

draw(Label("$x$",1),pQ--pQ+0.2*i,2W,red,Arrow3);
draw(Label("$y$",1),pQ--pQ+0.32*j,red,Arrow3);
draw(Label("$z$",1),pQ--pQ+0.26*k,red,Arrow3);

draw("$\bm{R}$",O--pQ,Arrow3,PenMargin3);
draw("$\omega\bm{K}$",arc(0.9Z,0.2,90,-120,90,160,CW),1.2N,Arrow3);

Mots-clefs : , , , , ,


Official Asymptote example – odetest

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 4 h 57 min

Figure 0142
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import ode;

write("integration test");
real f(real t, real x) {return cos(x);}
write(integrate(1,f,0,10,0.1,dynamic=true,0.0002,0.0004,RK3BS,verbose=true));
write();

write("system integration test");
real[] f(real t, real[] x) {return new real[] {x[1],1.5*x[0]^2};}
write(integrate(new real[] {4,-8},f,0,1,n=100,dynamic=true,tolmin=0.0002,
                tolmax=0.0004,RK3BS,verbose=true));
write();

write("simultaneous newton test");
real[] function(real[] x) {
  return new real[] {x[0]^2+x[1]^2-25,(x[0]-6)^2+x[1]^2-25};
}
real[][] fJac(real[] x) {
  return new real[][] {{2*x[0],2*x[1]},{2*(x[0]-6),2*x[1]}};
}
write(newton(function,fJac,new real[] {0,-1}));
write();


write("BVP solver test");
write("Finding initial conditions that solve w''(t)=1.5*w(t), w(0)=4, w(1)=1");
real[] initial(real[] x) {
  return new real[] {4,x[0]};
}

real[] discrepancy(real[] x) {
  write("Error: ",x[0]-1);
  return new real[] {x[0]-1};
}

write(solveBVP(f,0,1,n=10,initial,discrepancy,guess=new real[] {-30},RK4,
               iterations=10));
write();
write(solveBVP(f,0,1,n=100,initial,discrepancy,guess=new real[] {-30},RK4,
               iterations=10));
write();
write(solveBVP(f,0,1,n=10000,initial,discrepancy,guess=new real[] {-30},RK4,
               iterations=10));
write();

Mots-clefs :


Official Asymptote example – onecontour

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 5 h 57 min

Figure 0143
(Compiled with Asymptote version 1.87svn-r4652)
/* 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}));

Mots-clefs : ,


Official Asymptote example – oneoverx

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 6 h 57 min

Figure 0144
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(200,IgnoreAspect);

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

bool3 branch(real x)
{
  static int lastsign=0;
  if(x == 0) return false;
  int sign=sgn(x);
  bool b=lastsign == 0 || sign == lastsign; 
  lastsign=sign;
  return b ? true : default;
}

draw(graph(f,-1,1,branch));
axes("$x$","$y$",red);

Mots-clefs : , ,


Official Asymptote example – orthocenter

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

Figure 0145
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import geometry;
import math;

size(7cm,0);

real theta=degrees(asin(0.5/sqrt(7)));

pair B=(0,sqrt(7));
pair A=B+2sqrt(3)*dir(270-theta);
pair C=A+sqrt(21);
pair O=0;

pair Ap=extension(A,O,B,C);
pair Bp=extension(B,O,C,A);
pair Cp=extension(C,O,A,B);

perpendicular(Ap,NE,Ap--O,blue);
perpendicular(Bp,NE,Bp--C,blue);
perpendicular(Cp,NE,Cp--O,blue);

draw(A--B--C--cycle);

currentpen=black;

draw("1",A--O,-0.25*I*dir(A--O));
draw(O--Ap);
draw("$\sqrt{7}$",B--O,LeftSide);
draw(O--Bp);
draw("4",C--O);
draw(O--Cp);

dot("$O$",O,1.5*dir(B--Bp,Cp--C),red);
dot("$A$",A,1.5*dir(C--A,B--A),red);
dot("$B$",B,NW,red);
dot("$C$",C,dir(A--C,B--C),red);
dot("$A'$",Ap,dir(A--Ap),red);
dot("$B'$",Bp,dir(B--Bp),red);
dot("$C'$",Cp,dir(C--Cp),red);

label(graphic("piicon.eps","width=2.5cm"),Ap,5ENE,red);


Mots-clefs : , ,


Official Asymptote example – p-orbital

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 8 h 57 min

Figure 0146
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3; 
import palette; 
size(200); 
currentprojection=orthographic(6,8,2); 
 
real c0=0.1; 

real f(real r) {return r*(1-r/6)*exp(-r/3);}

triple f(pair t) {
  real r=t.x;
  real phi=t.y;
  real f=f(r);
  real s=max(min(c0/f,1),-1);
  real R=r*sqrt(1-s^2);
  return (R*cos(phi),R*sin(phi),r*s);
}

bool cond(pair t) {return f(t.x) != 0;}

real R=abs((20,20,20));
surface s=surface(f,(0,0),(R,2pi),100,8,Spline,cond);

s.colors(palette(s.map(abs),Gradient(palegreen,heavyblue))); 
draw(s); 
draw(zscale3(-1)*s); 
 
axes3("$x$","$y$","$z$",Arrow3);

Mots-clefs : , , , ,


Official Asymptote example – parametricelevation

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 9 h 57 min

Figure 0147
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import palette;
size(200);

currentprojection=orthographic(4,2,4);

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

surface s=surface(f,(0,0),(pi,2pi),10,Spline);
draw(s,mean(palette(s.map(zpart),BWRainbow())),black,nolight);

Mots-clefs : , , ,


Official Asymptote example – parametricgraph

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 10 h 57 min

Figure 0148
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(0,200);

real x(real t) {return cos(2pi*t);}
real y(real t) {return sin(2pi*t);}

draw(graph(x,y,0,1));

//xlimits(0,1,Crop);
//ylimits(-1,0,Crop);

xaxis("$x$",BottomTop,LeftTicks);
yaxis("$y$",LeftRight,RightTicks(trailingzero));



Mots-clefs : ,


Official Asymptote example – parametricsurface

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 11 h 57 min

Figure 0149
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(200,0);
currentprojection=orthographic(4,0,2);

real R=2;
real a=1.9;

triple f(pair t) {
  return ((R+a*cos(t.y))*cos(t.x),(R+a*cos(t.y))*sin(t.x),a*sin(t.y));
}

pen p=rgb(0.2,0.5,0.7);

// surface only
draw(surface(f,(0,0),(2pi,2pi),8,8,Spline),lightgray);

// mesh only
//draw(surface(f,(0,0),(2pi,2pi),8,8,Spline),nullpen,meshpen=p);

// surface & mesh
//draw(surface(f,(0,0),(2pi,2pi),8,8,Spline),lightgray,meshpen=p);

Mots-clefs : , ,


Official Asymptote example – partialsurface

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 12 h 57 min

Figure 0150
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import palette;

size(0,300);
currentprojection=perspective(3,-2,2);

real V(real r) {return r^4-r^2;}
real V(pair pos) {return V(abs(pos));}

real R=1/sqrt(2);
real z=-0.2;

bool active(pair pos) {return abs(pos) < R;}
bool above(pair pos) {return V(pos) >= z;}

pair a=(-1.5,-1);
pair b=(0.5,1);
real f=1.2;

draw(plane(f*(b.x-a.x,0,z),(0,f*(b.y-a.y),z),(a.x,a.y,z)),
     lightgrey+opacity(0.5));

surface s=surface(V,a,b,40,Spline,active);
draw(s,mean(palette(s.map(new real(triple v) {
          return above((v.x,v.y)) ? 1 : 0;}),
      new pen[] {lightblue,lightgreen})),black);

xaxis3(Label("$\phi^\dagger\phi$",1),red,Arrow3);
zaxis3(Label("$V(\phi^\dagger\phi)$",1),0,0.3,red,Arrow3);

Mots-clefs : , , ,


Official Asymptote example – pathintersectsurface

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 13 h 57 min

Figure 0151
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(500);
import graph3;

path3 g=randompath3(10);

draw(g,red+thin());

triple[][] P={
  {(0,0,0),(1,0,0),(1,0,0),(2,0,0)},
  {(0,4/3,0),(2/3,4/3,2),(4/3,4/3,2),(2,4/3,0)},
  {(0,2/3,0),(2/3,2/3,0),(4/3,2/3,0),(2,2/3,0)},
  {(0,2,0),(2/3,2,0),(4/3,2,0),(2,2,0)}};

surface s=surface(patch(P));
s.append(unitplane);

draw(s,lightgray+opacity(0.9));
dot(intersectionpoints(g,s),blue);

Mots-clefs : , , ,


Official Asymptote example – pdb

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 14 h 57 min

Figure 0152
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;
import cpkcolors;

// A sample Protein Data Bank file for this example is available from
// http://ndbserver.rutgers.edu/ftp/NDB/coordinates/na-biol/100d.pdb1

bool getviews=true;

currentlight=White;
//currentlight=nolight;

size(200);
currentprojection=perspective(30,30,15);

// Uncomment this line for more accurate (but slower) PDF rendering
//dotgranularity=0;

pen chainpen=green;
pen hetpen=purple;

string filename="100d.pdb1";
//string filename=getstring("filename");

string prefix=stripextension(filename);
file data=input(filename);

pen color(string e) 
{
  e=replace(e," ","");
  int n=length(e);
  if(n < 1) return currentpen;
  if(n > 1) e=substr(e,0,1)+downcase(substr(e,1,n-1));
  int index=find(Element == e);
  if(index < 0) return currentpen;
  return rgb(Hexcolor[index]);
}       

// ATOM
string[] name,altLoc,resName,chainID,iCode,element,charge;
int[] serial,resSeq;
real[][] occupancy,tempFactor;

bool newchain=true;

struct bond 
{
  int i,j;
  void operator init(int i, int j) {
    this.i=i;
    this.j=j;
  }
}

bond[] bonds;

struct atom 
{
  string name;
  triple v;
  void operator init(string name, triple v) {
    this.name=name;
    this.v=v;
  }
}

struct chain
{
  int[] serial;
  atom[] a;
}

int[] serials;
chain[] chains;
atom[] atoms;

while(true) {
  string line=data;
  if(eof(data)) break;
  string record=replace(substr(line,0,6)," ","");
  if(record == "TER") {newchain=true; continue;}
  bool ATOM=record == "ATOM";
  bool HETATOM=record == "HETATM";
  int serial;

  atom a;
  if(ATOM || HETATOM) {
    serial=(int) substr(line,6,5);
    a.name=substr(line,76,2);
    a.v=((real) substr(line,30,8),
         (real) substr(line,38,8),
         (real) substr(line,46,8));
  }
  if(ATOM) {
    if(newchain) {
      chains.push(new chain);
      newchain=false;
    }
    chain c=chains[chains.length-1];
    c.serial.push(serial);
    c.a.push(a);
    continue;
  }
  if(HETATOM) {
    serials.push(serial);
    atoms.push(a);
  }
  if(record == "CONECT") {
    int k=0;
    int i=(int) substr(line,6,5);
    while(true) {
      string s=replace(substr(line,11+k,5)," ","");
     if(s == "") break;
      k += 5;
      int j=(int) s;
      if(j <= i) continue;
      bonds.push(bond(i,j));
     }
  }
}

write("Number of atomic chains: ",chains.length);

int natoms;
for(chain c : chains) {
  for(int i=0; i < c.a.length-1; ++i)
    draw(c.a[i].v--c.a[i+1].v,chainpen,currentlight);
  for(atom a : c.a)
    dot(a.v,color(a.name),currentlight);
  natoms += c.a.length;
}

write("Number of chained atoms: ",natoms);
write("Number of hetero atoms: ",atoms.length);

for(atom h : atoms)
  dot(h.v,color(h.name),currentlight);

write("Number of hetero bonds: ",bonds.length);

for(bond b : bonds) {
  triple v(int i) {return atoms[find(serials == i)].v;}
  draw(v(b.i)--v(b.j),hetpen,currentlight);
}

string options;
string viewfilename=prefix+".views";

if(!error(input(viewfilename,check=false)))
  options="3Dviews="+viewfilename;

if(getviews) {
  picture pic;
  add(pic,embed("label",currentpicture,options=options),(0,0),N);
  label(pic,cameralink("label"),(0,0),S,fontsize(12pt));
  shipout(prefix,pic,options=options);
} else
  shipout(prefix,options=options);

Mots-clefs : , , , , ,


Official Asymptote example – penimage

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 15 h 57 min

Figure 0153
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);

import palette;

int n=256;
real ninv=2pi/n;
pen[][] v=new pen[n][n];

for(int i=0; i < n; ++i)
  for(int j=0; j < n; ++j)
    v[i][j]=rgb(0.5*(1+sin(i*ninv)),0.5*(1+cos(j*ninv)),0);

image(v,(0,0),(1,1));


Mots-clefs : ,


Official Asymptote example – phase

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 16 h 57 min

Figure 0154
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(8cm,6cm,IgnoreAspect);

pair S0=(4,0.2);
pair S1=(2,3);
pair S8=(0.5,0);

xaxis("$S$");
yaxis(Label("$I$",0.5));

draw(S0{curl 0}..tension 1.5..S1{W}..tension 1.5..{curl 0}S8,Arrow(Fill,0.4));
draw((S1.x,0)..S1,dashed);
draw((0,S1.y)..S1,dotted);

labelx("$\frac{\gamma}{\beta}$",S1.x);
labelx("$S_\infty$",S8.x);
labely("$I_{\max}$",S1.y);


Mots-clefs :


Official Asymptote example – pipeintersection

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 17 h 57 min

Figure 0155
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

currentprojection=orthographic(5,4,2);
currentlight=Headlamp;

size(12cm,0);

real f(pair z) {return min(sqrt(1-z.x^2),sqrt(1-z.y^2));}

surface s=surface(f,(0,0),(1,1),40,Spline);

transform3 t=rotate(90,O,Z), t2=t*t, t3=t2*t, i=xscale3(-1)*zscale3(-1);
draw(surface(s,t*s,t2*s,t3*s,i*s,i*t*s,i*t2*s,i*t3*s),blue);

Mots-clefs : , , ,


Official Asymptote example – planeproject

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 18 h 57 min

Figure 0156
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size3(200,IgnoreAspect);

currentprojection=orthographic(4,6,3);

real x(real t) {return 1+cos(2pi*t);}
real y(real t) {return 1+sin(2pi*t);}
real z(real t) {return t;}

path3 p=graph(x,y,z,0,1,operator ..);

draw(p,Arrow3);
draw(planeproject(XY*unitsquare3)*p,red,Arrow3);
draw(planeproject(YZ*unitsquare3)*p,green,Arrow3);
draw(planeproject(ZX*unitsquare3)*p,blue,Arrow3);

axes3("$x$","$y$","$z$");

Mots-clefs : ,


Official Asymptote example – planes

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

Figure 0157
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(6cm,0);
import bsp;

real u=2.5;
real v=1;

currentprojection=oblique;

path3 y=plane((2u,0,0),(0,2v,0),(-u,-v,0));
path3 l=rotate(90,Z)*rotate(90,Y)*y;
path3 g=rotate(90,X)*rotate(90,Y)*y;

face[] faces;
filldraw(faces.push(y),project(y),yellow);
filldraw(faces.push(l),project(l),lightgrey);
filldraw(faces.push(g),project(g),green);

add(faces);


Mots-clefs : ,


Official Asymptote example – polararea

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

Figure 0158
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import math;
import graph;

size(0,150);

real f(real t) {return 5+cos(10*t);}

xaxis("$x$");
yaxis("$y$");

real theta1=pi/8;
real theta2=pi/3;
path k=graph(f,theta1,theta2,operator ..);
real rmin=min(k).y;
real rmax=max(k).y;
draw((0,0)--rmax*expi(theta1),dotted);
draw((0,0)--rmax*expi(theta2),dotted);

path g=polargraph(f,theta1,theta2,operator ..);
path h=(0,0)--g--cycle;
fill(h,lightgray);
draw(h);

real thetamin=3*pi/10;
real thetamax=2*pi/10;
pair zmin=polar(f(thetamin),thetamin);
pair zmax=polar(f(thetamax),thetamax);
draw((0,0)--zmin,dotted+red);
draw((0,0)--zmax,dotted+blue);

draw("$\theta_*$",arc((0,0),0.5*rmin,0,degrees(thetamin)),red+fontsize(10pt),
     PenMargins);
draw("$\theta^*$",arc((0,0),0.5*rmax,0,degrees(thetamax)),blue+fontsize(10pt),
     PenMargins);

draw(arc((0,0),rmin,degrees(theta1),degrees(theta2)),red,PenMargins);
draw(arc((0,0),rmax,degrees(theta1),degrees(theta2)),blue,PenMargins);


Mots-clefs : , ,


Official Asymptote example – polarcircle

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

Figure 0159
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import math;
import graph;
size(0,100);

real f(real t) {return 2*cos(t);}
pair F(real x) {return (x,f(x));}

draw(polargraph(f,0,pi,operator ..));

defaultpen(fontsize(10pt));

xaxis("$x$");
yaxis("$y$");

real theta=radians(50);
real r=f(theta);
draw("$\theta$",arc((0,0),0.5,0,degrees(theta)),red,Arrow,PenMargins);

pair z=polar(r,theta);
draw(z--(z.x,0),dotted+red);
draw((0,0)--(z.x,0),dotted+red);
label("$r\cos\theta$",(0.5*z.x,0),0.5*S,red);
label("$r\sin\theta$",(z.x,0.5*z.y),0.5*E,red);
dot("$(x,y)$",z,N);
draw("r",(0,0)--z,0.5*unit(z)*I,blue,Arrow,DotMargin);

dot("$(a,0)$",(1,0),NE);
dot("$(2a,0)$",(2,0),NE);



Mots-clefs : , ,


Official Asymptote example – poster

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

Figure 0160
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
orientation=Landscape;
import slide;
import graph;

defaultpen(deepblue);

real f(real x) {return (x != 0) ? x*sin(1/x) : 0;}
pair F(real x) {return (x,f(x));}

xaxis(background,grey);
yaxis(background,-0.25,0.25,grey);
real a=1.2/pi;
draw(background,graph(background,f,-a,a,10000),grey);
label(background,"$x\sin\frac{1}{x}$",F(0.92/pi),3SE,grey+fontsize(14pt));
frame f=background.fit();
box(f,RadialShade(yellow,0.6*yellow+red),above=false);
background.erase();
add(background,f);  

title("Young Researchers' Conference",align=3S,fontsize(48pt));
center("University of Alberta, Edmonton, April 1--2, 2006");

skip(4);

center("A general conference for\\
the mathematical and statistical sciences\\
for graduate students, by graduate students.",fontsize(32pt));

label("Registration and abstract submission online.",(0,-0.5));

label("\tt http://www.pims.math.ca/science/2006/06yrc/",point(SW),NE,
      black+fontsize(18pt));

Mots-clefs :


Official Asymptote example – projectelevation

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 23 h 57 min

Figure 0161
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import grid3;
import palette;

currentprojection=orthographic(0.8,1,2);

size(400,300,IgnoreAspect);

real f(pair z) {return cos(2*pi*z.x)*sin(2*pi*z.y);}

surface s=surface(f,(-1/2,-1/2),(1/2,1/2),50,Spline);

surface S=planeproject(unitsquare3)*s;
S.colors(palette(s.map(zpart),Rainbow()));
draw(S,nolight);
draw(s,lightgray+opacity(0.7));

grid3(XYZgrid);

Mots-clefs : , , , , , , , ,


Official Asymptote example – projectrevolution

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 0 h 57 min

Figure 0162
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import solids; 
import palette; 
 
currentprojection=orthographic(20,0,3); 
 
size(400,300,IgnoreAspect); 
 
revolution r=revolution(new real(real x) {return sin(x)*exp(-x/2);},
                          0,2pi,operator ..,Z); 
surface s=surface(r); 
 
surface S=planeproject(shift(-Z)*unitsquare3)*s;
S.colors(palette(s.map(zpart),Rainbow()));
draw(S);
draw(s,lightgray); 

Mots-clefs : , , , , , , ,


Official Asymptote example – quartercircle

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 1 h 57 min

Figure 0163
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(100,0);
draw((1,0){up}..{left}(0,1));

Mots-clefs : , ,


Official Asymptote example – rainbow

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 2 h 57 min

Figure 0164
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);

pen indigo=rgb(102/255,0,238/255);

void rainbow(path g) {
  draw(new path[] {scale(1.3)*g,scale(1.2)*g,scale(1.1)*g,g,
        scale(0.9)*g,scale(0.8)*g,scale(0.7)*g},
    new pen[] {red,orange,yellow,green,blue,indigo,purple});
}

rainbow((1,0){N}..(0,1){W}..{S}(-1,0));
rainbow(scale(4)*shift(-0.5,-0.5)*unitsquare);

Mots-clefs : ,


Official Asymptote example – randompath3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 3 h 57 min

Figure 0165
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;
size(300);
draw(randompath3(100),red,currentlight);

Mots-clefs : ,


Official Asymptote example – ring

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 4 h 57 min

Figure 0166
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,100);
path unitcircle=E..N..W..S..cycle;
path g=scale(2)*unitcircle;
radialshade(unitcircle^^g,yellow+evenodd,(0,0),1.0,yellow+brown,(0,0),2);


Mots-clefs : , ,


Official Asymptote example – roll

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 5 h 57 min

Figure 0167
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

size(200,0);

triple f(pair t) {
return(t.x+t.y/4+sin(t.y),cos(t.y),sin(t.y));
}

surface s=surface(f,(0,0),(2pi,2pi),7,20,Spline);
draw(s,olive);

Mots-clefs : , ,


Official Asymptote example – roundpath

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 6 h 57 min

Figure 0168
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
// example file for 'roundedpath.asy'
// written by stefan knorr

// import needed packages
import roundedpath;

// define open and closed path
path A = (0,0)--(10,10)--(30,10)--(20,0)--(30,-10)--(10,-10);
path B = A--cycle;

draw(shift(-60,0)*A, green);
draw(shift(-30,0)*roundedpath(A,1), red);

// draw open path and some modifications
for (int i = 1; i < 20; ++i)
  draw(roundedpath(A,i/4), rgb(1 - i*0.049, 0, i*0.049) + linewidth(0.5));

draw(shift(-60,-30)*B, green);
draw(shift(-30,-30)*roundedpath(B,1), red);

//draw closed path and some modifications
for (int i = 1; i < 20; ++i)                          // only round edges
  draw(shift(0,-30)*roundedpath(B,i/4), rgb(0.5, i*0.049,0) + linewidth(0.5));

for (int i = 1; i < 20; ++i)                          // round edged and scale 
  draw(shift(0,-60)*roundedpath(B,i/4,1-i/50), rgb(1, 1 - i*0.049,i*0.049) + linewidth(0.5));

for (int i = 1; i < 50; ++i)                          // shift (round edged und scaled shifted version)
  draw(shift(-30,-60)*shift(10,0)*roundedpath(shift(-10,0)*B,i/10,1-i/80), rgb( i*0.024, 1 - i*0.024,0) + linewidth(0.5));

for (int i = 1; i < 20; ++i)                          // shift (round edged und scaled shifted version)
  draw(shift(-60,-60)*shift(10,0)*roundedpath(shift(-10,0)*B,i/4,1-i/50), gray(i/40));

Mots-clefs : ,


Official Asymptote example – sacone

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

Figure 0169
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,150);

pair z0=(0,0);
real r=1;
real h=1;
real l=sqrt(r^2+h^2);
real a=(1-r/l)*360;
real a1=a/2;
real a2=360-a/2;
path g=arc(z0,r,a1,a2);
fill((0,0)--g--cycle,lightgreen);
draw(g);
pair z1=point(g,0);
pair z2=point(g,length(g));

real r2=1.1*r;
path c=arc(0,r2,a1,a2);
draw("$2\pi r$",c,red,Arrows,Bars,PenMargins);
pen edge=blue+0.5mm;
draw("$\ell$",z0--z1,0.5*SE,edge);
draw(z0--z2,edge);
draw(arc(z0,r,a2-360,a1),grey+dashed);
dot(0);

Mots-clefs :


Official Asymptote example – sacone3D

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 8 h 57 min

Figure 0170
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import solids;

size(0,75);
real r=1;
real h=1;

revolution R=cone(r,h);
draw(surface(R),lightgreen+opacity(0.5));
pen edge=blue+0.25mm;
draw("$\ell$",(0,r,0)--(0,0,h),W,edge);
draw("$r$",(0,0,0)--(r,0,0),red+dashed);
draw((0,0,0)--(0,0,h),red+dashed);
dot(h*Z);

Mots-clefs : , ,


Official Asymptote example – sacylinder

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 9 h 57 min

Figure 0171
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(0,100);

real r=1;
real h=3;

yaxis(dashed);

real m=0.475*h;

draw((r,0)--(r,h));
label("$L$",(r,0.5*h),E);

real s=4;

pair z1=(s,0);
pair z2=z1+(2*pi*r,h);
filldraw(box(z1,z2),lightgreen);
pair zm=0.5*(z1+z2);
label("$L$",(z1.x,zm.y),W);
label("$2\pi r$",(zm.x,z2.y),N);
draw("$r$",(0,m)--(r,m),N,red,Arrows);

draw((0,1.015h),yscale(0.5)*arc(0,0.25cm,-250,70),red,ArcArrow);




Official Asymptote example – sacylinder3D

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 10 h 57 min

Figure 0172
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import solids;
size(0,100);

real r=1;
real h=3;

revolution R=cylinder(-h/2*Z,r,h);
draw(surface(R),lightgreen+opacity(0.5));
draw((0,0,-h/2)--(0,0,h/2),dashed);
dot((0,0,-h/2));
dot((0,0,h/2));
draw("$L$",(0,r,-h/2)--(0,r,h/2),W,black);
draw("$r$",(0,0,-h/2)--(0,r,-h/2),red);
draw(arc(O,1,90,90,90,0),red,Arrow3);

Mots-clefs : , , ,


Official Asymptote example – saddle

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 11 h 57 min

Figure 0173
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

size(100,0);
path3 g=(1,0,0)..(0,1,1)..(-1,0,0)..(0,-1,1)..cycle;
draw(g);
draw(((-1,-1,0)--(1,-1,0)--(1,1,0)--(-1,1,0)--cycle));
dot(g,red);

Mots-clefs : , , ,


Official Asymptote example – scaledgraph

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 12 h 57 min

Figure 0174
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

axiscoverage=0.9;
size(200,IgnoreAspect);

real[] x={-1e-11,1e-11};
real[] y={0,1e6};

real xscale=round(log10(max(x)));
real yscale=round(log10(max(y)))-1;

draw(graph(x*10^(-xscale),y*10^(-yscale)),red);

xaxis("$x/10^{"+(string) xscale+"}$",BottomTop,LeftTicks);
yaxis("$y/10^{"+(string) yscale+"}$",LeftRight,RightTicks(trailingzero));

Mots-clefs : ,


Official Asymptote example – secondaryaxis

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 13 h 57 min

Figure 0175
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(9cm,6cm,IgnoreAspect);
string data="secondaryaxis.csv";

file in=line(csv(input(data)));

string[] titlelabel=in;
string[] columnlabel=in;

real[][] a=dimension(in,0,0);
a=transpose(a);
real[] t=a[0], susceptible=a[1], infectious=a[2], dead=a[3], larvae=a[4];
real[] susceptibleM=a[5], exposed=a[6],infectiousM=a[7];

scale(true);

draw(graph(t,susceptible,t >= 10 & t <= 15));
draw(graph(t,dead,t >= 10 & t <= 15),dashed);

xaxis("Time ($\tau$)",BottomTop,LeftTicks);
yaxis(Left,RightTicks);

picture secondary=secondaryY(new void(picture pic) {
    scale(pic,Linear(true),Log(true));
    draw(pic,graph(pic,t,infectious,t >= 10 & t <= 15),red);
    yaxis(pic,Right,red,LeftTicks(begin=false,end=false));
  });
                             
add(secondary);
label(shift(5mm*N)*"Proportion of crows",point(NW),E);


Mots-clefs : , , , ,


Official Asymptote example – shade

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 14 h 57 min

Figure 0176
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    

size(100,0);
radialshade(unitsquare,yellow,(0,0),0,red,(0,0),1);


Mots-clefs : ,


Official Asymptote example – shadedtiling

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 15 h 57 min

Figure 0177
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,100);
import patterns;

real d=4mm;
picture tiling;
path square=scale(d)*unitsquare;
axialshade(tiling,square,white,(0,0),black,(d,d));
fill(tiling,shift(d,d)*square,blue);
add("shadedtiling",tiling);

filldraw(unitcircle,pattern("shadedtiling"));


Mots-clefs : , , ,


Official Asymptote example – shadestroke

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 16 h 57 min

Figure 0178
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(100);

radialshade(W..N..E--(0,0),stroke=true,
            red+linewidth(30),(0,0),0.25,yellow,(0,0),1);


Mots-clefs : ,


Official Asymptote example – shellmethod

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 17 h 57 min

Figure 0179
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import solids;

size(400);
currentprojection=perspective(0,-1,30,up=Y);
currentlight=light(gray(0.75),(0.25,-0.25,1),(0,1,0));

pen color=green;
real alpha=240;

real f(real x) {return 2x^2-x^3;}
pair F(real x) {return (x,f(x));}
triple F3(real x) {return (x,f(x),0);}

int n=10;
path3[] blocks=new path3[n];
for(int i=1; i <= n; ++i) {
  real height=f((i-0.5)*2/n);
  real left=(i-1)*2/n;
  real right=i*2/n;
  blocks[i-1]=
    (left,0,0)--(left,height,0)--(right,height,0)--(right,0,0)--cycle;
}

path p=graph(F,0,2,n,operator ..)--cycle;
surface s=surface(p);
path3 p3=path3(p);

revolution a=revolution(p3,Y,0,alpha);
draw(surface(a),color);
draw(rotate(alpha,Y)*s,color);
for(int i=0; i < n; ++i)
  draw(surface(blocks[i]),color+opacity(0.5),black);
draw(p3);

xaxis3(Label("$x$",1,align=2X),Arrow3);
yaxis3(Label("$y$",1,align=2Y),ymax=1.4,dashed,Arrow3);
arrow("$y=2x^2-x^3$",XYplane(F(1.8)),X+Z,1.5cm,red,Arrow3(DefaultHead2));
draw(arc(1.17Y,0.3,90,0,7.5,180),ArcArrow3);

Mots-clefs : , , , ,


Official Asymptote example – shellsqrtx01

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 18 h 57 min

Figure 0180
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import solids;
size(0,150);
currentprojection=orthographic(1,0,10,up=Y);
pen color=green;
real alpha=-240;

real f(real x) {return sqrt(x);}
pair F(real x) {return (x,f(x));}
triple F3(real x) {return (x,f(x),0);}

path p=graph(F,0,1,n=30,operator ..)--(1,0)--cycle;
path3 p3=path3(p);

revolution a=revolution(p3,X,alpha,0);
draw(surface(a),color);
draw(p3,blue);

surface s=surface(p);
draw(s,color);
draw(rotate(alpha,X)*s,color);

xaxis3(Label("$x$",1),xmax=1.25,dashed,Arrow3);
yaxis3(Label("$y$",1),Arrow3);

dot("$(1,1)$",(1,1,0));
arrow("$y=\sqrt{x}$",F3(0.8),Y,0.75cm,red);

real r=0.4;
draw(F3(r)--(1,f(r),0),red);
real x=(1+r)/2;

draw("$r$",(x,0,0)--(x,f(r),0),X+0.2Z,red,Arrow3,PenMargin3);
draw(arc(1.1X,0.4,90,90,3,-90),Arrow3);

Mots-clefs : , , , ,


Official Asymptote example – sin1x

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

Figure 0181
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(200,0);

real f(real x) {return (x != 0) ? sin(1/x) : 0;}
real T(real x) {return 2/(x*pi);}

real a=-4/pi, b=4/pi;
int n=150,m=5;

xaxis("$x$",red);
yaxis(red);

draw(graph(f,a,-T(m),n)--graph(f,-m,-(m+n),n,T)--(0,f(0))--graph(f,m+n,m,n,T)--
     graph(f,T(m),b,n));

label("$\sin\frac{1}{x}$",(b,f(b)),SW);

Mots-clefs : , ,


Official Asymptote example – sinc

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

Figure 0182
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import contour;

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

size(12cm,0);

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

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

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

Mots-clefs : , , , ,


Official Asymptote example – sinxlex

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

Figure 0183
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import geometry;

size(0,100);
real theta=30;

pair A=(0,0); 
pair B=dir(theta);
pair C=(1,0);
pair D=(1,Tan(theta));
pair E=(Cos(theta),0);

filldraw(A--C{N}..B--cycle,lightgrey);
draw(B--C--D--cycle);
draw(B--E);

draw("$x$",arc(C,A,B,0.7),RightSide,Arrow,PenMargin);

dot("$A$",A,W);
dot("$B$",B,NW);
dot("$C$",C);
dot("$D$",D);
dot(("$E$"),E,S);
label("$1$",A--B,LeftSide);
      

Mots-clefs :


Official Asymptote example – slopefield1

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

Figure 0184
(Compiled with Asymptote version 1.87svn-r4652)
/* 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);



Mots-clefs : ,


Official Asymptote example – smoothelevation

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 23 h 57 min

Figure 0185
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import grid3;
import palette;

if(settings.render <= 0) settings.prc=false;

currentprojection=orthographic(1,2,13);

size(400,300,IgnoreAspect);

real f(pair z) {return cos(2*pi*z.x)*sin(2*pi*z.y);}

surface s=surface(f,(-1/2,-1/2),(1/2,1/2),20,Spline);
s.colors(palette(s.map(zpart),Rainbow()));

draw(s);

scale(true);

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

grid3(XYZgrid);

Mots-clefs : , , , ,


Official Asymptote example – soccerball

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 0 h 57 min

Figure 0186
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3; 
size(400); 
currentlight.background=palegreen;

real c=(1+sqrt(5))/2; 
 
triple[] z={(c,1,0),(-c,1,0),(-c,-1,0),(c,-1,0)}; 
triple[] x={(0,c,1),(0,-c,1),(0,-c,-1),(0,c,-1)}; 
triple[] y={(1,0,c),(1,0,-c),(-1,0,-c),(-1,0,c)}; 
 
triple[][] Q={
  {z[0],y[1],x[3],x[0],y[0],z[3]},
  {z[1],x[0],x[3],y[2],z[2],y[3]},
  {z[2],z[1],y[2],x[2],x[1],y[3]},
  {z[3],z[0],y[0],x[1],x[2],y[1]},
  {x[0],x[3],z[1],y[3],y[0],z[0]},
  {x[1],x[2],z[2],y[3],y[0],z[3]},
  {x[2],x[1],z[3],y[1],y[2],z[2]},
  {x[3],x[0],z[0],y[1],y[2],z[1]},
  {y[0],y[3],x[1],z[3],z[0],x[0]},
  {y[1],y[2],x[2],z[3],z[0],x[3]},
  {y[2],y[1],x[3],z[1],z[2],x[2]},
  {y[3],y[0],x[0],z[1],z[2],x[1]} 
}; 
 
path3 p=arc(O,Q[0][0],Q[0][1]); 
real R=abs(point(p,reltime(p,1/3))); 
 
triple[][] P;
for(int i=0; i < Q.length; ++i){
  P[i]=new triple[] ; 
  for(int j=0; j < Q[i].length; ++j){
    P[i][j]=Q[i][j]/R; 
  } 
} 
 
surface sphericaltriangle(triple center, triple A, triple B, triple C,
                          int nu=3, int nv=nu) {
  path3 tri1=arc(center,A,B); 
  path3 tri2=arc(center,A,C); 
  path3 tri3=arc(center,B,C); 
  triple tri(pair p) {
    path3 cr=arc(O,relpoint(tri2,p.x),relpoint(tri3,p.x)); 
    return relpoint(cr,p.y); 
  }; 
 
  return surface(tri,(0,0),(1-sqrtEpsilon,1),nu,nv,Spline); 
} 
 
for(int i=0; i < P.length; ++i){
  triple[] pentagon=sequence(new triple(int k) {
      path3 p=arc(O,P[i][0],P[i][k+1]); 
      return point(p,reltime(p,1/3)); 
    },5); 
  pentagon.cyclic=true; 
  draw(sequence(new path3(int k) {
        return arc(O,pentagon[k],pentagon[k+1]);},5),linewidth(2pt)); 
  triple M=unit(sum(pentagon)/5); 
  for(int i=0; i < 5; ++i){
    surface sf=sphericaltriangle(O,pentagon[i],M,pentagon[i+1]); 
    draw(sf,black); 
  } 
} 
 
for(int i=0; i < P.length; ++i){
  for(int j=1; j <= 5; ++j){
    triple K=P[i][0]; 
    triple A=P[i][j]; 
    triple B=P[i][(j % 5)+1]; 
    path3[] p={arc(O,K,A),arc(O,A,B),arc(O,B,K)}; 
    draw(subpath(p[0],reltime(p[0],1/3),reltime(p[0],2/3)),linewidth(4pt)); 
    triple[] hexagon={point(p[0],reltime(p[0],1/3)),
                      point(p[0],reltime(p[0],2/3)),
                      point(p[1],reltime(p[1],1/3)),
                      point(p[1],reltime(p[1],2/3)),
                      point(p[2],reltime(p[2],1/3)),
                      point(p[2],reltime(p[2],2/3))}; 
    hexagon.cyclic=true; 
    triple M=unit(sum(hexagon)/6); 
    for(int i=0; i < 6; ++i){
      surface sf=sphericaltriangle(O,hexagon[i],M,hexagon[i+1]); 
      draw(sf,white); 
    } 
  } 
}

Mots-clefs : , , , , , ,


Official Asymptote example – spectrum

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 1 h 57 min

Figure 0187
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
usepackage("ocg");
settings.tex="pdflatex";

// Dan Bruton algorithm
pen nm2rgb(real wl, real gamma=0.8, bool intensity=true) {
  triple rgb;
  if(wl >= 380 && wl <= 440) {rgb=((440-wl)/60,0,1);}
  if(wl >  440 && wl <= 490) {rgb=(0,(wl-440)/50,1);}
  if(wl >  490 && wl <= 510) {rgb=(0,1,(510-wl)/20);}
  if(wl >  510 && wl <= 580) {rgb=((wl-510)/70,1,0);}
  if(wl >  580 && wl <= 645) {rgb=(1,(645-wl)/65,0);}
  if(wl >  645 && wl <= 780) {rgb=(1,0,0);}
  
  real Intensity=1;
  if(intensity) {
    if(wl >= 700) {Intensity=0.3+0.7*(780-wl)/80;}
    else if(wl <= 420) {Intensity=0.3+0.7*(wl-380)/40;}
  }

  return rgb((Intensity*rgb.x)**gamma,(Intensity*rgb.y)**gamma,
             (Intensity*rgb.z)**gamma);
}

real width=1;
real height=50;

begin("spectrum");
for(real i=380 ; i <= 780 ; i += width) {
  draw((i,0)--(i,height),width+nm2rgb(wl=i,false)+squarecap);
}
begin("Extinction",false); // nested
for(real i=380 ; i <= 780 ; i += width) {
  draw((i,0)--(i,height),width+nm2rgb(wl=i,true)+squarecap);
}
end();
end();

begin("Wavelength");
xaxis(scale(0.5)*"$\lambda$(nm)",BottomTop,380,780,
      RightTicks(scale(0.5)*rotate(90)*Label(),step=2,Step=10),above=true);
end();

// From Astronomical Data Center(NASA)
// Neutral only
real[] Na={423.899, 424.208, 427.364, 427.679, 428.784, 429.101,
           432.14, 432.462, 434.149, 434.474, 439.003, 439.334, 441.989, 442.325,
           449.418, 449.766, 454.163, 454.519, 568.2633, 568.8204, 588.995,
           589.5924};
begin("Na absorption");
for(int i=0; i < Na.length; ++i) {
  draw((Na[i],0)--(Na[i],height),0.1*width+squarecap);
}
end();

begin("Na emission");
for(int i=0; i < Na.length; ++i) {
  draw((Na[i],0)--(Na[i],-height),0.1*width+nm2rgb(Na[i],false)+squarecap);
}
end();

// Neutral only
real[] Zn={388.334, 396.543, 411.321, 429.288, 429.833, 462.981,
           468.014, 472.215, 481.053 , 506.866, 506.958, 518.198, 530.865,
           531.024, 531.102, 577.21, 577.55, 577.711, 623.79, 623.917, 636.234,
           647.918, 692.832, 693.847, 694.32, 779.936};
begin("Zn absorption",false);
for(int i=0; i < Zn.length; ++i) {
  draw((Zn[i],0)--(Zn[i],height),width+squarecap);
}
end();

begin("Zn emission",false);
for(int i=0; i < Zn.length; ++i) {
  draw((Zn[i],0)--(Zn[i],-height),width+nm2rgb(Zn[i],false)+squarecap);
}
end();

shipout(bbox(2mm,Fill(white)));

Mots-clefs : , , , ,


Official Asymptote example – sphere

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 2 h 57 min

Figure 0188
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

size(200);
currentprojection=orthographic(5,4,3);

draw(unitsphere,green);

Mots-clefs : , ,


Official Asymptote example – spheresilhouette

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 3 h 57 min

Figure 0189
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import solids;
settings.render=0;
settings.prc=false;

size(200);

revolution r=sphere(O,1);
draw(r,1,longitudinalpen=nullpen);
draw(r.silhouette());

Mots-clefs : , , , ,


Official Asymptote example – sphereskeleton

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 4 h 57 min

Figure 0190
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(100); 
import solids; 

currentprojection=orthographic(5,4,2);

revolution sphere=sphere(1); 
draw(surface(sphere),green+opacity(0.2));
draw(sphere,m=7,blue);


Mots-clefs : , , , ,


Official Asymptote example – sphericalharmonic

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 5 h 57 min

Figure 0191
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import palette;
size(200);

currentprojection=orthographic(4,2,4);

real r(real theta, real phi) {return 1+0.5*(sin(2*theta)*sin(2*phi))^2;}

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

surface s=surface(f,(0,0),(pi,2pi),50,Spline);
s.colors(palette(s.map(abs),Gradient(yellow,red)));
draw(s);

Mots-clefs : , , ,


Official Asymptote example – spiral

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 6 h 57 min

Figure 0192
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,150);
import graph;

real f(real t) {return exp(-t/(2pi));}

draw(polargraph(f,0,20*pi,operator ..));

xaxis("$x$",-infinity,1.3);
yaxis("$y$",-infinity,1);

labelx(1);
labelx("$e^{-1}$",1.0/exp(1),SE);

Mots-clefs : , , ,


Official Asymptote example – spiral3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

Figure 0193
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import palette;
 
size3(10cm);
 
currentprojection=orthographic(5,4,2);

real r(real t) {return 3exp(-0.1*t);}
real x(real t) {return r(t)*cos(t);}
real y(real t) {return r(t)*sin(t);}
real z(real t) {return t;}

path3 p=graph(x,y,z,0,6*pi,50,operator ..);

tube T=tube(p,2);
surface s=T.s;
s.colors(palette(s.map(zpart),BWRainbow()));
draw(s);
draw(T.center,thin());

Mots-clefs : , , , , ,


Official Asymptote example – spline

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 8 h 57 min

Figure 0194
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph; 
import interpolate; 
 
size(15cm,15cm,IgnoreAspect); 
 
real a=1997, b=2002; 
int n=5; 
real[] xpt=a+sequence(n+1)*(b-a)/n; 
real[] ypt={31,36,26,22,21,24}; 
horner h=diffdiv(xpt,ypt);
fhorner L=fhorner(h);
 
scale(false,true);

pen p=linewidth(1);

draw(graph(L,a,b),dashed+black+p,"Lagrange interpolation");
draw(graph(xpt,ypt,Hermite(natural)),red+p,"natural spline");
draw(graph(xpt,ypt,Hermite(monotonic)),blue+p,"monotone spline");
xaxis("$x$",BottomTop,LeftTicks(Step=1,step=0.25));
yaxis("$y$",LeftRight,RightTicks(Step=5));

dot(pairs(xpt,ypt),4bp+gray(0.3));

attach(legend(),point(10S),30S);

Mots-clefs : , ,


Official Asymptote example – splitpatch

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 9 h 57 min

Figure 0195
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

currentprojection=orthographic(0,0,1);

triple[][] A={
  {(0,0,0),(1,0,0),(1,0,0),(2,0,0)},
  {(0,4/3,0),(2/3,4/3,2),(4/3,4/3,2),(2,4/3,0)},
  {(0,2/3,0),(2/3,2/3,0),(4/3,2/3,0),(2,2/3,0)},
  {(0,2,0),(2/3,2,0),(4/3,2,0),(2,2,0)}
};

triple[][] B={
  {(0.5,0,-1),(0.5,1,-1),(0.5,2,-1),(0.5,3,-1)},
  {(0.5,0,0),(0.5,1,0),(0.5,2,0),(0.5,3,0)},
  {(0.5,0,1),(0.5,1,1),(0.5,2,1),(0.5,3,1)},
  {(0.5,0,2),(0.5,1,2),(0.5,2,2),(0.5,3,2)}
};

split S=split(A,B,10);
//write(S.T.length);

for(int i=0; i < S.T.length; ++i)
  draw(surface(patch(S.T[i])),Pen(i));
draw(surface(patch(B)),blue);

Mots-clefs : , ,


Official Asymptote example – spring0

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 10 h 57 min

Figure 0196
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import spring;

drawspring(0,"$L$");


Mots-clefs : ,


Official Asymptote example – spring2

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 11 h 57 min

Figure 0197
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import spring;

drawspring(40.0,"$L+x$");


Mots-clefs : ,


Official Asymptote example – sqrtx01

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 12 h 57 min

Figure 0198
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import solids;
size(0,150);
currentprojection=perspective(1.5,0,10,Y);
pen color=green+opacity(0.75);

real f(real x){return sqrt(x);}
pair F(real x){return (x,f(x));}
triple F3(real x){return (x,f(x),0);}

path p=graph(F,0,1,n=20,operator ..);
path3 p3=path3(p);

revolution a=revolution(p3,X,0,360);
draw(surface(a),color);
draw(p3,blue);

real x=relpoint(p,0.5).x;

xaxis3(Label("$x$",1),xmax=1.5,dashed,Arrow3);
yaxis3(Label("$y$",1),Arrow3);
dot(Label("$(1,1)$"),(1,1,0));
arrow(Label("$y=\sqrt{x}$"),F3(0.7),Y,0.75cm,red);
draw(arc(1.2X,0.4,90,90,175,-40,CW),Arrow3);
draw("$r$",(x,0,0)--F3(x),red,Arrow3,PenMargin3);

Mots-clefs : , , , ,


Official Asymptote example – sqrtx01y1

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 13 h 57 min

Figure 0199
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import solids;
size(0,150);
currentprojection=perspective(0,1,10,up=Y);

real f(real x) {return sqrt(x);}
pair F(real x) {return (x,f(x));}
triple F3(real x) {return (x,f(x),0);}

path p=graph(F,0,1,n=25,operator ..);
path3 p3=path3(p);

revolution a=revolution(p3,Y,0,360);
draw(surface(a),green);
draw(p3,blue);

xtick((0,0,0));
xtick((1,0,0));

xaxis3(Label("$x$",1),Arrow3);
yaxis3(Label("$y$",1),ymax=1.5,dashed,Arrow3);
dot(Label("$(1,1)$"),(1,1,0));
arrow("$y=\sqrt{x}$",F3(0.5),X,0.75cm,red);
draw(arc(1.2Y,0.3,90,0,7.5,140),Arrow3);

Mots-clefs : , , , ,


Official Asymptote example – square

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 14 h 57 min

Figure 0200
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
draw((0,0)--(100,0)--(100,100)--(0,100)--cycle);

Mots-clefs : ,


Official Asymptote example – star

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 15 h 57 min

Figure 0201
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(100);
import math;

int n=5;
path p;

int i=0;
do {
  p=p--unityroot(n,i);
  i=(i+2) % n;
} while(i != 0);

filldraw(p--cycle,red+evenodd);

Mots-clefs : , , , ,


Official Asymptote example – strokepath

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 16 h 57 min

Figure 0202
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
path g=scale(100)*unitcircle;
pen p=linewidth(1cm);

frame f;
// Equivalent to draw(f,g,p):
fill(f,strokepath(g,p),red);
shipout("strokepathframe",f);
shipped=false;

size(400);

// Equivalent to draw(g,p):
currentpicture.add(new void(frame f, transform t) {
    fill(f,strokepath(t*g,p),red);
  });
currentpicture.addPath(g,p);


Mots-clefs : , ,


Official Asymptote example – strokeshade

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 17 h 57 min

Figure 0203
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(100);
guide g=(0,0)..controls(70,30) and (-40,30)..(30,0);
latticeshade(g,stroke=true,linewidth(10),
             new pen[][] {{red,orange,yellow},{green,blue,purple}});

Mots-clefs : ,


Official Asymptote example – subpictures

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 18 h 57 min

Figure 0204
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
picture pic1;
real size=50;
size(pic1,size);
fill(pic1,(0,0)--(50,100)--(100,0)--cycle,red);

picture pic2;
size(pic2,size);
fill(pic2,unitcircle,green);

picture pic3;
size(pic3,size);
fill(pic3,unitsquare,blue);

picture pic;
add(pic,pic1.fit(),(0,0),N);
add(pic,pic2.fit(),(0,0),10S);

add(pic.fit(),(0,0),N);
add(pic3.fit(),(0,0),10S);


Mots-clefs : , ,


Official Asymptote example – superpath

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

Figure 0205
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,100);
path unitcircle=E..N..W..S..cycle;
path g=scale(2)*unitcircle;
filldraw(unitcircle^^g,evenodd+yellow,black);


Mots-clefs : , ,


Official Asymptote example – tanh

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

Figure 0206
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(100,0);

real f(real x) {return tanh(x);}
pair F(real x) {return (x,f(x));}

xaxis("$x$");
yaxis("$y$");

draw(graph(f,-2.5,2.5,operator ..));

label("$\tanh x$",F(1.5),1.25*N);


Mots-clefs : , ,


Official Asymptote example – teapot

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

Figure 0207
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

size(20cm);

currentprojection=perspective(250,-250,250);
//currentlight=White;

triple[][][] Q={
  {
    {(39.68504,0.0,68.03150),(39.68504,-22.22362,68.03150),(22.22362,-39.68504,68.03150),(0.0,-39.68504,68.03150)},
    {(37.91339,0.0,71.75197),(37.91339,-21.23150,71.75197),(21.23150,-37.91339,71.75197),(0.0,-37.91339,71.75197)},
    {(40.74803,0.0,71.75197),(40.74803,-22.81890,71.75197),(22.81890,-40.74803,71.75197),(0.0,-40.74803,71.75197)},
    {(42.51969,0.0,68.03150),(42.51969,-23.81102,68.03150),(23.81102,-42.51969,68.03150),(0.0,-42.51969,68.03150)},
  },
  {
    {(0.0,-39.68504,68.03150),(-22.22362,-39.68504,68.03150),(-39.68504,-22.22362,68.03150),(-39.68504,0.0,68.03150)},
    {(0.0,-37.91339,71.75197),(-21.23150,-37.91339,71.75197),(-37.91339,-21.23150,71.75197),(-37.91339,0.0,71.75197)},
    {(0.0,-40.74803,71.75197),(-22.81890,-40.74803,71.75197),(-40.74803,-22.81890,71.75197),(-40.74803,0.0,71.75197)},
    {(0.0,-42.51969,68.03150),(-23.81102,-42.51969,68.03150),(-42.51969,-23.81102,68.03150),(-42.51969,0.0,68.03150)},
  },
  {
    {(-39.68504,0.0,68.03150),(-39.68504,22.22362,68.03150),(-22.22362,39.68504,68.03150),(0.0,39.68504,68.03150)},
    {(-37.91339,0.0,71.75197),(-37.91339,21.23150,71.75197),(-21.23150,37.91339,71.75197),(0.0,37.91339,71.75197)},
    {(-40.74803,0.0,71.75197),(-40.74803,22.81890,71.75197),(-22.81890,40.74803,71.75197),(0.0,40.74803,71.75197)},
    {(-42.51969,0.0,68.03150),(-42.51969,23.81102,68.03150),(-23.81102,42.51969,68.03150),(0.0,42.51969,68.03150)},
  },
  {
    {(0.0,39.68504,68.03150),(22.22362,39.68504,68.03150),(39.68504,22.22362,68.03150),(39.68504,0.0,68.03150)},
    {(0.0,37.91339,71.75197),(21.23150,37.91339,71.75197),(37.91339,21.23150,71.75197),(37.91339,0.0,71.75197)},
    {(0.0,40.74803,71.75197),(22.81890,40.74803,71.75197),(40.74803,22.81890,71.75197),(40.74803,0.0,71.75197)},
    {(0.0,42.51969,68.03150),(23.81102,42.51969,68.03150),(42.51969,23.81102,68.03150),(42.51969,0.0,68.03150)},
  },
  {
    {(42.51969,0.0,68.03150),(42.51969,-23.81102,68.03150),(23.81102,-42.51969,68.03150),(0.0,-42.51969,68.03150)},
    {(49.60629,0.0,53.14960),(49.60629,-27.77952,53.14960),(27.77952,-49.60629,53.14960),(0.0,-49.60629,53.14960)},
    {(56.69291,0.0,38.26771),(56.69291,-31.74803,38.26771),(31.74803,-56.69291,38.26771),(0.0,-56.69291,38.26771)},
    {(56.69291,0.0,25.51181),(56.69291,-31.74803,25.51181),(31.74803,-56.69291,25.51181),(0.0,-56.69291,25.51181)},
  },
  {
    {(0.0,-42.51969,68.03150),(-23.81102,-42.51969,68.03150),(-42.51969,-23.81102,68.03150),(-42.51969,0.0,68.03150)},
    {(0.0,-49.60629,53.14960),(-27.77952,-49.60629,53.14960),(-49.60629,-27.77952,53.14960),(-49.60629,0.0,53.14960)},
    {(0.0,-56.69291,38.26771),(-31.74803,-56.69291,38.26771),(-56.69291,-31.74803,38.26771),(-56.69291,0.0,38.26771)},
    {(0.0,-56.69291,25.51181),(-31.74803,-56.69291,25.51181),(-56.69291,-31.74803,25.51181),(-56.69291,0.0,25.51181)},
  },
  {
    {(-42.51969,0.0,68.03150),(-42.51969,23.81102,68.03150),(-23.81102,42.51969,68.03150),(0.0,42.51969,68.03150)},
    {(-49.60629,0.0,53.14960),(-49.60629,27.77952,53.14960),(-27.77952,49.60629,53.14960),(0.0,49.60629,53.14960)},
    {(-56.69291,0.0,38.26771),(-56.69291,31.74803,38.26771),(-31.74803,56.69291,38.26771),(0.0,56.69291,38.26771)},
    {(-56.69291,0.0,25.51181),(-56.69291,31.74803,25.51181),(-31.74803,56.69291,25.51181),(0.0,56.69291,25.51181)},
  },
  {
    {(0.0,42.51969,68.03150),(23.81102,42.51969,68.03150),(42.51969,23.81102,68.03150),(42.51969,0.0,68.03150)},
    {(0.0,49.60629,53.14960),(27.77952,49.60629,53.14960),(49.60629,27.77952,53.14960),(49.60629,0.0,53.14960)},
    {(0.0,56.69291,38.26771),(31.74803,56.69291,38.26771),(56.69291,31.74803,38.26771),(56.69291,0.0,38.26771)},
    {(0.0,56.69291,25.51181),(31.74803,56.69291,25.51181),(56.69291,31.74803,25.51181),(56.69291,0.0,25.51181)},
  },
  {
    {(56.69291,0.0,25.51181),(56.69291,-31.74803,25.51181),(31.74803,-56.69291,25.51181),(0.0,-56.69291,25.51181)},
    {(56.69291,0.0,12.75590),(56.69291,-31.74803,12.75590),(31.74803,-56.69291,12.75590),(0.0,-56.69291,12.75590)},
    {(42.51969,0.0,6.377957),(42.51969,-23.81102,6.377957),(23.81102,-42.51969,6.377957),(0.0,-42.51969,6.377957)},
    {(42.51969,0.0,4.251961),(42.51969,-23.81102,4.251961),(23.81102,-42.51969,4.251961),(0.0,-42.51969,4.251961)},
  },
  {
    {(0.0,-56.69291,25.51181),(-31.74803,-56.69291,25.51181),(-56.69291,-31.74803,25.51181),(-56.69291,0.0,25.51181)},
    {(0.0,-56.69291,12.75590),(-31.74803,-56.69291,12.75590),(-56.69291,-31.74803,12.75590),(-56.69291,0.0,12.75590)},
    {(0.0,-42.51969,6.377957),(-23.81102,-42.51969,6.377957),(-42.51969,-23.81102,6.377957),(-42.51969,0.0,6.377957)},
    {(0.0,-42.51969,4.251961),(-23.81102,-42.51969,4.251961),(-42.51969,-23.81102,4.251961),(-42.51969,0.0,4.251961)},
  },
  {
    {(-56.69291,0.0,25.51181),(-56.69291,31.74803,25.51181),(-31.74803,56.69291,25.51181),(0.0,56.69291,25.51181)},
    {(-56.69291,0.0,12.75590),(-56.69291,31.74803,12.75590),(-31.74803,56.69291,12.75590),(0.0,56.69291,12.75590)},
    {(-42.51969,0.0,6.377957),(-42.51969,23.81102,6.377957),(-23.81102,42.51969,6.377957),(0.0,42.51969,6.377957)},
    {(-42.51969,0.0,4.251961),(-42.51969,23.81102,4.251961),(-23.81102,42.51969,4.251961),(0.0,42.51969,4.251961)},
  },
  {
    {(0.0,56.69291,25.51181),(31.74803,56.69291,25.51181),(56.69291,31.74803,25.51181),(56.69291,0.0,25.51181)},
    {(0.0,56.69291,12.75590),(31.74803,56.69291,12.75590),(56.69291,31.74803,12.75590),(56.69291,0.0,12.75590)},
    {(0.0,42.51969,6.377957),(23.81102,42.51969,6.377957),(42.51969,23.81102,6.377957),(42.51969,0.0,6.377957)},
    {(0.0,42.51969,4.251961),(23.81102,42.51969,4.251961),(42.51969,23.81102,4.251961),(42.51969,0.0,4.251961)},
  },
  {
    {(-45.35433,0.0,57.40157),(-45.35433,-8.503932,57.40157),(-42.51969,-8.503932,63.77952),(-42.51969,0.0,63.77952)},
    {(-65.19685,0.0,57.40157),(-65.19685,-8.503932,57.40157),(-70.86614,-8.503932,63.77952),(-70.86614,0.0,63.77952)},
    {(-76.53543,0.0,57.40157),(-76.53543,-8.503932,57.40157),(-85.03937,-8.503932,63.77952),(-85.03937,0.0,63.77952)},
    {(-76.53543,0.0,51.02362),(-76.53543,-8.503932,51.02362),(-85.03937,-8.503932,51.02362),(-85.03937,0.0,51.02362)},
  },
  {
    {(-42.51969,0.0,63.77952),(-42.51969,8.503932,63.77952),(-45.35433,8.503932,57.40157),(-45.35433,0.0,57.40157)},
    {(-70.86614,0.0,63.77952),(-70.86614,8.503932,63.77952),(-65.19685,8.503932,57.40157),(-65.19685,0.0,57.40157)},
    {(-85.03937,0.0,63.77952),(-85.03937,8.503932,63.77952),(-76.53543,8.503932,57.40157),(-76.53543,0.0,57.40157)},
    {(-85.03937,0.0,51.02362),(-85.03937,8.503932,51.02362),(-76.53543,8.503932,51.02362),(-76.53543,0.0,51.02362)},
  },
  {
    {(-76.53543,0.0,51.02362),(-76.53543,-8.503932,51.02362),(-85.03937,-8.503932,51.02362),(-85.03937,0.0,51.02362)},
    {(-76.53543,0.0,44.64566),(-76.53543,-8.503932,44.64566),(-85.03937,-8.503932,38.26771),(-85.03937,0.0,38.26771)},
    {(-70.86614,0.0,31.88976),(-70.86614,-8.503932,31.88976),(-75.11811,-8.503932,26.57480),(-75.11811,0.0,26.57480)},
    {(-56.69291,0.0,25.51181),(-56.69291,-8.503932,25.51181),(-53.85826,-8.503932,17.00787),(-53.85826,0.0,17.00787)},
  },
  {
    {(-85.03937,0.0,51.02362),(-85.03937,8.503932,51.02362),(-76.53543,8.503932,51.02362),(-76.53543,0.0,51.02362)},
    {(-85.03937,0.0,38.26771),(-85.03937,8.503932,38.26771),(-76.53543,8.503932,44.64566),(-76.53543,0.0,44.64566)},
    {(-75.11811,0.0,26.57480),(-75.11811,8.503932,26.57480),(-70.86614,8.503932,31.88976),(-70.86614,0.0,31.88976)},
    {(-53.85826,0.0,17.00787),(-53.85826,8.503932,17.00787),(-56.69291,8.503932,25.51181),(-56.69291,0.0,25.51181)},
  },
  {
    {(48.18897,0.0,40.39370),(48.18897,-18.70866,40.39370),(48.18897,-18.70866,17.00787),(48.18897,0.0,17.00787)},
    {(73.70078,0.0,40.39370),(73.70078,-18.70866,40.39370),(87.87401,-18.70866,23.38582),(87.87401,0.0,23.38582)},
    {(65.19685,0.0,59.52755),(65.19685,-7.086619,59.52755),(68.03150,-7.086619,57.40157),(68.03150,0.0,57.40157)},
    {(76.53543,0.0,68.03150),(76.53543,-7.086619,68.03150),(93.54330,-7.086619,68.03150),(93.54330,0.0,68.03150)},
  },
  {
    {(48.18897,0.0,17.00787),(48.18897,18.70866,17.00787),(48.18897,18.70866,40.39370),(48.18897,0.0,40.39370)},
    {(87.87401,0.0,23.38582),(87.87401,18.70866,23.38582),(73.70078,18.70866,40.39370),(73.70078,0.0,40.39370)},
    {(68.03150,0.0,57.40157),(68.03150,7.086619,57.40157),(65.19685,7.086619,59.52755),(65.19685,0.0,59.52755)},
    {(93.54330,0.0,68.03150),(93.54330,7.086619,68.03150),(76.53543,7.086619,68.03150),(76.53543,0.0,68.03150)},
  },
  {
    {(76.53543,0.0,68.03150),(76.53543,-7.086619,68.03150),(93.54330,-7.086619,68.03150),(93.54330,0.0,68.03150)},
    {(79.37007,0.0,70.15748),(79.37007,-7.086619,70.15748),(99.92125,-7.086619,70.68897),(99.92125,0.0,70.68897)},
    {(82.20472,0.0,70.15748),(82.20472,-4.251961,70.15748),(97.79527,-4.251961,71.22047),(97.79527,0.0,71.22047)},
    {(79.37007,0.0,68.03150),(79.37007,-4.251961,68.03150),(90.70866,-4.251961,68.03150),(90.70866,0.0,68.03150)},
  },
  {
    {(93.54330,0.0,68.03150),(93.54330,7.086619,68.03150),(76.53543,7.086619,68.03150),(76.53543,0.0,68.03150)},
    {(99.92125,0.0,70.68897),(99.92125,7.086619,70.68897),(79.37007,7.086619,70.15748),(79.37007,0.0,70.15748)},
    {(97.79527,0.0,71.22047),(97.79527,4.251961,71.22047),(82.20472,4.251961,70.15748),(82.20472,0.0,70.15748)},
    {(90.70866,0.0,68.03150),(90.70866,4.251961,68.03150),(79.37007,4.251961,68.03150),(79.37007,0.0,68.03150)},
  },
  {
    {(0.0,0.0,89.29133),(0.0,0.0,89.29133),(0.0,0.0,89.29133),(0.0,0.0,89.29133)},
    {(22.67716,0.0,89.29133),(22.67716,-12.75590,89.29133),(12.75590,-22.67716,89.29133),(0.0,-22.67716,89.29133)},
    {(0.0,0.0,80.78740),(0.0,0.0,80.78740),(0.0,0.0,80.78740),(0.0,0.0,80.78740)},
    {(5.669294,0.0,76.53543),(5.669294,-3.174809,76.53543),(3.174809,-5.669294,76.53543),(0.0,-5.669294,76.53543)},
  },
  {
    {(0.0,0.0,89.29133),(0.0,0.0,89.29133),(0.0,0.0,89.29133),(0.0,0.0,89.29133)},
    {(0.0,-22.67716,89.29133),(-12.75590,-22.67716,89.29133),(-22.67716,-12.75590,89.29133),(-22.67716,0.0,89.29133)},
    {(0.0,0.0,80.78740),(0.0,0.0,80.78740),(0.0,0.0,80.78740),(0.0,0.0,80.78740)},
    {(0.0,-5.669294,76.53543),(-3.174809,-5.669294,76.53543),(-5.669294,-3.174809,76.53543),(-5.669294,0.0,76.53543)},
  },
  {
    {(0.0,0.0,89.29133),(0.0,0.0,89.29133),(0.0,0.0,89.29133),(0.0,0.0,89.29133)},
    {(-22.67716,0.0,89.29133),(-22.67716,12.75590,89.29133),(-12.75590,22.67716,89.29133),(0.0,22.67716,89.29133)},
    {(0.0,0.0,80.78740),(0.0,0.0,80.78740),(0.0,0.0,80.78740),(0.0,0.0,80.78740)},
    {(-5.669294,0.0,76.53543),(-5.669294,3.174809,76.53543),(-3.174809,5.669294,76.53543),(0.0,5.669294,76.53543)},
  },
  {
    {(0.0,0.0,89.29133),(0.0,0.0,89.29133),(0.0,0.0,89.29133),(0.0,0.0,89.29133)},
    {(0.0,22.67716,89.29133),(12.75590,22.67716,89.29133),(22.67716,12.75590,89.29133),(22.67716,0.0,89.29133)},
    {(0.0,0.0,80.78740),(0.0,0.0,80.78740),(0.0,0.0,80.78740),(0.0,0.0,80.78740)},
    {(0.0,5.669294,76.53543),(3.174809,5.669294,76.53543),(5.669294,3.174809,76.53543),(5.669294,0.0,76.53543)},
  },
  {
    {(5.669294,0.0,76.53543),(5.669294,-3.174809,76.53543),(3.174809,-5.669294,76.53543),(0.0,-5.669294,76.53543)},
    {(11.33858,0.0,72.28346),(11.33858,-6.349609,72.28346),(6.349609,-11.33858,72.28346),(0.0,-11.33858,72.28346)},
    {(36.85039,0.0,72.28346),(36.85039,-20.63622,72.28346),(20.63622,-36.85039,72.28346),(0.0,-36.85039,72.28346)},
    {(36.85039,0.0,68.03150),(36.85039,-20.63622,68.03150),(20.63622,-36.85039,68.03150),(0.0,-36.85039,68.03150)},
  },
  {
    {(0.0,-5.669294,76.53543),(-3.174809,-5.669294,76.53543),(-5.669294,-3.174809,76.53543),(-5.669294,0.0,76.53543)},
    {(0.0,-11.33858,72.28346),(-6.349609,-11.33858,72.28346),(-11.33858,-6.349609,72.28346),(-11.33858,0.0,72.28346)},
    {(0.0,-36.85039,72.28346),(-20.63622,-36.85039,72.28346),(-36.85039,-20.63622,72.28346),(-36.85039,0.0,72.28346)},
    {(0.0,-36.85039,68.03150),(-20.63622,-36.85039,68.03150),(-36.85039,-20.63622,68.03150),(-36.85039,0.0,68.03150)},
  },
  {
    {(-5.669294,0.0,76.53543),(-5.669294,3.174809,76.53543),(-3.174809,5.669294,76.53543),(0.0,5.669294,76.53543)},
    {(-11.33858,0.0,72.28346),(-11.33858,6.349609,72.28346),(-6.349609,11.33858,72.28346),(0.0,11.33858,72.28346)},
    {(-36.85039,0.0,72.28346),(-36.85039,20.63622,72.28346),(-20.63622,36.85039,72.28346),(0.0,36.85039,72.28346)},
    {(-36.85039,0.0,68.03150),(-36.85039,20.63622,68.03150),(-20.63622,36.85039,68.03150),(0.0,36.85039,68.03150)},
  },
  {
    {(0.0,5.669294,76.53543),(3.174809,5.669294,76.53543),(5.669294,3.174809,76.53543),(5.669294,0.0,76.53543)},
    {(0.0,11.33858,72.28346),(6.349609,11.33858,72.28346),(11.33858,6.349609,72.28346),(11.33858,0.0,72.28346)},
    {(0.0,36.85039,72.28346),(20.63622,36.85039,72.28346),(36.85039,20.63622,72.28346),(36.85039,0.0,72.28346)},
    {(0.0,36.85039,68.03150),(20.63622,36.85039,68.03150),(36.85039,20.63622,68.03150),(36.85039,0.0,68.03150)},
  },
  {
    {(0.0,0.0,0.0),(0.0,0.0,0.0),(0.0,0.0,0.0),(0.0,0.0,0.0)},
    {(40.39370,0.0,0.0),(40.39370,22.62047,0.0),(22.62047,40.39370,0.0),(0.0,40.39370,0.0)},
    {(42.51969,0.0,2.12598),(42.51969,23.81102,2.12598),(23.81102,42.51969,2.12598),(0.0,42.51969,2.12598)},
    {(42.51969,0.0,4.251961),(42.51969,23.81102,4.251961),(23.81102,42.51969,4.251961),(0.0,42.51969,4.251961)},
  },
  {
    {(0.0,0.0,0.0),(0.0,0.0,0.0),(0.0,0.0,0.0),(0.0,0.0,0.0)},
    {(0.0,40.39370,0.0),(-22.62047,40.39370,0.0),(-40.39370,22.62047,0.0),(-40.39370,0.0,0.0)},
    {(0.0,42.51969,2.12598),(-23.81102,42.51969,2.12598),(-42.51969,23.81102,2.12598),(-42.51969,0.0,2.12598)},
    {(0.0,42.51969,4.251961),(-23.81102,42.51969,4.251961),(-42.51969,23.81102,4.251961),(-42.51969,0.0,4.251961)},
  },
  {
    {(0.0,0.0,0.0),(0.0,0.0,0.0),(0.0,0.0,0.0),(0.0,0.0,0.0)},
    {(-40.39370,0.0,0.0),(-40.39370,-22.62047,0.0),(-22.62047,-40.39370,0.0),(0.0,-40.39370,0.0)},
    {(-42.51969,0.0,2.12598),(-42.51969,-23.81102,2.12598),(-23.81102,-42.51969,2.12598),(0.0,-42.51969,2.12598)},
    {(-42.51969,0.0,4.251961),(-42.51969,-23.81102,4.251961),(-23.81102,-42.51969,4.251961),(0.0,-42.51969,4.251961)},
  },
  {
    {(0.0,0.0,0.0),(0.0,0.0,0.0),(0.0,0.0,0.0),(0.0,0.0,0.0)},
    {(0.0,-40.39370,0.0),(22.62047,-40.39370,0.0),(40.39370,-22.62047,0.0),(40.39370,0.0,0.0)},
    {(0.0,-42.51969,2.12598),(23.81102,-42.51969,2.12598),(42.51969,-23.81102,2.12598),(42.51969,0.0,2.12598)},
    {(0.0,-42.51969,4.251961),(23.81102,-42.51969,4.251961),(42.51969,-23.81102,4.251961),(42.51969,0.0,4.251961)},
  }
};

draw(surface(Q),blue);

Mots-clefs : , , ,


Official Asymptote example – tensor

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

Figure 0208
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);

pen[][] p={{red,green,blue,cyan},{green,blue,rgb(black),magenta}};
path G=(0,0){dir(-120)}..(1,0)..(1,1)..(0,1)..cycle;
path[] g={G,subpath(G,1,2)..(2,1)..(2,0)..cycle};
pair[][] z={{(0.5,0.5),(0.5,0.5),(0.5,0.5),(0.5,0.5)},{(2,0.5),(2,0.5),(1.5,0.5),(2,0.5)}};
tensorshade(g,p,z);
dot(g);

Mots-clefs : , ,


Official Asymptote example – textpath

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 23 h 57 min

Figure 0209
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(300);

fill(texpath(Label("test",TimesRoman())),pink);
fill(texpath(Label("test",fontcommand('.fam T\n.ps 12')),tex=false),red);

pair z=10S;

fill(texpath(Label("$ \sqrt{x^2} $",z,TimesRoman())),pink);
fill(texpath(Label("$ sqrt {x sup 2} $",z,fontcommand('.fam T\n.ps 12')),
             tex=false),red);

Mots-clefs : , , , ,


Official Asymptote example – thermodynamics

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 0 h 57 min

Figure 0210
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
// example file for roundedpath() in roundedpath.asy
// written by stefan knorr


// import needed packages
import roundedpath;

// function definition
picture CreateKOOS(real Scale, string legend)               // draw labeled coordinate system as picture
{
  picture ReturnPic;
  real S = 1.2*Scale;
  draw(ReturnPic, ((-S,0)--(S,0)), bar = EndArrow);         // x axis
  draw(ReturnPic, ((0,-S)--(0,S)), bar = EndArrow);         // y axis
  label(ReturnPic, "$\varepsilon$", (S,0), SW);             // x axis label
  label(ReturnPic, "$\sigma$", (0,S), SW);                  // y axis label
  label(ReturnPic, legend, (0.7S, -S), NW);                 // add label 'legend' 
  return ReturnPic;                                         // return picture
}


// some global definitions
real S = 13mm;                          // universal scale factor for the whole file
real grad = 0.25;                       // gradient for lines
real radius = 0.04;                     // radius for the rounded path'
real lw = 2;                            // linewidth
pair A = (-1, -1);                      // start point for graphs
pair E = ( 1,  1);                      // end point for graphs
path graph;                             // local graph
pen ActPen;                             // actual pen for each drawing
picture T[];                            // vector of all four diagrams
real inc = 2.8;                         // increment-offset for combining pictures

//////////////////////////////////////// 1st diagram
T[1] = CreateKOOS(S, "$T_1$");                                        // initialise T[1] as empty diagram with label $T_1$                  
graph = A;                                                            //  # pointwise definition of current path 'graph'                    
graph = graph -- (A.x + grad*1.6, A.y + 1.6);                         //  #                                                                 
graph = graph -- (E.x - grad*0.4, E.y - 0.4);                         //  #                                                                 
graph = graph -- E;                                                   //  #

graph = roundedpath(graph, radius, S);                                // round edges of 'graph' using roundedpath() in roundedpath.asy      
ActPen =  rgb(0,0,0.6) + linewidth(lw);                               // define pen for drawing in 1st diagram                              
draw(T[1],                   graph, ActPen);                          // draw 'graph' with 'ActPen' into 'T[1]' (1st hysteresis branch)     
draw(T[1], rotate(180,(0,0))*graph, ActPen);                          // draw rotated 'graph' (2nd hysteresis branch)                       

graph = (0,0) -- (grad*0.6, 0.6) -- ( (grad*0.6, 0.6) + (0.1, 0) );   // define branch from origin to hysteresis
graph = roundedpath(graph, radius, S);                                // round this path                        
draw(T[1], graph, ActPen);                                            // draw this path into 'T[1]'             


//////////////////////////////////////// 2nd diagram
T[2] = CreateKOOS(S, "$T_2$");                                        // initialise T[2] as empty diagram with label $T_2$              
graph = A;                                                            //  # pointwise definition of current path 'graph'                
graph = graph -- (A.x + grad*1.3, A.y + 1.3);                         //  #                                                             
graph = graph -- (E.x - grad*0.7 , E.y - 0.7);                        //  #                                                             
graph = graph -- E;                                                   //  #
                                                                                                
graph = roundedpath(graph, radius, S);                                // round edges of 'graph' using roundedpath() in roundedpath.asy      
ActPen =  rgb(0.2,0,0.4) + linewidth(lw);                             // define pen for drawing in 2nd diagram                              
draw(T[2],                   graph, ActPen);                          // draw 'graph' with 'ActPen' into 'T[2]' (1st hysteresis branch)     
draw(T[2], rotate(180,(0,0))*graph, ActPen);                          // draw rotated 'graph' (2nd hysteresis branch)                       

graph = (0,0) -- (grad*0.3, 0.3) -- ( (grad*0.3, 0.3) + (0.1, 0) );   // define branch from origin to hysteresis
graph = roundedpath(graph, radius, S);                                // round this path                        
draw(T[2], graph, ActPen);                                            // draw this path into 'T[2]'             


//////////////////////////////////////// 3rd diagram
T[3] = CreateKOOS(S, "$T_3$");                                        // initialise T[3] as empty diagram with label $T_3$              
graph = A;                                                            //  # pointwise definition of current path 'graph'                
graph = graph -- (A.x + grad*0.7, A.y + 0.7);                         //  #                                                             
graph = graph -- ( - grad*0.3 , - 0.3);                               //  #                                                             
graph = graph -- (0,0);                                               //  #                                                             
graph = graph -- (grad*0.6, 0.6);                                     //  #                                                             
graph = graph -- (E.x - grad*0.4, E.y - 0.4);                         //  #                                                             
graph = graph -- E;                                                   //  #                                                             
                                                                                                                                        
graph = roundedpath(graph, radius, S);                                // round edges of 'graph' using roundedpath() in roundedpath.asy  
ActPen =  rgb(0.6,0,0.2) + linewidth(lw);                             // define pen for drawing in 3rd diagram                          
draw(T[3],                   graph, ActPen);                          // draw 'graph' with 'ActPen' into 'T[3]' (1st hysteresis branch) 
draw(T[3], rotate(180,(0,0))*graph, ActPen);                          // draw rotated 'graph' (2nd hysteresis branch)                   


//////////////////////////////////////// 4th diagram
T[4] = CreateKOOS(S, "$T_4$");                                        // initialise T[4] as empty diagram with label $T_4$              
graph = A;                                                            //  # pointwise definition of current path 'graph'                
graph = graph -- (A.x + grad*0.4, A.y + 0.4);                         //  #                                                             
graph = graph -- ( - grad*0.6 , - 0.6);                               //  #                                                             
graph = graph -- (0,0);                                               //  #                                                             
graph = graph -- (grad*0.9, 0.9);                                     //  #                                                             
graph = graph -- (E.x - grad*0.1, E.y - 0.1);                         //  #                                                             
graph = graph -- E;                                                   //  #                                                             
                                                                                                                                        
graph = roundedpath(graph, radius, S);                                // round edges of 'graph' using roundedpath() in roundedpath.asy  
ActPen =  rgb(0.6,0,0) + linewidth(lw);                               // define pen for drawing in 4th diagram                          
draw(T[4],                   graph, ActPen);                          // draw 'graph' with 'ActPen' into 'T[4]' (1st hysteresis branch) 
draw(T[4], rotate(180,(0,0))*graph, ActPen);                          // draw rotated 'graph' (3nd hysteresis branch)                   


// add some labels and black dots to the first two pictures
pair SWW = (-0.8, -0.6);
label(T[1], "$\sigma_f$", (0, 0.6S), NE);                             // sigma_f
draw(T[1], (0, 0.6S), linewidth(3) + black);
label(T[2], "$\sigma_f$", (0, 0.3S), NE);                             // sigma_f
draw(T[2], (0, 0.3S), linewidth(3) + black);
label(T[1], "$\varepsilon_p$", (0.7S, 0), SWW);                       // epsilon_p
draw(T[1], (0.75S, 0), linewidth(3) + black);
label(T[2], "$\varepsilon_p$", (0.7S, 0), SWW);                       // epsilon_p
draw(T[2], (0.75S, 0), linewidth(3) + black);


// add all pictures T[1...4] to the current one
add(T[1],(0,0));
add(T[2],(1*inc*S,0));
add(T[3],(2*inc*S,0));
add(T[4],(3*inc*S,0));


// draw line of constant \sigma and all intersection points with the graphs in T[1...4]
ActPen = linewidth(1) + dashed + gray(0.5);                           // pen definition
draw((-S, 0.45*S)--((3*inc+1)*S, 0.45*S), ActPen);                    // draw backgoundline
label("$\sigma_s$", (-S, 0.45S), W);                            // label 'sigma_s'

path mark = scale(2)*unitcircle;                                  // define mark-symbol to be used for intersections
ActPen = linewidth(1) + gray(0.5);                                    // define pen for intersection mark
draw(shift(( 1 - grad*0.55 + 0*inc)*S, 0.45*S)*mark, ActPen);         //  # draw all intersections
draw(shift((-1 + grad*1.45 + 0*inc)*S, 0.45*S)*mark, ActPen);         //  #
draw(shift(( 1 - grad*0.55 + 1*inc)*S, 0.45*S)*mark, ActPen);         //  #
draw(shift(( 1 - grad*0.55 + 2*inc)*S, 0.45*S)*mark, ActPen);         //  # 
draw(shift((     grad*0.45 + 2*inc)*S, 0.45*S)*mark, ActPen);         //  # 
draw(shift((     grad*0.45 + 3*inc)*S, 0.45*S)*mark, ActPen);         //  #

Mots-clefs : ,


Official Asymptote example – threeviews

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 1 h 57 min

Figure 0211
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

picture pic;
size(pic,200);
currentlight.viewport=false;
settings.render=4;

draw(pic,scale3(0.5)*unitsphere,green);
draw(pic,Label("$x$",1),O--X);
draw(pic,Label("$y$",1),O--Y);
draw(pic,Label("$z$",1),O--Z);

addViews(pic);

Mots-clefs : , ,


Official Asymptote example – tile

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 2 h 57 min

Figure 0212
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,90);
import patterns;

add("tile",tile());
add("filledtilewithmargin",tile(6mm,4mm,red,Fill),(1mm,1mm),(1mm,1mm));
add("checker",checker());
add("brick",brick());

real s=2.5;
filldraw(unitcircle,pattern("tile"));
filldraw(shift(s,0)*unitcircle,pattern("filledtilewithmargin"));
filldraw(shift(2s,0)*unitcircle,pattern("checker"));
filldraw(shift(3s,0)*unitcircle,pattern("brick"));

Mots-clefs : , , ,


Official Asymptote example – torus

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 3 h 57 min

Figure 0213
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);
import graph3;

currentprojection=perspective(5,4,4);

//import solids;
//revolution torus=revolution(shift(3X)*Circle(O,1,Y,32),Z,90,345);
//draw(surface(torus),green);

real R=3;
real a=1;

triple f(pair t) {
  return ((R+a*cos(t.y))*cos(t.x),(R+a*cos(t.y))*sin(t.x),a*sin(t.y));
}

draw(surface(f,(radians(90),0),(radians(345),2pi),8,8,Spline),green);

Mots-clefs : ,


Official Asymptote example – transparency

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 4 h 57 min

Figure 0214
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,150);

settings.outformat="pdf";

begingroup();
fill(shift(1.5dir(120))*unitcircle,green+opacity(0.75));
fill(shift(1.5dir(60))*unitcircle,red+opacity(0.75));
fill(unitcircle,blue+opacity(0.75));
endgroup();

Mots-clefs : , , ,


Official Asymptote example – treetest

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 5 h 57 min

Figure 0215
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import drawtree;

treeLevelStep = 2cm;

TreeNode root = makeNode( "Root" );
TreeNode child1 = makeNode( root, "Child\_1" );
TreeNode child2 = makeNode( root, "Child\_2" );

TreeNode gchild1 = makeNode( child1, "Grandchild\_1" );
TreeNode gchild2 = makeNode( child1, "Grandchild\_2" );

TreeNode gchild3 = makeNode( child1, "Grandchild\_3" );
TreeNode gchild4 = makeNode( child1, "Grandchild\_4" );


TreeNode gchild11 = makeNode( child2, "Grandchild\_1" );
TreeNode gchild22 = makeNode( child2, "Grandchild\_2" );

TreeNode ggchild1 = makeNode( gchild1, "Great Grandchild\_1" );

draw( root, (0,0) );


Mots-clefs : ,


Official Asymptote example – trefoilknot

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 6 h 57 min

Figure 0216
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import tube;
import graph3;
import palette;
currentlight=White;

size(0,8cm);
currentprojection=perspective(1,1,1,up=-Y);

int e=1;
real x(real t) {return cos(t)+2*cos(2t);}
real y(real t) {return sin(t)-2*sin(2t);}
real z(real t) {return 2*e*sin(3t);}

path3 p=scale3(2)*graph(x,y,z,0,2pi,50,operator ..)&cycle;

pen[] pens=Gradient(6,red,blue,purple);
pens.push(yellow);
for (int i=pens.length-2; i >= 0 ; --i)
  pens.push(pens[i]);

path sec=scale(0.25)*texpath("$\pi$")[0];
coloredpath colorsec=coloredpath(sec, pens,colortype=coloredNodes);
draw(tube(p,colorsec));

Mots-clefs : , , , ,


Official Asymptote example – triangle

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

Figure 0217
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,100);
import geometry;

triangle t=triangle(b=3,alpha=90,c=4);
  
dot((0,0));

draw(t);
draw(rotate(90)*t,red);
draw(shift((-4,0))*t,blue);
draw(reflect((0,0),(1,0))*t,green);
draw(slant(2)*t,magenta);

Mots-clefs : , , ,


Official Asymptote example – triangulate

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 8 h 57 min

Figure 0218
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(200);
int np=100;
pair[] points;

real r() {return 1.2*(rand()/randMax*2-1);}

for(int i=0; i < np; ++i)
  points.push((r(),r()));

int[][] trn=triangulate(points);

for(int i=0; i < trn.length; ++i) {
  draw(points[trn[i][0]]--points[trn[i][1]]);
  draw(points[trn[i][1]]--points[trn[i][2]]);
  draw(points[trn[i][2]]--points[trn[i][0]]);
}

for(int i=0; i < np; ++i)
  dot(points[i],red);

Mots-clefs : ,


Official Asymptote example – triceratops

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 9 h 57 min

Figure 0219
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import obj;

size(15cm);
currentprojection=orthographic(0,2,5,up=Y);

// A compressed version of the required data file may be obtained from:
// http://www.cs.technion.ac.il/~irit/data/Viewpoint/galleon.obj.gz

draw(obj("triceratops.obj",brown));

Mots-clefs : ,


Official Asymptote example – trumpet

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 10 h 57 min

Figure 0220
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
size(200,0);

triple f(pair t) {
  return(10*sin(t.y),cos(t.x)*(cos(t.y)+log(abs(tan(t.y/2)))),
         sin(t.x)*(cos(t.y)+log(abs(tan(t.y/2)))));
}

surface s=surface(f,(0,pi/2),(2pi,pi-0.1),7,15,Spline);
draw(s,olive);

Mots-clefs : , ,


Official Asymptote example – tvgen

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 11 h 57 min

Figure 0221
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
/* tvgen - draw pm5544-like television test cards.
 * Copyright (C) 2007, 2009, Servaas Vandenberghe.
 *
 * The tvgen code below is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with tvgen: see the file COPYING.  If not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 * tvgen-1.1/tvgen.asy
 * This asy script generates pm5544-like television test cards.  The image 
 * parameters were derived from a 1990 recording.  The basic parameters 
 * conform to itu-r bt.470, bt.601, and bt.709.  There is no unique image 
 * since local variants exist and parameters have varied over time.  
 */
//papertype="a4";
import plain;
int verbose=settings.verbose/*+2*/;  /* uncomment for debug info */

/* tv dot coordinates --> PS points */
pair tvps(real col, real row, real xd, real yd, int Nv) { 
  real psx, psy; 
  psx=col*xd; psy=(Nv-row)*yd; 
  return (psx,psy); 
}
path tvrect(int lc, int tr, int rc, int br, real xd, real yd, int Nv) {
  real lx, ty, rx, by; 
  pair[] z; 
  
  lx=lc*xd; ty=(Nv-tr)*yd; 
  rx=rc*xd; by=(Nv-br)*yd; 
  /* bl br tr tl */
  z[0]=(lx, by);
  z[1]=(rx, by); 
  z[2]=(rx, ty); 
  z[3]=(lx, ty); 
  
  return z[0]--z[1]--z[2]--z[3]--cycle; 
}

/********************* image aspect ratio markers ********************/
void rimarkers(real rimage, int Nh, int Nhc, int os, int Nvc, int Nsy, pen pdef, real xd, real yd, int Nv) {
  int[] ridefN={ 4, 16 };
  int[] ridefD={ 3,  9 };
  int i;

  for(i=0; i<2; ++i) {
    real rid=ridefN[i]/ridefD[i];

    if(rimage>rid) {
      int off, offa, offb;

      /* Nhdef=Nh/rimage*rid */
      off=round(Nh/rimage*rid/2);
      offa=off+os;
      offb=off-os;
      // write(offa,offb);

      if(2*offa<Nh) {
        int hy, tr, br;
        path zz;
        
        hy=floor(Nsy/3);
        tr=Nvc-hy;
        br=Nvc+hy;
        
        zz=tvrect(Nhc+offb, tr, Nhc+offa, br, xd,yd,Nv);
        //dot(zz);
        fill(zz, p=pdef);
        zz=tvrect(Nhc-offa, tr, Nhc-offb, br, xd,yd,Nv);
        fill(zz, p=pdef);
      }
    }
  } /* for i */
  return;
}

/************* cross hatch: line pairing, center interlace test *************/
void centerline(int[] coff, int[] coffa, int[] coffb, int Nhc, int divsx,
                int os, int[] rcrowc, int Nvc, int divsy,
                pair ccenter, real[] rcoff, pair[] rcright, pair[] rcleft,
                pen pdef, real xd, real yd, int Nv) {
  pair[] z;
  int col;
  pen pblack=pdef+gray(0.0), pwhite=pdef+gray(1.0);
  
  z[0]=rcright[divsy];

  col=Nhc+coff[0];
  z[1]=tvps(col,rcrowc[divsy], xd,yd,Nv);
  z[2]=tvps(col,rcrowc[divsy-1], xd,yd,Nv);
  col=Nhc-coff[0];
  z[3]=tvps(col,rcrowc[divsy-1], xd,yd,Nv);
  z[4]=tvps(col,rcrowc[divsy], xd,yd,Nv);

  z[5]=rcleft[divsy]; 
  z[6]=rcleft[divsy+1];

  z[7]=tvps(col,rcrowc[divsy+1], xd,yd,Nv);
  z[8]=tvps(col,rcrowc[divsy+2], xd,yd,Nv);
  col=Nhc+coff[0];
  z[9]=tvps(col,rcrowc[divsy+2], xd,yd,Nv);
  z[10]=tvps(col,rcrowc[divsy+1], xd,yd,Nv);

  z[11]=rcright[divsy+1]; 
  fill(z[1]--z[2]--z[3]--z[4] //--z[5]--z[6]
       --arc(ccenter, z[5], z[6])
       --z[7]--z[8]--z[9]--z[10] //--z[11]--z[0]
       --arc(ccenter,z[11], z[0])
       --cycle, p=pblack);

  int i, maxoff, rows, tr, br;
  path zz;

  maxoff=floor(rcoff[divsy]);

  /* center cross: vertical and horizontal centerline */
  rows=min(Nvc-rcrowc[divsy-1], rcrowc[divsy+2]-Nvc);
  tr=Nvc-rows;
  br=Nvc+rows;
  //write("centerline long: rows tr br ", rows, tr, br);
  zz=tvrect(Nhc-os, tr, Nhc+os, br, xd,yd,Nv);
  fill(zz, p=pwhite);
  zz=tvrect(Nhc-maxoff,Nvc-1, Nhc+maxoff,Nvc+1, xd,yd,Nv);
  fill(zz, p=pwhite);

  /* vertical short lines */
  rows=min(Nvc-rcrowc[divsy], rcrowc[divsy+1]-Nvc);
  tr=Nvc-rows;
  br=Nvc+rows;
  if(verbose>1)
    write("centerline: rows tr br ", rows, tr, br);
  for(i=0; i<=divsx; ++i) {
    int off;
    
    off=coff[i];
    if(off<maxoff) {
      int offa, offb;
      path zzv;
      offa=coffa[i];
      offb=coffb[i];

      zzv=tvrect(Nhc+offb, tr, Nhc+offa, br, xd,yd,Nv); 
      fill(zzv, p=pwhite);
      zzv=tvrect(Nhc-offa, tr, Nhc-offb, br, xd,yd,Nv); 
      fill(zzv, p=pwhite);
    }
  }
  return;
}

/************************ topbw **************************************/
void topbw(int[] coff, int Nhc, int os, int urow, int trow, int brow, 
           pair ccenter, pair rclt, pair rclb, pair rcrt, pair rcrb, 
           pen pdef, real xd, real yd, int Nv) {
  pen pblack=pdef+gray(0.0), pwhite=pdef+gray(1.0);
  pair[] ze;
  path zext, zref, zint;
  int off, col, cr;

  off=ceil((coff[2]+coff[3])/2);
  ze[0]=tvps(Nhc+off,trow, xd,yd,Nv);
  ze[1]=rcrt;
  ze[2]=rclt;
  ze[3]=tvps(Nhc-off,trow, xd,yd,Nv);
  ze[4]=tvps(Nhc-off,brow, xd,yd,Nv);
  col=Nhc-coff[2]-os;
  ze[5]=tvps(col,brow, xd,yd,Nv);
  ze[6]=tvps(col,trow, xd,yd,Nv);
  cr=col+3*os;    /* reflection test black pulse */
  zref=tvrect(col,trow, cr,brow, xd,yd,Nv);
  ze[7]=tvps(cr,trow, xd,yd,Nv);
  ze[8]=tvps(cr,brow, xd,yd,Nv);
  ze[9]=tvps(Nhc+off,brow, xd,yd,Nv);
  //dot(ze);

  zext=ze[0] // --ze[1]--ze[2]
    --arc(ccenter, ze[1], ze[2])
    --ze[3]--ze[4]--ze[5]--ze[6]--ze[7]--ze[8]--ze[9]--cycle;

  off=ceil((coff[1]+coff[2])/2);
  zint=tvrect(Nhc-off,urow, Nhc+off,trow, xd,yd,Nv); 

  /* paths are completely resolved; no free endpoint conditions */
  fill(zext^^reverse(zint), p=pwhite);
  fill(zint, p=pblack);
  fill(zref, p=pblack);

  fill(arc(ccenter,rclt,rclb)--ze[4]--ze[3]--cycle, p=pblack);
  fill(arc(ccenter,rcrb,rcrt)--ze[0]--ze[9]--cycle, p=pblack);
  return;
}

/************************ testtone **************************************/
/* x on circle -> return y>=0 
 * in:
 *   x     x-coordinate relative to origin
 *   crad  circle radius in y units, true size=crad*yd
 */
real testcircx(real x, real crad, real xd, real yd) {
  real relx, phi, y;

  relx=x*xd/yd/crad;
  if(relx>1) {
    phi=0;
  } else {
    phi=acos(relx);
  }
  y=crad*sin(phi);         // or (x*xd)^2+(y*yd)^2=(crad*yd)^2

  return y;
}
/* y on circle -> return x>=0 */
real testcircy(real y, real crad, real xd, real yd) {
  real rely, phi, x;

  rely=y/crad;
  if(rely>1) {
    phi=pi/2;
  } else {
    phi=asin(rely);
  }
  x=crad*cos(phi)*yd/xd;         // or (x*xd)^2+(y*yd)^2=(crad*yd)^2

  return x;
}

/* brow>trow && xb>xt */
void testtone(real Tt, int trow, int brow, 
              real ccol, real crow, real crad,
              pen pdef, real xd, real yd, int Nv) {
  int blocks, i;
  real yt, xt, yb, xb, Ttt=Tt/2;
  pair ccenter;

  yt=crow-trow;
  xt=testcircy(yt, crad, xd, yd);
  yb=crow-brow;
  xb=testcircy(yb, crad, xd, yd);
  //write('#xt yt\t',xt,yt); write('#xb yb\t',xb,yb);

  ccenter=tvps(ccol,crow, xd,yd,Nv);

  blocks=floor(2*xb/Tt);

  for(i=-blocks-1; i<=blocks; ++i) {
    real tl, tr;
    path zz;

    tl=max(-xb,min(i*Ttt,xb));      /* limit [-xb..xb] */
    tr=max(-xb,min((i+1)*Ttt,xb));

    if(tl<-xt && tr<=-xt || tr>xt && tl>=xt) {   /* top full circle */
      pair[] z;
      real yl, yr;

      yl=testcircx(tl, crad, xd, yd);
      yr=testcircx(tr, crad, xd, yd);

      z[0]=tvps(ccol+tl,brow, xd,yd,Nv);
      z[1]=tvps(ccol+tr,brow, xd,yd,Nv);
      z[2]=tvps(ccol+tr,crow-yr, xd,yd,Nv);
      z[3]=tvps(ccol+tl,crow-yl, xd,yd,Nv);

      zz=z[0]--z[1]--arc(ccenter,z[2],z[3])--cycle;
    } else if(tl<-xt) {       /* tl in circel, tr not, partial */
      pair[] z;
      real yl;

      yl=testcircx(tl, crad, xd, yd);

      z[0]=tvps(ccol+tl,brow, xd,yd,Nv);
      z[1]=tvps(ccol+tr,brow, xd,yd,Nv);
      z[2]=tvps(ccol+tr,trow, xd,yd,Nv);
      z[3]=tvps(ccol-xt,trow, xd,yd,Nv);
      z[4]=tvps(ccol+tl,crow-yl, xd,yd,Nv);

      zz=z[0]--z[1]--z[2]--arc(ccenter,z[3],z[4])--cycle;
    } else if(tr>xt) { /* tr in circle, tl not, partial */
      pair[] z;
      real yr;

      yr=testcircx(tr, crad, xd, yd);

      z[0]=tvps(ccol+tl,brow, xd,yd,Nv);
      z[1]=tvps(ccol+tr,brow, xd,yd,Nv);
      z[2]=tvps(ccol+tr,crow-yr, xd,yd,Nv);
      z[3]=tvps(ccol+xt,trow, xd,yd,Nv);
      z[4]=tvps(ccol+tl,trow, xd,yd,Nv);
      zz=z[0]--z[1]--arc(ccenter,z[2],z[3])--z[4]--cycle;
    } else { /* full block */
      pair[] z;

      z[0]=tvps(ccol+tr,trow, xd,yd,Nv);
      z[1]=tvps(ccol+tl,trow, xd,yd,Nv);
      z[2]=tvps(ccol+tl,brow, xd,yd,Nv);
      z[3]=tvps(ccol+tr,brow, xd,yd,Nv);
      zz=z[0]--z[1]--z[2]--z[3]--cycle;
    } 

    if(tl<tr) {
      if(i%2 == 0) {
        fill(zz, p=pdef+gray(0.0));
      } else {
        fill(zz, p=pdef+gray(0.75));
      }
    }
  }
  return;
}

/************************ color bars *************************************/
void colorbars(int[] coff, int Nhc, int trow, int crow, int brow, 
               pair ccenter, pair rclt, pair rclb, pair rcrt, pair rcrb, 
               pen pdef, real xd, real yd, int Nv) {
  real cI=0.75;
  real[] cR={ cI,  0,  0,  cI, cI,  0 };
  real[] cG={ cI, cI, cI,   0,  0,  0 };
  real[] cB={  0, cI,  0,  cI,  0, cI };
  int cmax=2, poff, rows, i;

  rows=brow-trow;
  poff=0;
  for(i=0; i<=cmax; ++i) {
    int off;
    int ii=2*i, il=cmax-i, ir=i+cmax+1;
    path zzl, zzr;
  
    off=ceil((coff[1+ii]+coff[2+ii])/2);
    if(i!=0 && i<cmax) {
      zzr=tvrect(Nhc+poff,trow, Nhc+off,brow, xd,yd,Nv); 
      zzl=tvrect(Nhc-off,trow, Nhc-poff,brow, xd,yd,Nv); 
    } else {
      if(i==0) {
        int col, pcol;
        pair[] zl, zr;

        col=Nhc+off;
        pcol=Nhc+poff;
        zr[0]=tvps(col,trow, xd,yd,Nv);
        zr[1]=tvps(pcol,trow, xd,yd,Nv);
        zr[2]=tvps(pcol,crow, xd,yd,Nv);
        zr[3]=tvps(Nhc+coff[0],crow, xd,yd,Nv);
        zr[4]=tvps(Nhc+coff[0],brow, xd,yd,Nv);
        zr[5]=tvps(col,brow, xd,yd,Nv);
        zzr=zr[0]--zr[1]--zr[2]--zr[3]--zr[4]--zr[5]--cycle;

        col=Nhc-off;
        pcol=Nhc-poff;
        zl[0]=tvps(pcol,trow, xd,yd,Nv);
        zl[1]=tvps(col,trow, xd,yd,Nv);
        zl[2]=tvps(col,brow, xd,yd,Nv);
        zl[3]=tvps(Nhc-coff[0],brow, xd,yd,Nv);
        zl[4]=tvps(Nhc-coff[0],crow, xd,yd,Nv);
        zl[5]=tvps(pcol,crow, xd,yd,Nv);
        zzl=zl[0]--zl[1]--zl[2]--zl[3]--zl[4]--zl[5]--cycle;
      } else {
        int pcol;
        pair[] zl, zr;

        pcol=Nhc+poff;
        zr[0]=tvps(pcol,brow, xd,yd,Nv);
        zr[1]=rcrb;
        zr[2]=rcrt;
        zr[3]=tvps(pcol,trow, xd,yd,Nv);
        zzr=zr[0]--arc(ccenter,zr[1],zr[2])--zr[3]--cycle;

        pcol=Nhc-poff;
        zl[0]=tvps(pcol,trow, xd,yd,Nv);
        zl[1]=rclt;
        zl[2]=rclb;
        zl[3]=tvps(pcol,brow, xd,yd,Nv);
        zzl=zl[0]--arc(ccenter,zl[1],zl[2])--zl[3]--cycle;
      }
    }
    fill(zzr, p=pdef+rgb(cR[ir], cG[ir], cB[ir]));
    fill(zzl, p=pdef+rgb(cR[il], cG[il], cB[il]));

    poff=off;
  }
  return;
}

/************************ test frequencies ****************************/
/* in
 *   theta  rad
 *   freq   1/hdot
 *   step   hdot
 * out
 *   new phase theta
 */
real addphase(real theta, real freq, real step) {
  real cycles, thetaret;
  int coverflow;

  cycles=freq*step;
  coverflow=floor(abs(cycles));  
  if(coverflow>1) {
    thetaret=0;
  } else {
    real dpi=2*pi;

    cycles-=coverflow*sgn(cycles);
    thetaret=theta+cycles*dpi;       /* cycles=(-1 .. 1) */

    if(thetaret>pi) { 
      thetaret-=dpi; 
    } else if(thetaret<-pi) { 
      thetaret-=dpi; 
    }
  }

  //write("addphase: ", step, theta, thetaret);
  return thetaret;
}

void testfreqs(real[] ftones, int[] coff, int Nhc, int trow,int crow,int brow, 
               pair ccenter, pair rclt, pair rclb, pair rcrt, pair rcrb, 
               pen pdef, real xd, real yd, int Nv) {
  int[] divc;
  real[] divfl, divfr;
  int i, divs, coffmax, off, divnext;
  real fl, fr, thr, thl;

  /* Segment info for PAL continental test card
   * segment i extends from [divc[i] .. divc[i+1]) with frequency divf[i]
   */
  divs=2;     // the number of segments on the right, total=2*divs+1
  divc[0]=0;
  for(i=0; i<=divs; ++i) {
    int ii=i*2, il=divs-i, ir=divs+i;

    divc[i+1]=ceil((coff[ii]+coff[ii+1])/2);  /* xdot distance to center */

    divfl[i]=ftones[divs-i];
    divfr[i]=ftones[divs+i];
  }
  coffmax=divc[divs+1];

  int trowlim=coff[0];
  int tr;

  tr=crow;

  divnext=0;
  fl=0;
  fr=0;
  thl=0;
  thr=0;
  // draw a vertical line at off..off+1
  for(off=0; off<coffmax; ++off) {
    real ampl, ampr;
    int col;
    path zz;

    if(off==trowlim) {
      tr=trow;
    }

    if(off == divc[divnext]) {  
      /* switch frequency: cycles=0.5*fcur+0.5*fnext */
      thl=addphase(thl, fl, -0.5);
      thr=addphase(thr, fr,  0.5);
      fl=divfl[divnext];
      fr=divfr[divnext];
      thl=addphase(thl, fl, -0.5);
      thr=addphase(thr, fr,  0.5);

      ++divnext;
      // thl=pi; thr=pi;
      //write(off, fl, fr);
    } else {
      thl=addphase(thl, fl, -1);
      thr=addphase(thr, fr,  1);
      // thl=0; thr=0;
    }

    ampl=(1+sin(thl))/2;
    ampr=(1+sin(thr))/2;
    //write(off, thr, ampr);

    col=Nhc-off-1;
    zz=tvrect(col,tr, col+1,brow, xd,yd,Nv); 
    fill(zz, p=pdef+gray(ampl));
    col=Nhc+off;
    zz=tvrect(col,tr, col+1,brow, xd,yd,Nv); 
    fill(zz, p=pdef+gray(ampr));
  }

  pair[] z;
  z[0]=tvps(Nhc-coffmax,trow, xd,yd,Nv);
  z[1]=tvps(Nhc-coffmax,brow, xd,yd,Nv);
  fill(z[0]--arc(ccenter,rclt,rclb)--z[1]--cycle, p=pdef+gray(0.0));
  z[0]=tvps(Nhc+coffmax,brow, xd,yd,Nv);
  z[1]=tvps(Nhc+coffmax,trow, xd,yd,Nv);
  fill(z[0]--arc(ccenter,rcrb,rcrt)--z[1]--cycle, p=pdef+gray(0.0));
  return;
}

/************************ gray bars **************************************/
void graybars(int[] coff, int Nhc, int trow, int brow, 
              pair ccenter, pair rclt, pair rclb, pair rcrt, pair rcrb, 
              pen pdef, real xd, real yd, int Nv) {
  int[] gs={0, 51, 102, 153, 204, 255};
  int cmax=2, poff, rows, i;

  rows=brow-trow;
  poff=0;
  for(i=0; i<=cmax; ++i) {
    int off;
    int ii=2*i, il=cmax-i, ir=i+cmax+1;
    path zzl, zzr;
  
    off=ceil((coff[1+ii]+coff[2+ii])/2);
    if(i<cmax) {
      zzl=tvrect(Nhc-off,trow, Nhc-poff,brow, xd,yd,Nv); 
      zzr=tvrect(Nhc+poff,trow, Nhc+off,brow, xd,yd,Nv); 
    } else {
      int pcol;
      pair zlt, zlb, zrt, zrb;

      pcol=Nhc-poff;
      zlt=tvps(pcol,trow, xd,yd,Nv);
      zlb=tvps(pcol,brow, xd,yd,Nv);
      zzl=zlt--arc(ccenter,rclt,rclb)--zlb--cycle;

      pcol=Nhc+poff;
      zrb=tvps(pcol,brow, xd,yd,Nv);
      zrt=tvps(pcol,trow, xd,yd,Nv);
      zzr=zrb--arc(ccenter,rcrb,rcrt)--zrt--cycle;
    }
    fill(zzl, p=pdef+gray(gs[il]/255));
    fill(zzr, p=pdef+gray(gs[ir]/255));

    poff=off;
  }
  return;
}

/************************ bottom bw **************************************/
void bottombw(int off, int Nhc, int trow, int brow, 
              pair ccenter, pair rclt, pair rclb, pair rcrt, pair rcrb, 
              pen pdef, real xd, real yd, int Nv) {
  int rows;
  pair zt, zb;
  path zz;

  rows=brow-trow;
  zz=tvrect(Nhc-off,trow, Nhc+off,brow, xd,yd,Nv); 
  fill(zz, p=pdef+gray(0.0));

  zt=tvps(Nhc-off,trow, xd,yd,Nv);
  zb=tvps(Nhc-off,brow, xd,yd,Nv);
  fill(zt--arc(ccenter,rclt,rclb)--zb--cycle, p=pdef+gray(1.0));

  zb=tvps(Nhc+off,brow, xd,yd,Nv);
  zt=tvps(Nhc+off,trow, xd,yd,Nv);
  fill(zb--arc(ccenter,rcrb,rcrt)--zt--cycle, p=pdef+gray(1.0));
  return;
}

/************************ bottom circle **************************************/
void bottomcirc(int off, int Nhc, int trow, real cx, real cy, real crad, 
                pair ccenter, pair rclt, pair rcrt,
                pen pdef, real xd, real yd, int Nv) {
  real cI=0.75;
  real xl, yl, xr, yr, phil, phir;
  pair ccleft, ccright;
  pair[] z;

  xl=Nhc-off-cx;
  phil=acos(xl*xd/yd/crad);
  yl=crad*sin(phil);         // or (x*xd)^2+(y*yd)^2=(crad*yd)^2
  ccleft=tvps(cx+xl,cy+yl, xd,yd,Nv);
  //write(xl,yl);

  xr=Nhc+off-cx;
  phir=acos(xr*xd/yd/crad);
  yr=crad*sin(phir); 
  ccright=tvps(cx+xr,cy+yr, xd,yd,Nv);

  //dot(ccright); dot(ccleft);
  // red center
  z[0]=tvps(Nhc-off,trow, xd,yd,Nv);
  z[1]=ccleft;
  z[2]=ccright;
  z[3]=tvps(Nhc+off,trow, xd,yd,Nv);
  fill(z[0]--arc(ccenter,z[1],z[2])--z[3]--cycle, p=pdef+rgb(cI,0,0));

  // yellow
  z[0]=tvps(Nhc-off,trow, xd,yd,Nv);
  z[1]=rclt;
  z[2]=ccleft;
  fill(z[0]--arc(ccenter,z[1],z[2])--cycle, p=pdef+rgb(cI,cI,0));
  z[0]=tvps(Nhc+off,trow, xd,yd,Nv);
  z[1]=ccright;
  z[2]=rcrt;
  fill(z[0]--arc(ccenter,z[1],z[2])--cycle, p=pdef+rgb(cI,cI,0));

  return;
}

/****************************** PAL ears ***********************************
 * left  y      R       G       B 
 *      0.55    98      162     140
 *      0.5     103     128     191
 *      0.5     152     128     64
 *      0.45    157     93      115
 * right
 *      0.6     153     168     76
 *      0.4     102     87      179
 *
 * in: dright=  -1 left ear, +1 right ear
 */
void palears(int[] coff, int[] coffa, int[] coffb, int Nhc, 
             int[] rcrowt, int[] rcrowb, int Nvc, int divsy, int dright,
             pen pdef, real xd, real yd, int Nv) {
  /* the amplitude of (u,v) as seen on a vectorscope, 
   * max 0.296 Vn for 100% saturation in W and V ears.
   * cvbs:   0.7*( y +/- |u+jv| ) = -0.24 .. 0.93 V 
   * maxima: ebu 75/0 bars 0.70, bbc 100/25 0.88, 100/0 bars 0.93
   * burst:  0.150 Vcvbs, 21.4 IRE or 0.214 V normalized.
   * luma:   modulated for monochrome compatibility, 1990 version.
   * choice: set amplitude of subcarrier equal to amplitude of colorburst.
   */
  real cI=0.214;

  /* (u,v) for zero G-y, phase of -34.5 degrees */
  real wr=0.299, wb=0.114, wg=1-wr-wb;     /* wg=0.587, y=wr*R+wg*G+wb*B */
  real wu=0.493, wv=0.877;                 /* u=wu*(B-y) v=wv*(R-y) */
  real colu=wu*wg/wb, colv=-wv*wg/wr;      /* for w=(G-y)/0.696 == 0 */

  /* ears:     U==0   W==0   W==0  U==0 */
  real[] cyl={ 0.55,   0.5,   0.5, 0.45 };
  real[] cul={   0,   colu, -colu,    0 };
  real[] cvl={  -1,   colv, -colv,    1 };

  /* ears:     V==0   W==0  W==0   V==0 */
  real[] cyr={ 0.60,   0.5,  0.5,  0.40 };
  real[] cur={  -1,   colu, -colu,    1 };
  real[] cvr={   0,   colv, -colv,    0 };

  real[] cy, cu, cv;
  pair[] z;
  path[] zz;
  int lcol, ccol, cicol, rcol, i;

  if(dright>0) {
    cy=cyr; cu=cur; cv=cvr;
  } else {
    cy=cyl; cu=cul; cv=cvl;
  }

  lcol=Nhc+dright*coffa[5];
  ccol=Nhc+dright*coff[6];
  cicol=Nhc+dright*coffa[6];
  rcol=Nhc+dright*coffb[7];

  int urow, trow, crow, brow, arow;
  urow=rcrowb[divsy-5];
  trow=rcrowt[divsy-3];
  crow=Nvc;
  brow=rcrowb[divsy+4];
  arow=rcrowt[divsy+6];

  z[0]=tvps(ccol,urow, xd,yd,Nv);
  z[1]=tvps(ccol,trow, xd,yd,Nv);
  z[2]=tvps(cicol,trow, xd,yd,Nv);
  z[3]=tvps(cicol,crow, xd,yd,Nv);
  z[4]=tvps(rcol,crow, xd,yd,Nv);
  z[5]=tvps(rcol,urow, xd,yd,Nv);
  zz[0]=z[0]--z[1]--z[2]--z[3]--z[4]--z[5]--cycle;

  zz[1]=tvrect(lcol,urow, ccol,trow, xd,yd,Nv);
  zz[2]=tvrect(lcol,brow, ccol,arow, xd,yd,Nv);

  z[0]=tvps(ccol,arow, xd,yd,Nv);
  z[1]=tvps(ccol,brow, xd,yd,Nv);
  z[2]=tvps(cicol,brow, xd,yd,Nv);
  z[3]=tvps(cicol,crow, xd,yd,Nv);
  z[4]=tvps(rcol,crow, xd,yd,Nv);
  z[5]=tvps(rcol,arow, xd,yd,Nv);
  zz[3]=z[0]--z[1]--z[2]--z[3]--z[4]--z[5]--cycle;

  for(i=0; i<4; ++i) {
    real y, u, v, A, ph, By, Ry, Gy, R, G, B;

    y=cy[i];
    u=cu[i];
    v=cv[i];

    A=hypot(u,v);
    ph= (u!=0 || v!=0) ? atan2(v,u) : 0.0;
    if(v>=0) {
      if(ph<0) ph=ph+pi;
    } else {
      if(ph>0) ph=ph-pi;
    }
    if(A>0) {
      u=u/A*cI;
      v=v/A*cI;
    }

    By=u/wu;
    Ry=v/wv;
    Gy=(-wr*Ry-wb*By)/wg;
    //write(y,Gy,A,ph*180/pi);

    R=Ry+y;
    G=Gy+y;
    B=By+y;
    if(verbose > 1)
      write(y,round(R*255),round(G*255),round(B*255));

    fill(zz[i], p=pdef+rgb(R,G,B));
  }
  return;
}

/****************************** NTSC bars ***********************************
 * amplitude equals color burst smpte (pm: -V +U)
 *         y   campl  sat       R    G    B 
 * left   0.5  0.21   70%  -I?
 * right  0.5  0.17   60%  +Q?
 */
void ntscbars(int[] coff, int[] coffa, int[] coffb, int Nhc, 
              int[] rcrowt, int[] rcrowb, int Nvc, int divsy, int dright,
              pen pdef, real xd, real yd, int Nv) {
  /* The amplitude of (i,q) as seen on a vectorscope, 
   * max 0.292 Vn for 100% saturation in I==0 ears.
   * burst:    0.143 Vcvbs, 20 IRE or 0.200 V normalized.
   * pedestal: (yp,up,vp)=(p,0,0)+(1-p)*(y,u,v), p=0.075.
   * choice:   equal amplitude for colorburst and subcarrier.
   */
  real campl=0.200/0.925;

  /* wg=0.587, y=wr*R+wg*G+wb*B */
  real wr=0.299, wb=0.114, wg=1-wr-wb;
  /* iT : iq -> RyBy : rotation+scaling */
  real iT11=0.95, iT12=0.62, iT21=-1.11, iT22=1.71;

  /* bars        -2    -1    0     1       2 */
  real[] cyl={ 0.50, 0.50,   0, 0.50,   0.50 };
  real[] cil={    0,    0,   0,   -1,      1 };
  real[] cql={   -1,    1,   0,    0,      0 };
  int[]  offil={  6,    7,   5,    7,      6 };

  real cy, ci, cq;
  int dri, dris, offi, lcol, rcol, i;

  if(dright>=0) {
    dris=1;
  } else {
    dris=-1;
  }
  if(dright<-2 || dright>2) {
    dri=2;
  } else {
    dri=2+dright;
  }

  cy=cyl[dri]; ci=cil[dri]; cq=cql[dri];
  offi=offil[dri];
  lcol=Nhc+dris*coffa[offi];
  rcol=Nhc+dris*coffb[offi+1];

  real A, By, Ry, Gy, R, G, B;

  A=hypot(ci,cq);
  if(A>0) {
    ci=ci/A*campl;
    cq=cq/A*campl;
  }
  Ry=iT11*ci+iT12*cq;
  By=iT21*ci+iT22*cq;
  Gy=(-wr*Ry-wb*By)/wg;
  //write(cy,Ry,Gy,By);

  R=Ry+cy;
  G=Gy+cy;
  B=By+cy;
  if(verbose > 1)
    write(cy,ci,cq,round(R*255),round(G*255),round(B*255));

  for(i=-divsy; i<=divsy; ++i) {
    path zz;
    int brow, trow;
    
    if(i>-divsy) {
      trow=rcrowb[divsy+i];
    } else {
      trow=floor((rcrowb[divsy+i]+rcrowt[divsy+i+1])/2);
    } 

    if(divsy>i) {
      brow=rcrowt[divsy+i+1];
    } else {
      brow=floor((rcrowb[divsy+i]+rcrowt[divsy+i+1])/2);
    }

    zz=tvrect(lcol,brow, rcol,trow, xd,yd,Nv);
    fill(zz, p=pdef+rgb(R,G,B));
  }
  
  return;
}


/****************************** main ***********************************/
/* Conversion to bitmap:
 *   EPSPNG='gs -dQUIET -dNOPAUSE -dBATCH -sDEVICE=png16m'
 *   asy -u bsys=2 -u colortv=1 -u os=1 -a Z tvgen
 *   $EPSPNG -r132x144 -g720x576 -sOutputFile=tvgen.png tvgen.eps
 *
 * asy -u bsys=2 -u colortv=1 -u os=1 tvgen
 */
int bsys=2, colortv=1, os=1;

/* bsys: broadcast system
 * bsys  im aspect  Nh
 *    0    4/3       704  guaranteed analog broadcast itu-r bt.470
 *    1    4/3       720  new broadcast, most TV station logos and animations
 *    2    15/11     720  total aperture analog 4/3, 1.37 film DVDs
 *    3    20/11     720  total aperture analog 16/9, 1.85 film DVDs 
 *    4    4/3       768  bsys=0, square dot analog broadcast 
 *    5    4/3       768  bsys=1, square dot cable TV info channel
 *    6    131/96    786  bsys=2, total square dot broadcast camera 
 *    7    16/9      720  new broadcast 16/9, SD from HD-1440 or itu-r bt.709
 *    8    4/3       704  525 analog broadcast itu-r bt.470 711*485
 *    9    4/3       720  525 new broadcast
 *   10    15/11     720  525 total aperture analog broadcast
 *   11    16/9     1920  1250, 1080 square dot at 12.5 frames/second
 *   12    4/3      1600  1250, 1200 square dot at 12.5 frames/second
 * 
 * colortv:
 *   set 0 for monochrome crosshatch, 1 for pal ears, 2 for ntsc bars 
 *
 * os: horizontal oversampling, typical values for 13.5MHz:
 *    2   4/3 704*576, 15/11 720*576
 *    4   4/3 720*480
 *    5   4/3 704*480, 15/11 720*480, 4/3 768*576 14.4MHz
 *    8   4/3 720*576, 20/11 720*576
 *   12   704->768 rerastering
 *   16   720->768 rerastering
 */
access settings;
usersetting();

if(bsys<0 || bsys>12 || colortv<0 || colortv>3 || os<=0 || os>16) {
  write('Error: bad user input: bsys, colortv, os=\t', bsys, colortv, os);
  abort('Bad option  -u bsys=N  ?');
}

int[] bNdot=
  {   12,  16,  12,  16,     1,   1,    1,  64,   10,   8,  10,    1,    1 };
int[] bDdot=
  {   11,  15,  11,  11,     1,   1,    1,  45,   11,   9,  11,    1,    1 };
int[] bNh=
  {  704, 720, 720, 720,   768, 768,  786, 720,  704, 720, 720, 1920, 1600 };
int[] bNv=
  {  576, 576, 576, 576,   576, 576,  576, 576,  480, 480, 480, 1080, 1200 };
real[] bfs=
  { 13.5,13.5,13.5,13.5, 14.75,14.4,14.75,13.5, 13.5,13.5,13.5,   36,   30 };
int[] bNsy=
  {   42,  42,  42,  42,    42,  42,   42,  42,   34,  34,  34,   78,   90 };
int[] bNsh=
  {    0,   0,   0,   0,     0,   0,    0,   0,    0,   0,   0,    0,    0 };

/* active lines for a 625 line frame
 *   The number of active video lines decreased around 1997.  
 *     old:  3 run in + 575 visible + 3 run out = 581 lines
 *     new:  6 teletext and WSS + 575 visible 
 *   Hence the image center shifted down by 3 lines.  Thus
 *     old TV + new testcard = bottom is cut off,
 *     new TV + old testcard = top is cut off.
 *
 *   To generate the old testcard either use Nv=582 Nsh=0 or Nv=576 Nsh=3.
 *
 * aspect ratio
 *   rimage=xsize/ysize  rimage=rdot*Nh/Nv
 *   Nh=704 dots
 *   Nv=576 lines
 *   rd=ri*Nv/Nh=4/3*9/11=12/11
 *
 *   Nv: 480=2^5*3*5 576=2^6*3^2  
 *   Nh: 704=2^6*11 720=2^4*3^2*5
 *
 * horizontal line distance for pre 1997 test pattern
 *   top  8 lines, 13 squares of Ny=43 lines, bottom  9 lines
 *   top 12 lines, 13 squares of Ny=42 lines, bottom 18 lines
 *   pairs are from odd even field
 *   Interlace test: Ny must be odd for a cross-hatch without centerline.
 *
 * squares: ly=Nsy, lx=rd*Nsx, lx=ly ==> Nsx=Nsy/rd={ 39.4, 38.5 }
 *   x line width 230 ns -> 3 dots
 *   bottom 2.9us red -> 39.15 dots
 *
 * resolution DPI from image aspect ratio 
 *   Rv=Nv/ly,   ly=4in
 *   ri=Ni/Di,   Ni={4,15,16} Di={3,11,9}
 *   lx=ri*ly
 *
 *   Rh=Nh/lx=Di*(Nh/(Ni*ly))
 *   ==> ri=4/Di  => Nh=k*16
 *       ri=15/Di => Nh=k*60
 *       ri=16/Di => Nh=k*64
 *
 * resolution DPI from dot aspect ratio, general algorithm, 
 *
 *     rd=Nd/Dd=ldx/ldy
 *
 *   assume 1 dot = Nd x Dd square subdots at a resolution of k, in dpi, then
 *
 *     ldx=Nd/k, ldy=Dd/k  ==>  Rh=k/Nd, Rv=k/Dd
 *
 *   choosing k=m*Nd*Dd for integer Rh and Rv gives
 *
 *     ldx=1/(m*Dd), ldy=1/(m*Nd), Rh=m*Dd, Rv=m*Nd
 *
 *   and 
 *
 *     lx=Nh*ldx=Nh/(m*Dd), ly=Nv*ldy=Nv/(m*Nd)
 *
 *   so choose m for the intended height Ly, in inch, as
 *
 *     m=round(Nv/(Ly*Nd))
 *
 *   which limits Ly<=Nv/Nd since Rv>=Nd.
 */
//cm=72/2.540005;
real Ly, ly, lx, ysize, xsize, rimage, xd, yd, pwidth;
int Nd, Dd, m, Nh, Nv, Nshift, Na, Nsy;
real fs, Ttone;

Nd=bNdot[bsys];
Dd=bDdot[bsys]*os;
Nh=bNh[bsys]*os;
Nv=bNv[bsys];

Ly=4;                    // 4 inch vertical size
m=floor(0.5+Nv/(Ly*Nd));
if(m<1) m=1;
ly=Nv/(m*Nd);
lx=Nh/(m*Dd);

ysize=ly*1inch;
xsize=lx*1inch;
rimage=xsize/ysize;
if(verbose > 1)
  write('#Nd Dd m ri:\t', Nd, Dd, m, rimage);
//size(xsize,ysize,Aspect);  // should not have any effect

Nsy=bNsy[bsys];       // grating size in lines 42,43, 34,35
Nshift=bNsh[bsys];    // shift image up: pre 1997 =3, 2007 =0 
fs=1e6*bfs[bsys]*os; 
Na=0;          // add 1,0,-1 to height of hor center squares for even Na+Nsy

Ttone=fs/250e3;       // period of ft=250 kHz, fs/ft=54
real[] ftones={0.8e6/fs, 1.8e6/fs, 2.8e6/fs, 3.8e6/fs, 4.8e6/fs};

xd=xsize/Nh;
yd=ysize/Nv;
pwidth=min(abs(xd),abs(yd));

pen pdefault=squarecap+linewidth(pwidth);
pen pblack=pdefault+gray(0.0);
pen pwhite=pdefault+gray(1.0);

/**** calculate grating repeats and size in tv dots ****/
// horizontal lines
int divsy, rdisty, Nvc, Nt, Nb;

Nvc=floor(Nv/2)-Nshift;
divsy=floor(((Nv-Na-2)/Nsy-1)/2);   // (Nv-Na-2)/2-Nsy/2 dots for Nsy lengths
rdisty=Na+Nsy*(1+2*divsy);
Nt=Nvc-ceil(rdisty/2);
Nb=Nv-Nt-rdisty;
if(verbose > 1)
  write('#divsy t b: \t',divsy,Nt,Nb);

/* Nsyc: center square height 
 *   line pairing test: verify distance of center to top and bot 
 *   distance is odd ==> top=even/odd, cent=odd/even, bot=even/odd
 *
 * Nsyc odd: not possible
 *
 * Nsyc even:
 *   Nsyc/2 odd  --> OK
 *   Nsyc/2 even --> stagger the raster one line upwards
 *
 * rcrowt   top dist of hor line
 * rcrowc   true center for color info, distance to top of image.
 * rcrowb   bot dist of hor line
 *
 * Nt=Nvc-(offu+divsy*Nsy);
 * Nb=Nv-( Nvc-(offd-divsy*Nsy) );
 * ==> Nt+Nb=Nv-Nsyc-2*divsy*Nsy
 */
int Nsyc, offu, offd, Nyst=0, i;
int[] rcrowt, rcrowc, rcrowb;

Nsyc=Nsy+Na;
offu=floor(Nsyc/2);
offd=offu-Nsyc;
if(Nsyc%2 != 0) {
  Nyst=1;
} else if(Nsyc%4 == 0) {
  Nyst=1; /* stagger */
}
for(i=0; i<=divsy; ++i) {  
  int iu, id, ou, od, ru, rd;

  iu=divsy-i;
  id=divsy+i+1;

  ou=offu+Nsy*i;
  od=offd-Nsy*i;
  if(verbose > 1)
    write(ou,od);
  rcrowc[iu]=Nvc-ou;
  rcrowc[id]=Nvc-od;
  
  ru=Nvc-(ou+Nyst);
  rd=Nvc-(od+Nyst);

  rcrowt[iu]=ru-1;
  rcrowb[iu]=ru+1;

  rcrowt[id]=rd-1;
  rcrowb[id]=rd+1;
}
Nt=floor((rcrowt[0]+rcrowb[0])/2);
Nb=Nv-Nt-Nsyc-2*Nsy*divsy;
if(verbose > 1)
  write('#st t b: \t',Nyst,Nt,Nb);

/* vertical lines
 * (Nh-2*os)/2-Nsx/2 dots available for divisions of Nsx dots.
 * At least 5 dots margin left and right ==> use -10*os
 */
real lsq, Nsx;
int divsx, Nhc, Nl;

lsq=Nsy*yd;
Nsx=lsq/xd;
divsx=floor(((Nh-10*os)/Nsx-1)/2);  
Nhc=round(Nh/2);
Nl=Nhc-round((1+2*divsx)*Nsx/2);
if(verbose > 1)
  write('#Nsx divsx Nl:\t',Nsx,divsx,Nl);

/**** draw gray background ****/
{ 
  path zz;
  //zz=tvrect(0,0, Nh,Nv, xd,yd,Nv);
  /* keep white canvas for castellations */
  zz=tvrect(Nl,Nt, Nh-Nl,Nv-Nb, xd,yd,Nv);
  fill(zz, p=pdefault+gray(0.5));
  //dot(zz);
}
/**** draw center circle ****/
real cx, cy, crad;
pair ccenter;
path ccirc;
cx=Nh/2;
cy=Nv/2-Nshift;
crad=6*Nsy;
if(Nv%2 != 0) { 
  crad+=0.5; 
}
ccenter=tvps(cx,cy, xd,yd,Nv);
ccirc=circle(ccenter, crad*yd);
if(colortv<=0) {
  draw(ccirc, p=pwhite+linewidth(2*yd));
}

/****** draw 2*divsy+2 horizontal lines **********************************/
real[] rcang, rcoff;
pair[] rcright, rcleft;
int i, iend=2*divsy+1;
for(i=0; i<=iend; ++i) {
  real y, phi, x;
  path zzh;
  pair zd;

  zzh=tvrect(0,rcrowt[i], Nh,rcrowb[i], xd,yd,Nv); 
  fill(zzh, p=pwhite); 

  y=cy-rcrowc[i];
  //write(roff);
  if(abs(y)<crad) {
    phi=asin(y/crad);
  } else {
    phi=pi/2;
  }
  rcang[i]=phi;
  x=(crad*cos(phi))*yd/xd;
  rcoff[i]=x;
  zd=tvps(cx+x,cy-y, xd,yd,Nv);
  rcright[i]=zd;
  //dot(zd);
  zd=tvps(cx-x,cy-y, xd,yd,Nv);
  rcleft[i]=zd;
}

/****** draw 2*divsx+2 vertical lines ***************************/
int[] coff, coffa, coffb;
int poffa=0, ccenterwhite=divsx%2;
for(i=0; i<=divsx; ++i) {
  real cdist=(1+2*i)*Nsx;
  int off, offa, offb;
  path zzv;
  
  off=round(cdist/2);
  //write(cdist,off);
  offa=off+os;
  offb=off-os;

  coff[i]=off;
  coffa[i]=offa;
  coffb[i]=offb;

  //write(Nhc-offa);
  zzv=tvrect(Nhc+offb,0, Nhc+offa,Nv, xd,yd,Nv); 
  fill(zzv, p=pwhite); 
  zzv=tvrect(Nhc-offa,0, Nhc-offb,Nv, xd,yd,Nv); 
  fill(zzv, p=pwhite); 

  /** top castellations, must end with black **/
  if(i%2 == ccenterwhite) { 
    int j, jnum;

    if(poffa == 0) {
      poffa=-offb;
      jnum=1;
    } else {
      jnum=2;
    }

    for(j=0; j<jnum; ++j) {
      int lc, rc;
      path zzc;
      
      if(j==0) {
        lc=Nhc+poffa;
        rc=Nhc+offb;
      } else {
        lc=Nhc-offb;
        rc=Nhc-poffa;
      }

      zzc=tvrect(lc,0, rc,Nt-1, xd,yd,Nv); 
      fill(zzc, p=pblack); 
      zzc=tvrect(lc,Nv-Nb+1, rc,Nv, xd,yd,Nv); 
      fill(zzc, p=pblack); 
    }
  }

  poffa=offa;
}
//write(coff);

/** left and right castellations **/
/* The bottom right red rectangle tests for a non causal color FIR 
 * filter in the receiver.  The last 2..4 dots then typically appear 
 * colorless, green, or cyan.  
 *
 * This comes from the fact that the chroma subcarrier is of lower 
 * bandwidth than luma and thus continues after the last active sample.  
 * These trailing (y,u,v) samples result from a signal to zero 
 * transition and depend on the transmit and receive filters.  Samples 
 * from VHS, system B/G/D/K, system I, or a DVD player output are 
 * different.  Nevertheless, a sharpening filter uses this data and so 
 * adds false color to the last dots.  
 */
int lc, rc;
iend=2*divsy+1;
lc=Nhc-coffa[divsx];
rc=Nhc+coffa[divsx];
for(i=1; i<=iend; ++i) {
  pen pcast;
  if(i == iend && colortv>0) {
    pcast=pdefault+rgb(0.75,0.0,0);
  } else {
    pcast=pblack;
  }
  if(i%2 == 1) {
    int tr, br;
    path zzc;
    
    tr=rcrowb[i-1];
    br=rcrowt[i];    
    zzc=tvrect( 0,tr, lc,br, xd,yd,Nv);
    fill(zzc, p=pblack); 
    zzc=tvrect(rc,tr, Nh,br, xd,yd,Nv); 
    fill(zzc, p=pcast);
  }
}

/****** markers for 4/3 aspect ratio ******/
if(rimage>4/3)
  rimarkers(rimage, Nh, Nhc, os, Nvc, Nsy, pwhite, xd, yd, Nv);

/****** line pairing center ******/
centerline(coff, coffa, coffb, Nhc, divsx, os, rcrowc, Nvc, divsy,
           ccenter, rcoff, rcright, rcleft, pdefault, xd, yd, Nv);

if(colortv>0) {
  /* topbw structure */
  topbw(coff, Nhc, os, rcrowc[divsy-5], rcrowc[divsy-4], rcrowc[divsy-3], 
        ccenter, rcleft[divsy-4], rcleft[divsy-3], rcright[divsy-4],
        rcright[divsy-3], pdefault, xd, yd, Nv);

  /* 250 kHz */
  testtone(Ttone, rcrowc[divsy-3], rcrowc[divsy-2], 
           cx, cy, crad, pdefault, xd, yd, Nv);

  /* color bars */ 
  colorbars(coff, Nhc, rcrowc[divsy-2], rcrowc[divsy-1], rcrowc[divsy], 
            ccenter, rcleft[divsy-2], rcleft[divsy], rcright[divsy-2],
            rcright[divsy], pdefault, xd, yd, Nv);

  /* test frequencies */
  testfreqs(ftones, coff, Nhc, rcrowc[divsy+1], rcrowc[divsy+2],
            rcrowc[divsy+3], ccenter, rcleft[divsy+1], rcleft[divsy+3],
            rcright[divsy+1],rcright[divsy+3], pdefault, xd, yd, Nv);

  /* gray bars */
  graybars(coff, Nhc, rcrowc[divsy+3], rcrowc[divsy+4], ccenter,
           rcleft[divsy+3], rcleft[divsy+4],
           rcright[divsy+3], rcright[divsy+4], pdefault, xd,yd,Nv);

  /* PAL ears */
  if(colortv==1) {
    palears(coff,coffa,coffb, Nhc, rcrowt, rcrowb, Nvc, divsy, -1, 
            pdefault, xd, yd, Nv);
    palears(coff,coffa,coffb, Nhc, rcrowt, rcrowb, Nvc, divsy, 1, 
            pdefault, xd, yd, Nv);
  } else if(colortv==2) {
    ntscbars(coff,coffa,coffb, Nhc, rcrowt, rcrowb, Nvc, divsy, -1, 
             pdefault, xd, yd, Nv);
    ntscbars(coff,coffa,coffb, Nhc, rcrowt, rcrowb, Nvc, divsy, 1, 
             pdefault, xd, yd, Nv);
    ntscbars(coff,coffa,coffb, Nhc, rcrowt, rcrowb, Nvc, divsy, -2, 
             pdefault, xd, yd, Nv);
    ntscbars(coff,coffa,coffb, Nhc, rcrowt, rcrowb, Nvc, divsy, 2, 
             pdefault, xd, yd, Nv);
  }

  /* bottom wh - black - wh */
  bottombw(round((coff[2]+coff[3])/2), Nhc, rcrowc[divsy+4], rcrowc[divsy+5], 
           ccenter, rcleft[divsy+4], rcleft[divsy+5],
           rcright[divsy+4], rcright[divsy+5], pdefault, xd, yd, Nv);

  /* bottom yellow red circle */
  bottomcirc(coff[0], Nhc, rcrowc[divsy+5], cx, cy, crad, 
             ccenter, rcleft[divsy+5], rcright[divsy+5], pdefault, xd, yd, Nv);
}

/********************** set id *********************/
{ /* dpi */
  pair rpos=tvps(Nhc,round((rcrowc[divsy-4]+rcrowc[divsy-5])/2), xd,yd,Nv);
  string iRhor, iRver, ires;
  real Rh, Rv;

  Rh=Nh/xsize*inch;
  Rv=Nv/ysize*inch;
  iRhor=format("%.4gx", Rh);
  iRver=format("%.4gdpi", Rv);
  ires=insert(iRver,0, iRhor);

  /* size info */
  int rowbot=round((rcrowc[divsy+4]+rcrowc[divsy+5])/2);
  pair tpos=tvps(Nhc,rowbot, xd,yd,Nv);
  string ihor, iver, itot, iasp, ifm;
  real asp, fm;

  ihor=format("%ix",Nh);
  iver=format("%i ",Nv);
  itot=insert(iver,0, ihor);
  asp=xsize/ysize;
  iasp=format("%.3g ",asp);
  fm=fs/1e6;
  ifm=format("%.4gMHz",fm);
  itot=insert(iasp,0, itot);
  itot=insert(ifm,0, itot);

  /* size of square */
  int rowNsy=round((rcrowc[divsy+5]+rcrowc[divsy+6])/2);
  pair Npos=tvps(Nhc+round((coff[4]+coff[5])/2),rowNsy, xd,yd,Nv);
  string iNsy=format("%i",Nsy);

  pen pbw;
  if(colortv>0) { 
    pbw=pdefault+gray(1.0); 
  } else { 
    pbw=pdefault+gray(0.0); 
  }
  label(ires, rpos, p=pbw);
  label(itot, tpos, p=pbw);
  label(iNsy, Npos, p=pbw);
  if(verbose > 1)
    write('#res:\t', ires, itot, iNsy);
}



Official Asymptote example – twistedtubes

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 12 h 57 min

Figure 0222
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;  
import palette; 
 
size(300,300,keepAspect=true);  
 
real w=0.4;

real f(triple t) {return sin(t.x);} 
triple f1(pair t) {return (cos(t.x)-2cos(w*t.y),sin(t.x)-2sin(w*t.y),t.y);}
triple f2(pair t) {return (cos(t.x)+2cos(w*t.y),sin(t.x)+2sin(w*t.y),t.y);}
triple f3(pair t) {return (cos(t.x)+2sin(w*t.y),sin(t.x)-2cos(w*t.y),t.y);}
triple f4(pair t) {return (cos(t.x)-2sin(w*t.y),sin(t.x)+2cos(w*t.y),t.y);}

surface s1=surface(f1,(0,0),(2pi,10),8,8,Spline); 
surface s2=surface(f2,(0,0),(2pi,10),8,8,Spline); 
surface s3=surface(f3,(0,0),(2pi,10),8,8,Spline); 
surface s4=surface(f4,(0,0),(2pi,10),8,8,Spline); 

pen[] Rainbow=Rainbow();
s1.colors(palette(s1.map(f),Rainbow)); 
s2.colors(palette(s2.map(f),Rainbow)); 
s3.colors(palette(s3.map(f),Rainbow)); 
s4.colors(palette(s4.map(f),Rainbow)); 

draw(s1); 
draw(s2);
draw(s3);
draw(s4);

Mots-clefs : , ,


Official Asymptote example – unitcircle

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 13 h 57 min

Figure 0223
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,150);

pair z0=0;
pair z1=1;
real theta=30;
pair z=dir(theta);

draw(circle(z0,1));
filldraw(z0--arc(z0,1,0,theta)--cycle,lightgrey);
dot(z0);
dot(Label,z1);
dot("$(x,y)=(\cos\theta,\sin\theta)$",z);
arrow("area $\frac{\theta}{2}$",dir(0.5*theta),2E);
draw("$\theta$",arc(z0,0.7,0,theta),LeftSide,Arrow,PenMargin);

Mots-clefs : , , , , ,


Official Asymptote example – unitcircle3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 14 h 57 min

Figure 0224
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;

size(100);

path3 g=(1,0,0)..(0,1,0)..(-1,0,0)..(0,-1,0)..cycle;
draw(g);
draw(O--Z,red+dashed,Arrow3);
draw(((-1,-1,0)--(1,-1,0)--(1,1,0)--(-1,1,0)--cycle));
dot(g,red);

Mots-clefs : , ,


Official Asymptote example – unitoctant

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 15 h 57 min

Figure 0225
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;

currentprojection=orthographic(5,4,2);

size(0,150);
patch s=octant1;
draw(surface(s),green+opacity(0.5));
draw(s.external(),blue);

triple[][] P=s.P;

for(int i=0; i < 4; ++i)
  dot(P[i],red);

axes3("$x$","$y$",Label("$z$",align=Z));
triple P00=P[0][0];
triple P10=P[1][0];
triple P01=P[0][1];
triple P02=P[0][2];
triple P11=P[1][1];
triple P12=P[1][2];
triple Q11=XYplane(xypart(P11));
triple Q12=XYplane(xypart(P12));

draw(P11--Q11,dashed);
draw(P12--Q12,dashed);
draw(O--Q12--Q11--(Q11.x,0,0));
draw(Q12--(Q12.x,0,0));

label("$(1,0,0)$",P00,-2Y);
label("$(1,a,0)$",P10,-Z);
label("$(1,0,a)$",P01,-2Y);
label("$(a,0,1)$",P02,Z+X-Y);
label("$(1,a,a)$",P11,3X);
label("$(a,a^2,1)$",P12,7X+Y);

Mots-clefs : ,


Official Asymptote example – upint

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 16 h 57 min

Figure 0226
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
import lowupint;

size(100,0);

real a=-0.8, b=1.2;
real c=-1.0/sqrt(3.0);

partition(a,b,c,max);

arrow("$f(x)$",F(0.5*(a+b)),NNE,red);
label("$\cal{U}$",(0.5*(a+b),f(0.5*(a+b))/2));


Mots-clefs : ,


Official Asymptote example – vectorfield

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 17 h 57 min

Figure 0227
(Compiled with Asymptote version 1.87svn-r4652)
/* 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));

Mots-clefs : ,


Official Asymptote example – vectorfield3

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 18 h 57 min

Figure 0228
(Compiled with Asymptote version 1.87svn-r4652)
/* 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);

Mots-clefs : ,


Official Asymptote example – vectorfieldsphere

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

Figure 0229
(Compiled with Asymptote version 1.87svn-r4652)
/* 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));

draw(unitsphere,gray+opacity(0.5));

Mots-clefs : , , ,


Official Asymptote example – venn

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

Figure 0230
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,150);

pen colour1=red;
pen colour2=green;

pair z0=(0,0);
pair z1=(-1,0);
pair z2=(1,0);
real r=1.5;
path c1=circle(z1,r);
path c2=circle(z2,r);
fill(c1,colour1);
fill(c2,colour2);

picture intersection;
fill(intersection,c1,colour1+colour2);
clip(intersection,c2);

add(intersection);

draw(c1);
draw(c2);

label("$A$",z1);
label("$B$",z2);

pair z=(0,-2);
real m=3;
margin BigMargin=Margin(0,m*dot(unit(z1-z),unit(z0-z)));

draw(Label("$A\cap B$",0),conj(z)--z0,Arrow,BigMargin);
draw(Label("$A\cup B$",0),z--z0,Arrow,BigMargin);
draw(z--z1,Arrow,Margin(0,m));
draw(z--z2,Arrow,Margin(0,m));

shipout(bbox(0.25cm));
currentpicture.uptodate=true;

Mots-clefs : , ,


Official Asymptote example – vertexshading

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

Figure 0231
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import three;
//settings.prc=false;

size(200);

currentprojection=perspective(4,5,5);

draw(surface(unitcircle3,new pen[] {red,green,blue,white}));
draw(surface(shift(Z)*unitsquare3,
             new pen[] {red,green+opacity(0.5),blue,black}));

Mots-clefs : , ,


Official Asymptote example – washermethod

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

Figure 0232
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import solids;
size(0,150);
currentprojection=perspective(0,0,11,up=Y);

pen color1=green+opacity(0.25);
pen color2=red;
real alpha=250;

real f(real x) {return 2x^2-x^3;}
pair F(real x) {return (x,f(x));}
triple F3(real x) {return (x,f(x),0);}

ngraph=12;
path[] p={graph(F,0.7476,1.8043,Spline)--cycle,
          graph(F,0.7,0.7476,Spline)--graph(F,1.7787,1.8043,Spline)--cycle,
          graph(F,0,0.7,Spline)--graph(F,1.8043,2,Spline)--cycle};

pen[] pn=new pen[] {color1,color2,color1};

for(int i=0; i < p.length; ++i) {
  revolution a=revolution(path3(p[i]),Y,0,alpha);
  draw(surface(a),pn[i]);

  surface s=surface(p[i]);
  draw(s,pn[i]);
  draw(rotate(alpha,Y)*s,pn[i]);
}

draw((4/3,0,0)--F3(4/3),dashed);
xtick("$\frac{4}{3}$",(4/3,0,0));

xaxis3(Label("$x$",1),Arrow3);
yaxis3(Label("$y$",1),ymax=1.25,dashed,Arrow3);
arrow("$y=2x^2-x^3$",F3(1.6),X+Y,0.75cm,red);
draw(arc(1.1Y,0.3,90,0,7.5,180),Arrow3);

Mots-clefs : , , , ,


Official Asymptote example – wedge

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 23 h 57 min

Figure 0233
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import solids;
size(0,150);
currentprojection=perspective(8,10,2);
currentlight=White;

draw(circle(O,4,Z));
draw(shift(-4Z)*scale(4,4,8)*unitcylinder,green+opacity(0.2));

triple F(real x){return (x,sqrt(16-x^2),sqrt((16-x^2)/3));}
path3 p=graph(F,0,4,operator ..);
path3 q=reverse(p)--rotate(180,(0,4,4/sqrt(3)))*p--cycle;
draw(surface(q--cycle),red);

real t=2;
path3 triangle=(t,0,0)--(t,sqrt(16-t^2),0)--F(t)--cycle;
draw(surface(triangle),blue);

xaxis3("$x$",Arrow3,PenMargin3(0,0.25));
yaxis3("$y$",Arrow3,PenMargin3(0,0.25));
zaxis3("$z$",dashed,Arrow3);

Mots-clefs : , , , ,


Official Asymptote example – westnile

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 0 h 57 min

Figure 0234
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;

size(9cm,8cm,IgnoreAspect);
string data="westnile.csv";

file in=line(csv(input(data)));

string[] columnlabel=in;

real[][] A=dimension(in,0,0);
A=transpose(A);
real[] number=A[0], survival=A[1];

path g=graph(number,survival);
draw(g);

scale(true);

xaxis("Initial no.\ of mosquitoes per bird ($S_{M_0}/N_{B_0}$)",
      Bottom,LeftTicks);
xaxis(Top);
yaxis("Susceptible bird survival",Left,RightTicks(trailingzero));
yaxis(Right);

real a=number[0];
real b=number[number.length-1];

real S1=0.475;
path h1=(a,S1)--(b,S1);
real M1=interp(a,b,intersect(h1,g)[0]);

real S2=0.9;
path h2=(a,S2)--(b,S2);
real M2=interp(a,b,intersect(h2,g)[0]);

labelx("$M_1$",M1);
labelx("$M_2$",M2);

draw((a,S2)--(M2,S2)--(M2,0),Dotted);
draw((a,S1)--(M1,S1)--(M1,0),dashed);

pen p=fontsize(10pt);

real y3=0.043;
path reduction=(M1,y3)--(M2,y3);
draw(reduction,Arrow,TrueMargin(0,0.5*(linewidth(Dotted)+linewidth())));

arrow(shift(-20,5)*Label(minipage("\flushleft{\begin{itemize}\item[1.]
Estimate proportion of birds surviving at end of season\end{itemize}}",100),
                         align=NNE),
      (M1,S1),NNE,1cm,p,Arrow(NoFill));

arrow(shift(-24,5)*Label(minipage("\flushleft{\begin{itemize}\item[2.]
Read off initial mosquito abundance\end{itemize}}",80),align=NNE),
      (M1,0),NE,2cm,p,Arrow(NoFill));

arrow(shift(20,0)*Label(minipage("\flushleft{\begin{itemize}\item[3.]
Determine desired bird survival for next season\end{itemize}}",90),align=SW),
      (M2,S2),SW,arrowlength,p,Arrow(NoFill));

arrow(shift(8,-15)*Label(minipage("\flushleft{\begin{itemize}\item[4.]
Calculate required proportional reduction in mosquitoes\end{itemize}}",90),
                         align=NW),
      point(reduction,0.5),NW,1.5cm,p,Arrow(NoFill));

Mots-clefs : ,


Official Asymptote example – workcone

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 1 h 57 min

Figure 0235
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import solids;
size(0,150);
currentprojection=orthographic(0,-30,5);

real r=4;
real h=10;
real s=8;
real x=r*s/h;

real sr=5;
real xr=r*sr/h;

real s1=sr-0.1;
real x1=r*s1/h;

real s2=sr+0.2;
real x2=r*s2/h;

path3 p=(0,0,0)--(x,0,s);
revolution a=revolution(p,Z);
draw(surface(a,4),lightblue+opacity(0.5));

path3 q=(x,0,s)--(r,0,h);
revolution b=revolution(q,Z);
draw(surface(b),white+opacity(0.5));

draw((-r-1,0,0)--(r+1,0,0));
draw((0,0,0)--(0,0,h+1),dashed);

path3 w=(x1,0,s1)--(x2,0,s2)--(0,0,s2);
revolution b=revolution(w,Z);
draw(surface(b),blue+opacity(0.5));
draw(circle((0,0,s2),x2));
draw(circle((0,0,s1),x1));

draw("$x$",(xr,0,0)--(xr,0,sr),red,Arrow3,PenMargin3);
draw("$r$",(0,0,sr)--(xr,0,sr),N,red);
draw((string) r,(0,0,h)--(r,0,h),N,red);
draw((string) h,(r,0,0)--(r,0,h),red,Arrow3,PenMargin3);
draw((string) s,(-x,0,0)--(-x,0,s),W,red,Arrow3,Bar3,PenMargin3);

Mots-clefs : , ,


Official Asymptote example – xsin1x

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 2 h 57 min

Figure 0236
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph;
size(300,0);

real f(real x) {return (x != 0.0) ? x * sin(1.0 / x) : 0.0;}
pair F(real x) {return (x,f(x));}

xaxis("$x$",red);
yaxis(red);
draw(graph(f,-1.2/pi,1.2/pi,1000));
label("$x\sin\frac{1}{x}$",F(1.1/pi),NW);

Mots-clefs : , ,


Official Asymptote example – xxsq01

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 3 h 57 min

Figure 0237
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import solids;
size(0,150);
currentprojection=perspective(0,0,10,up=Y);

pen color=green;
real alpha=250;

real f(real x) {return x^2;}
pair F(real x) {return (x,f(x));}
triple F3(real x) {return (x,f(x),0);}

path p=graph(F,0,1,n=10,operator ..)--cycle;
path3 p3=path3(p);

revolution a=revolution(p3,X,-alpha,0);
draw(surface(a),color);

surface s=surface(p);
draw(s,color);
draw(rotate(-alpha,X)*s,color);

draw(p3,blue);

xaxis3(Label("$x$",1),xmax=1.25,dashed,Arrow3);
yaxis3(Label("$y$",1),Arrow3);
dot(Label("$(1,1)$"),(1,1,0),X+Y);
arrow("$y=x$",(0.7,0.7,0),Y,0.75cm,red);
arrow("$y=x^2$",F3(0.7),X,0.75cm,red);
draw(arc(1.1X,0.3,90,90,3,-90),Arrow3);

Mots-clefs : , , , ,


Official Asymptote example – xxsq01x-1

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 4 h 57 min

Figure 0238
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import graph3;
import solids;
size(300);
currentprojection=perspective(0,2,10,up=Y);
currentlight=(0.25,-0.25,5);

pen color=green;

real f(real x) {return x^2;}
pair F(real x) {return (x,f(x));}
triple F3(real x) {return (x,f(x),0);}

path p=graph(F,0,1,n=10,operator ..)--cycle;
path3 p3=path3(p);

revolution a=revolution(-X,p3,Y,0,180);
draw(surface(a),color);
surface s=surface(p);
draw(s,color);
transform3 t=shift(-2X)*rotate(180,Y);
draw(t*s,color);
draw(p3);
draw(t*p3);

draw((-1,0,0)--(-1,1,0),dashed);
xaxis3(Label("$x$",1),Arrow3);
yaxis3(Label("$y$",1),Arrow3);
dot(Label("$(1,1)$"),(1,1,0));
dot(Label("$(-1,1)$"),(-1,1,0),W);
arrow("$y=x^{2}$",F3(0.7),X,1cm,red); 
arrow("$y=x$",(0.3,0.3,0),X,1.5cm,red); 
draw(circle((-1,1,0),2,Y),dashed);
draw((-1,1,0)--(1,1,0),dashed);
draw(shift(-X)*arc(0.02Y,0.3,90,0,0,0,CW),Arrow3);

Mots-clefs : , , , ,


Official Asymptote example – xxsq01y

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 5 h 57 min

Figure 0239
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
import solids;
size(0,150);
currentprojection=perspective(0,0,10,up=Y);
pen color=green;
real alpha=240;

real f(real x) {return x^2;}
pair F(real x) {return (x,f(x));}
triple F3(real x) {return (x,f(x),0);}

path p=graph(F,0,1,n=10,operator ..)--cycle;
path3 p3=path3(p);

draw(surface(revolution(p3,Y,0,alpha)),color);

surface s=surface(p);
draw(s,color);
draw(rotate(alpha,Y)*s,color);

draw(p3,blue);

xaxis3(Label("$x$",1),Arrow3);
yaxis3(Label("$y$",1),ymax=1.25,dashed,Arrow3);

dot("$(1,1)$",(1,1,0),X);
arrow("$y=x^{2}$",F3(0.7),X,0.75cm,red); 
arrow("$y=x$",(0.8,0.8,0),Y,1cm,red); 

real r=0.4;
draw((r,f(r),0)--(r,r,0),red);
draw("$r$",(0,(f(r)+r)*0.5,0)--(r,(f(r)+r)*0.5,0),N,red,Arrows3,PenMargins3);
draw(arc(1.1Y,0.3,90,0,7.5,180),Arrow3);

Mots-clefs : , , , ,


Official Asymptote example – yingyang

Catégorie : Asymptote, Official Gallery One-PagerPh. Ivaldi @ 6 h 57 min

Figure 0240
(Compiled with Asymptote version 1.87svn-r4652)
/* This code comes from The Official Asymptote Gallery */
    
size(0,25cm);
guide center=(0,1){W}..tension 0.8..(0,0){(1,-.5)}..tension 0.8..{W}(0,-1); 

draw((0,1)..(-1,0)..(0,-1));
filldraw(center{E}..{N}(1,0)..{W}cycle);
unfill(circle((0,0.5),0.125));
fill(circle((0,-0.5),0.125));

Mots-clefs : , , , ,