Official Asymptote example – smoothelevation

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

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

currentlight=Viewport;

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 – slopefield1

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

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

size(200);

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



Mots-clefs : ,


Official Asymptote example – sinxlex

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

Figure 0205
(Compiled with Asymptote version 2.14svn-r5318)
/* 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 – sinc

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

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

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

size(12cm,0);

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

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

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

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

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

Mots-clefs : , , , ,


Official Asymptote example – sin1x

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

Figure 0202
(Compiled with Asymptote version 2.14svn-r5318)
/* 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 – shellsqrtx01

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

Figure 0198
(Compiled with Asymptote version 2.14svn-r5318)
/* 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);

render render=render(compression=0,merge=true);
draw(surface(a),color,render);
draw(p3,blue);

surface s=surface(p);
draw(s,color,render);
draw(rotate(alpha,X)*s,color,render);

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 – shellmethod

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

Figure 0197
(Compiled with Asymptote version 2.14svn-r5318)
/* 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);

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

revolution a=revolution(p3,Y,0,alpha);
draw(surface(a),color,render);
draw(rotate(alpha,Y)*s,color,render);
for(int i=0; i < n; ++i)
  draw(surface(blocks[i]),color+opacity(0.5),black,render);
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 – shadestroke

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

Figure 0196
(Compiled with Asymptote version 2.14svn-r5318)
/* 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 – shadedtiling

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

Figure 0195
(Compiled with Asymptote version 2.14svn-r5318)
/* 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 – shade

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

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

size(100,0);
radialshade(unitsquare,yellow,(0,0),0,red,(0,0),1);


Mots-clefs : ,