Asymptote Generalities – fig0390

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 12 h 39 min

Figure 0039
(Compiled with Asymptote version 2.14svn-r5318)
    
path line=(0,0)--(5cm,0);

draw(line,Arrow(20bp,filltype=NoFill));
draw(shift(0,-cm)*line,Arrow(20bp,filltype=FillDraw(.8red)));
draw(shift(0,-2cm)*line,Arrow(20bp,filltype=Fill(.8red)));
draw(shift(0,-3cm)*line,Arrows(filltype=FillDraw(-10,10,.8red)));

Étiquettes : , ,


Asymptote Generalities – fig0400

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 13 h 39 min

Figure 0040
(Compiled with Asymptote version 2.14svn-r5318)
    
DefaultHead=HookHead;
path line=(0,0)--(5cm,0);

draw(line,Arrow(20bp,filltype=NoFill));
draw(shift(0,-cm)*line,Arrow(20bp,filltype=FillDraw(.8red)));
draw(shift(0,-2cm)*line,Arrow(20bp,filltype=Fill(.8red)));
draw(shift(0,-3cm)*line,Arrows(filltype=FillDraw(-10,10,.8red)));

Étiquettes : , ,


Asymptote Generalities – fig0410

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 14 h 39 min

Figure 0041
(Compiled with Asymptote version 2.14svn-r5318)
    
DefaultHead=TeXHead;
path line=(0,0)--(5cm,0);

draw(line,Arrow(10bp,filltype=NoFill));
draw(shift(0,-2cm)*line,Arrow(10bp,filltype=FillDraw(.8red)));
draw(shift(0,-4cm)*line,Arrow(10bp,filltype=Fill(.8red)));
draw(shift(0,-6cm)*line,Arrows(filltype=FillDraw(-10,10,.8red)));

Étiquettes : , ,


Asymptote Generalities – fig0430

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 16 h 39 min

Figure 0043
(Compiled with Asymptote version 2.14svn-r5318)
    
size(5cm,0);
path line=(0,0)--(5,0);

draw(line,Arrow(20bp,position=.75));
draw(shift(0,-2)*line,Arrow(20bp,40,.75,filltype=NoFill));

position pos=BeginPoint;
pos.position=.75;
draw(shift(0,-4)*line,BeginArrow(20bp,pos));
draw(shift(0,-6)*line,BeginArrow(20bp,40,pos,filltype=NoFill));

Étiquettes : , , ,


Asymptote Generalities – fig0450

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 18 h 39 min

Figure 0045
(Compiled with Asymptote version 2.14svn-r5318)
    
size(5cm,0);
path g = (0,0)--(1,0);
draw(g,Arrow(Relative(0.75)));
add(arrow(reverse(g), invisible, FillDraw(green,red), Relative(0.75)));

Étiquettes : , ,


Asymptote Generalities – fig0490

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 22 h 39 min

Figure 0049
(Compiled with Asymptote version 2.14svn-r5318)
    
fill((0,0)--(0,2cm)--(2cm,0)--cycle,gray);

Étiquettes : , ,


Asymptote Generalities – fig0500

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 23 h 39 min

Figure 0050
(Compiled with Asymptote version 2.14svn-r5318)
    
filldraw((0,0)--(0,2cm)--(2cm,0)--cycle,gray);

Étiquettes : , ,


Asymptote Generalities – fig0510

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 0 h 39 min

Figure 0051
(Compiled with Asymptote version 2.14svn-r5318)
    
filldraw((0,0)--(0,2cm)--(2cm,0)--cycle,fillpen=gray,drawpen=linewidth(1mm)+.8red);

Étiquettes : , ,


Asymptote Generalities – fig0520

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 1 h 39 min

Figure 0052
(Compiled with Asymptote version 2.14svn-r5318)
    
pen[][] p={{rgb(black)},
           {rgb(.8red)}};

latticeshade((0,0)--(0,2cm)--(2cm,0)--cycle,p);

Étiquettes : , , ,


Asymptote Generalities – fig0530

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 2 h 39 min

Figure 0053
(Compiled with Asymptote version 2.14svn-r5318)
    
pen[][] p={{rgb(black),rgb(black)},
           {rgb(red),rgb(green)}};

latticeshade((0,0)--(0,2cm)--(2cm,0)--cycle,p);

Étiquettes : , , ,


Asymptote Generalities – fig0540

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 3 h 39 min

Figure 0054
(Compiled with Asymptote version 2.14svn-r5318)
    
size(3cm,0);

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

latticeshade(unitsquare,p);

Étiquettes : , ,


Asymptote Generalities – fig0550

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 4 h 39 min

Figure 0055
(Compiled with Asymptote version 2.14svn-r5318)
    
size(3cm,0);
import palette;

real[][] v={{1,2},{3,4}};
pen[] Palette=Rainbow();

latticeshade(box((0,0),(1,1)),palette(v,Palette));

Étiquettes : , ,


Asymptote Generalities – fig0560

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 5 h 39 min

Figure 0056
(Compiled with Asymptote version 2.14svn-r5318)
    
size(3cm,0);

pair A=(0.35,0.35), B=(0.6,0.6);

radialshade(unitsquare,black,A,0.15,lightgrey,B,.6);

dot(A,.8red);
dot(B,blue+grey);
draw(shift(A)*scale(.15)*unitcircle,dashed+.8red);
draw(shift(B)*scale(.6)*unitcircle,dashed+blue+grey);
clip(unitsquare);

Étiquettes : , ,


Asymptote Generalities – fig0570

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 6 h 39 min

Figure 0057
(Compiled with Asymptote version 2.14svn-r5318)
    
size(3cm,0);

transform t=xscale(1.25);
pen p1=red, p2=yellow;
pair pa=t*dir(135), pb=t*dir(-45);

axialshade(t*unitcircle,p1,pa,p2,pb);
draw(pa--pb, dashed);

Étiquettes : , , ,


Asymptote Generalities – fig0580

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 7 h 39 min

Figure 0058
(Compiled with Asymptote version 2.14svn-r5318)
    
// Author: John Bowman
size(10cm,0);

real r=1;
real R=3.8;

int step=30;
path p=arc(0,r,0,step);
path P=arc(0,R,step,0);
for(int h=0; h < 360; h += step) {
  transform t=rotate(90-h);
  tensorshade(t*p--t*P--cycle,
              new pen[] {white,white,hsv(h-step,1,1),hsv(h,1,1)});
}

for(int h=0; h < 360; h += 30) {
  pair v=R*dir(90-h);
  draw(Label(string(h)+"$^\circ$",EndPoint),(v--1.05v));
}

draw(circle(0,r));
draw(circle(0,R));

Étiquettes : , , , , ,


Asymptote Generalities – fig0590

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 8 h 39 min

Figure 0059
(Compiled with Asymptote version 2.14svn-r5318)
    
size(12cm,0);
path[] P=texpath("$\displaystyle\int_{-\infty}^{+\infty}e^{-\alpha x^2}\,dx=
\sqrt{\frac{\pi}{\alpha}}$");
pair m=min(P), M=max(P);

axialshade(P,yellow,m,red,(m.x,M.y));
draw(P,0.5*blue);
shipout(bbox(3mm,Fill));

Étiquettes : , , , ,


Asymptote Generalities – fig0600

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 9 h 39 min

Figure 0060
(Compiled with Asymptote version 2.14svn-r5318)
    
size(3cm,0);

pair A, B, C, D;
A=(0,0); B=(1,0);
C=(1,1); D=(0,1);
fill(A--C--B--D--cycle,grey);

Étiquettes : , ,


Asymptote Generalities – fig0610

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 10 h 39 min

Figure 0061
(Compiled with Asymptote version 2.14svn-r5318)
    
size(3cm,0);

pair A, B, C, D;
A=(0,0); B=(1,0);
C=(1,1); D=(0,1);
filldraw(A--C--B--D--cycle,grey);

Étiquettes : , ,


Asymptote Generalities – fig0620

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 11 h 39 min

Figure 0062
(Compiled with Asymptote version 2.14svn-r5318)
    
size(10cm,0);

path cle=unitcircle;

draw((-1.5,0)--(2.5,0),linewidth(10mm));
filldraw(cle,red+opacity(.5));
filldraw(shift((1,0))*cle,blue+opacity(.5));

shipout(format="pdf");
/*Others examples here.*/

Étiquettes : , , , ,


Asymptote Generalities – fig0760

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 1 h 39 min

Figure 0076
(Compiled with Asymptote version 2.14svn-r5318)
    
frame f;
label(f,"\textbf{Hello}",yellow,Fill(black));  
add(scale(2)*rotate(45)*f);

Étiquettes : , , ,


Asymptote Generalities – fig0770

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 2 h 39 min

Figure 0077
(Compiled with Asymptote version 2.14svn-r5318)
    
frame f;
filldraw(scale(3cm)*unitsquare,black);
label(f,"Hello",.8red,Fill(white));  
add(scale(2)*rotate(45)*f,(1.5cm,1.5cm));

Étiquettes : , , ,


Asymptote Generalities – fig0830

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 8 h 39 min

Figure 0083
(Compiled with Asymptote version 2.14svn-r5318)
    
size(0,0);
path line=(0,0)--(3cm,0);
transform T=shift(0,-cm);

draw(Label("A",align=Center,filltype=UnFill), line);
draw(Label("B",UnFill), T*line, Center);
draw(Label("C",align=Center,position=Relative(.75),UnFill), T^2*line);
draw(Label("D",position=Relative(.25),UnFill), align=Center, T^3*line);

Étiquettes : , , , , ,


Asymptote Generalities – fig1010

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 2 h 39 min

Figure 0101
(Compiled with Asymptote version 2.14svn-r5318)
    
size(6cm,0);

picture pic;
pen [] P={.8red,.7green,blue+.5grey,yellow+.6grey};

fill(scale(10)*unitcircle,.2blue);

for (int i = 0; i <= 3; ++i)
  draw(pic, arc((0,0),10,i*90,(i+1)*90), P[i]);

for (real i = 1; i <= 10; i+=.05)
  add(rotate(90*i)*scale(1/i)*pic);

Étiquettes : , , , ,


Asymptote Generalities – fig1020

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 3 h 39 min

Figure 0102
(Compiled with Asymptote version 2.14svn-r5318)
    
size(4cm,0);

real a=360/6;
for (int i = -1; i < 5; ++i)
  fill(arc((0,0),1,i*a,(i+1)*a)--cycle,grey);

Étiquettes : , , ,


Asymptote Generalities – fig1030

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 4 h 39 min

Figure 0103
(Compiled with Asymptote version 2.14svn-r5318)
    
size(4cm,0);

real n=7, a=360/n;
for (int i = 0; i < n; ++i)
  filldraw((0,0)--arc((0,0),1,i*a,(i+1)*a)--cycle, i/n*blue + (1-i/n)*green + grey);

Étiquettes : , , , ,


Asymptote Generalities – fig1040

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 5 h 39 min

Figure 0104
(Compiled with Asymptote version 2.14svn-r5318)
    
size(4cm,0);

real a=360/6;
for (int i = -1; i < 5; ++i)
  draw(Label(format("%i",i+1)),arc((0,0),10,i*a,(i+1)*a)--cycle,grey);

Étiquettes : , , , , , , ,


Asymptote Generalities – fig1090

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 10 h 39 min

Figure 0108
(Compiled with Asymptote version 2.14svn-r5318)
    
size(4cm,0);

pair A=0, B=(1,0), C=(.7,1);

void fillangle(picture pic=currentpicture,
               pair O=0, pair A, pair B,
               real radius=10,
               pen p=grey)
{
  picture tpic;
  int n=sgn(radius);
  real a1=degrees(shift(-O)*A,false);
  real a2=degrees(shift(-O)*B,false);
  fill(tpic,(0,0)--arc((0,0), -radius, max(a1,a2), min(a1,a2),true)--cycle, p=p);
  add(pic,tpic,O);
}

draw(A--B--C--cycle);

real r1=15, r2=20;
fillangle(A,B,C,r1,.8red);
fillangle(A,B,C,-r2);
fillangle(B,A,C,r1,.8red);
fillangle(B,A,C,-r2);
fillangle(C,B,A,r1,.8red);
fillangle(C,B,A,-r2);

Étiquettes : , ,


Asymptote Generalities – fig1100

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 11 h 39 min

Figure 0109
(Compiled with Asymptote version 2.14svn-r5318)
    
size(0,0);
pair A, B, C;
A=(0,0); B=(3cm,0); C=(0,3cm);

draw(A--B--C--cycle);
filldraw(shift(A)*scale(4bp)*unitcircle, white);
filldraw(shift(B)*scale(4bp)*unitcircle, white);
filldraw(shift(C)*scale(4bp)*unitcircle, white);

Étiquettes : , ,


Asymptote Generalities – fig1230

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 0 h 39 min

Figure 0122
(Compiled with Asymptote version 2.14svn-r5318)
    
//From documentation of Asymptote
size(0,6cm);
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));

Étiquettes : , , ,


Asymptote Generalities – fig1570

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 10 h 39 min

Figure 0156
(Compiled with Asymptote version 2.14svn-r5318)
    
size(0,0);

pair [] P, Q, R, S;
real u=1cm;

for (int i=0; i<=4; ++i)
  P[i] = rotate(i*360/5)*(0,-u);

P[5] = P[0];
for (int i=0; i<=4; ++i)
  Q[i] = 3*midpoint(P[i]--P[i+1]);

Q[5] = Q[0];
for (int i=0; i<=4; ++i)
  R[i] = 1/3*( Q[i] + Q[i+1] + P[i+1] );

R[5] = R[0];
for (int i=0; i<=5; ++i)
  S[i] = 1.5*Q[i];

fill(shift(-abs(S[0]),-abs(S[0]))*scale(2*abs(S[0]))*unitsquare,.2grey);

radialshade(scale(abs(S[0]))*unitcircle,lightgrey,(0,0),abs(S[0]),
            black,(0,0),abs(.85*midpoint(S[0]--S[1])));

P[6]=P[1];
for (int i=0; i<=4; ++i)
  {
    radialshade(S[i]--Q[i]--R[i]--Q[i+1]--S[i+1]--cycle,
                lightgrey,(0,0),abs(R[i]),
                black,(0,0),abs(S[i]));
    radialshade(R[i]--Q[i+1]--R[i+1]--P[i+2]--P[i+1]--cycle,
                .8red,(0,0),sqrt(1-(2-2cos(pi/5))/4)*u,
                black,(0,0),abs(Q[i+1]));
  }

for (real i=1; i>0; i-=.05)
  fill(rotate(90*(1-i))*scale(i)*(P[0]--P[1]--P[2]--P[3]--P[4]--cycle),
       (1-i)*red);

pen p=linewidth(1pt);
for (int i=0; i<=4; ++i)
  {
    draw(P[i]   -- P[i+1],p);
    draw(P[i+1] -- R[i],p);
    draw(Q[i]   -- R[i],p);
    draw(R[i]   -- Q[i+1],p);
    draw(Q[i]   -- S[i],p);
    draw(S[i]   -- S[i+1],p);
  }

shipout(bbox(0,black+4mm));

Étiquettes : , , ,


Asymptote Generalities – fig1760

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 5 h 39 min

Figure 0175
(Compiled with Asymptote version 2.14svn-r5318)
    
import graph;
size(6cm,0);

path a = polargraph(new real(real t){return t;}, 0, 3pi, operator ..);
path b = polargraph(new real(real t){return 2t;}, 0, 3.75pi, operator ..);

real sharp=40;
path c=relpoint(a,1){relpoint(a,1)-postcontrol(a,length(a)-1)}..{dir(sharp)}relpoint(b,1);

fill(a..c..reverse(b)&cycle,0.8*red);
shipout(bbox(2mm, Fill(0.15*blue)));

Étiquettes : , , , , ,


Asymptote Generalities – fig1900

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 19 h 39 min

Figure 0188
(Compiled with Asymptote version 2.14svn-r5318)
    
//Translate from http://zoonek.free.fr/LaTeX/Metapost/metapost.html
size(6cm,0);

path a,b,c,d;
a = (-1,-.2){up} .. tension 1.2 .. (1,-.2){down};
transform r90=rotate(90);
b = r90*a;
c = r90*b;
d = r90*c;
path bound=buildcycle(a,b,c,d);
fill(bound, lightgrey);
draw(a^^b^^c^^d,grey);
draw(bound);

Étiquettes : , , , , , ,


Asymptote Generalities – fig1910

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 20 h 39 min

Figure 0189
(Compiled with Asymptote version 2.14svn-r5318)
    
size(6cm,0);

path a,b,c;
a = shift(1,0)*scale(2)*unitcircle;
b = rotate(120)*a;
c = rotate(120)*b;

fill(a, red);
fill(b, green);
fill(c, blue);
fill(buildcycle(a,b), red + green);
fill(buildcycle(b,c), green + blue);
fill(buildcycle(c,a), blue + red);
fill(buildcycle(a,b,c), white);

draw(a^^b^^c);

Étiquettes : , , , , , ,


Asymptote Generalities – fig1920

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 21 h 39 min

Figure 0190
(Compiled with Asymptote version 2.14svn-r5318)
    
size(0,0);

path pt1=scale(2cm)*unitcircle;
path pt2=scale(1cm)*unitcircle;

filldraw(pt1^^pt2,yellow+.9white);

Étiquettes : , , ,


Asymptote Generalities – fig1930

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 22 h 39 min

Figure 0191
(Compiled with Asymptote version 2.14svn-r5318)
    
size(0,0);

path pt1=scale(2cm)*unitcircle;
path pt2=scale(1cm)*unitcircle;

filldraw(pt1^^pt2,evenodd+yellow+.9white);

Étiquettes : , , , , ,


Asymptote Generalities – fig1940

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 23 h 39 min

Figure 0192
(Compiled with Asymptote version 2.14svn-r5318)
    
size(0,0);

path pt1=scale(2cm)*unitcircle;
path pt2=scale(1cm)*unitcircle;
path pt3=shift(0,.5cm)*pt2;

filldraw(pt1^^pt2^^pt3,evenodd+yellow+.9white);

Étiquettes : , , , , ,


Asymptote Generalities – fig1950

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 0 h 39 min

Figure 0193
(Compiled with Asymptote version 2.14svn-r5318)
    
size(0,0);

path pt1=scale(2cm)*unitcircle;
path pt2=scale(1cm)*unitcircle;
path pt3=shift(0,1.5cm)*pt2;

filldraw(pt1^^pt2^^pt3,evenodd+yellow+.9white);

Étiquettes : , , , , ,


Asymptote Generalities – fig1970

Category: Asymptote,Examples 2D,GeneralitiesPh. Ivaldi @ 2 h 39 min

Figure 0195
(Compiled with Asymptote version 2.14svn-r5318)
    
size(8cm,0);
import patterns;

add("hatchback",hatch(NW));
filldraw(xscale(2)*unitsquare,pattern("hatchback"));

add("r_hatchback",hatch(2.5mm,NW,.8red));
filldraw(shift(0,-2)*yscale(2)*unitsquare,pattern("r_hatchback"));

add("b_hatchback",hatch(NW,2.5mm+.8blue));
filldraw(shift(1,-2)*yscale(2)*unitsquare,pattern("b_hatchback"));

Étiquettes : , ,


Asymptote using three.asy – fig0090

Category: Asymptote,Examples 3D,three.asyPh. Ivaldi @ 22 h 50 min

Figure 0009
(Compiled with Asymptote version 2.14svn-r5318)
    
size(10cm,0);
import three;

currentprojection=obliqueX;

triple v1=(4,0,0),
       v2=(0,6,0),
       p0=(-2,-3,0);
path3 pl1=plane(v1,v2,p0);

path ph=transform(v1,v2,p0,currentprojection)*((0,-2){W}..(0,2){W}..cycle);
filldraw(project(pl1)^^ph,evenodd+lightgrey);

Étiquettes : , , , , ,


Asymptote and opacity – fig0180

Category: Asymptote,Examples 2D,OpacityPh. Ivaldi @ 9 h 54 min

Figure 0018
(Compiled with Asymptote version 1.87svn-r4652)
    
size(4cm,0);
dotfactor*=5;

dot(scale(2)*"A",(0.5,1),5N);

layer();

dot(scale(2)*"B",(1.5,1),5N);
filldraw(scale(2)*unitsquare, lightgray+opacity(.5));

shipout(bbox(5mm,black,RadialShade(lightblue,darkblue)), "pdf");

Étiquettes : , , , , , ,


Asymptote and opacity – fig0190

Category: Asymptote,Examples 2D,OpacityPh. Ivaldi @ 10 h 54 min

Figure 0019
(Compiled with Asymptote version 1.87svn-r4652)
    
size(10cm,0);
transform T=rotate(10)*xscale(1.1);
path c1=T*unitcircle, c2=T*scale(5)*unitcircle;
real l1=length(c1), l2=length(c2);

fill(scale(8)*shift(-0.5,-0.5)*unitsquare,blue);
int n=500;
real step=1/n;
for (int i=0; i < n; ++i) {
  real t=i*step;
  path g1=subpath(c1,t*l1,(t+step)*l1);
  path g2=subpath(c2,t*l2,(t+step)*l2);
  pair A=(relpoint(c1,t)+relpoint(c2,t))/2;
  pair B=(relpoint(c1,t+step)+relpoint(c2,t+step))/2;
  path sector=g1--reverse(g2)--cycle;
  pen trans=opacity(((2-(2*i/n)^1.5))/2);
  axialshade(sector,trans+i/n*white,A,trans+(i+1)/n*white,B);
}
shipout(bbox(lightblue+white,Fill),format="pdf");

Étiquettes : , ,


Tiling with Asymptote – fig0070

Category: Asymptote,Examples 2D,TilingPh. Ivaldi @ 18 h 06 min

Figure 0007
(Compiled with Asymptote version 1.87svn-r4652)
    
/*Author: Guillaume Connan */
size(10cm,0);

void zigzag(int k)
{
  real t=180/k;
  pair o=(0,0), m=dir(t),
    n=rotate(180-2*t,m)*o,
    b=rotate(4*t-180,n)*m,
    c=rotate(180-6*t,b)*n,
    nn=reflect(o,b)*n;

  path lo=m--n--b--nn--cycle,
    p=o--m--n--b--c--cycle,
    pp=reflect(o,b)*p;

  for (int i=0; i <= k; ++i){
    filldraw(rotate(2*t*i,o)*p,.5*(red+blue));
    filldraw(rotate(2*t*i,o)*pp,0.25(red+blue));
    filldraw(rotate(2*t*i,o)*lo,(red+blue));
  }
}

zigzag(25);
shipout(bbox(3mm,2mm+miterjoin+black,FillDraw(0.5*blue)));

Étiquettes : , , ,


Official Asymptote example – CDlabel

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

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

Étiquettes : , , ,


Official Asymptote example – fillcontour

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

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

size(12cm,IgnoreAspect);

pair a=(pi/2,0);
pair b=(3pi/2,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));

Étiquettes : , , , , ,


Official Asymptote example – hatch

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

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

Étiquettes : , ,


Official Asymptote example – hierarchy

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

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

Étiquettes : , , ,


Official Asymptote example – layers

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

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

Étiquettes : , , ,


Official Asymptote example – planes

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

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


Étiquettes : ,


Official Asymptote example – star

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

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

Étiquettes : , , , ,


Official Asymptote example – strokepath

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

Figure 0225
(Compiled with Asymptote version 2.14svn-r5318)
/* 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):
add(new void(frame f, transform t) {
    fill(f,strokepath(t*g,p),red);
  });
currentpicture.addPath(g,p);


Étiquettes : , ,


Official Asymptote example – superpath

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

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


Étiquettes : , ,


Official Asymptote example – textpath

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

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

Étiquettes : , , , ,


Official Asymptote example – tile

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

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

Étiquettes : , , ,


Official Asymptote example – transparency

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

Figure 0237
(Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */
    
size(0,150);

if(settings.outformat == "")
  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();

Étiquettes : , , ,


Official Asymptote example – unitcircle

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

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

Étiquettes : , , , , ,


Official Asymptote example – venn

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

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

Étiquettes : , ,


Official Asymptote example – yingyang

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

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

Étiquettes : , , , ,


Animation with Asymptote – fig0160

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

Figure 0016
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import graph_settings;
import animate;
size(10cm);
settings.tex="pdflatex";
settings.outformat="pdf";

pair[] interp(pair[] a1, pair[] a2, real k)
{
  if(a1.length != a2.length) abort("interp: arrays have differents length.");
  pair[] g;
  int l=a1.length;
  g=sequence(new pair(int j){
      return interp(a1[j],a2[j],k);
    },l);
  return g;
}

path morphing(pair[] a1, pair[] a2, real k, interpolate join=operator --)
{
  if(a1.length != a2.length) abort("morphing: arrays have differents length.");
  return join(...interp(a1, a2, k));
}

pair[] nodes(path g, int n)
{
  int np=round(n/length(g));
  n=np == 0 ? n : np*length(g);
  return sequence(new pair(int i){return point(g, length(g)*i/n);}, n);
}

animation A;

int nbpt=4;
pair[] A1=nodes(unitsquare,nbpt);
path g=(0,0)--(1,0)--(0,1)--(1,1)--cycle;
pair[] A2=shift(2,1)*rotate(25)*nodes(g,nbpt);
interpolate join=operator ..;
// interpolate join=operator --;


int n=40;
real step=1/n;
pen p1=0.8*red, p2=0.8*blue;

filldraw(join(morphing(A1,A2,0,join),cycle), p1);
filldraw(join(morphing(A1,A2,1,join),cycle), p2);

for (int i=0; i <= n; ++i) {
  save();
  filldraw(join(morphing(A1,A2,i*step,join),cycle),opacity(0.5)+interp(p1,p2,i*step));
  A.add();
  restore();
}

A.movie();

Étiquettes : , , ,


Animation with Asymptote – fig0170

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

Figure 0017
(Compiled with Asymptote version 1.86svn-r4626)
Movie flash (swf)
This animation is available in the Syracuse web site.
    
import graph;
import animate;
size(15cm);
settings.outformat="pdf";

pair[] interp(pair[] a1, pair[] a2, real k)
{
  if(a1.length != a2.length) abort("interp: arrays have differents length.");
  pair[] g;
  int l=a1.length;
  g=sequence(new pair(int j){
      return interp(a1[j],a2[j],k);
    },l);
  return g;
}

path morphing(pair[] a1, pair[] a2, real k, interpolate join=operator --)
{
  if(a1.length != a2.length) abort("morphing: arrays have differents length.");
  return join(...interp(a1, a2, k));
}

pair[] nodes(path g, int n)
{
  int np=round(n/length(g));
  n=np == 0 ? n : np*length(g);
  return sequence(new pair(int i){return point(g, length(g)*i/n);}, n);
}

animation A;

real f(real t){ return exp(cos(t))-2*cos(4*t)+sin(t/12)^5;}
path gf=polargraph(f,0,12*pi,1000);

int nbpt=1000;
pair[] A1=nodes(scale(5.5)*unitcircle,nbpt);
pair[] A2=shift(0,0)*nodes(gf,nbpt);
interpolate join=operator --;


int n=50;
real step=1/n;
pen p1=0.8*red, p2=0.8*blue;

for (int i=0; i <= n; ++i) {
  save();
  filldraw(join(morphing(A1,A2,1,join),cycle),
           evenodd+p2);
  filldraw(join(morphing(A1,A2,i*step,join),cycle),
           evenodd+interp(p1,p2,i*step));
  A.add();
  restore();
}

A.movie(BBox(3mm, 3bp+miterjoin+black, FillDraw(lightyellow)));

Étiquettes : , , ,


Various code with Asymptote – fig0100

Category: Asymptote,MiscellaneousPh. Ivaldi @ 21 h 11 min

Figure 0001
(Compiled with Asymptote version 1.87svn-r4652)
    
size(10cm);

path g=box((-1,-1),(1,1));
pen [] col= new pen[]{gray,yellow};
real k=sqrt(10)/4;
transform T=scale(k)*rotate(degrees(acos(17/(16*k*sqrt(2)))));
int nb=10;

for (int i=0; i<nb; ++i) filldraw(T^i*g,col[i%2]);

Étiquettes : , ,


Various code with Asymptote – fig0200

Category: Asymptote,MiscellaneousPh. Ivaldi @ 22 h 11 min

Figure 0002
(Compiled with Asymptote version 1.87svn-r4652)
    
size(10cm);
path g=box((-1,-1),(1,1));
pen [] col= new pen[]{gray,yellow};

path pairToSquare(pair pt){ return pt -- I*pt -- -pt -- -I*pt --cycle; }

int nb=10;
for (int i=0; i<nb; ++i)
  {
    filldraw(g,col[i%2]);
    g=pairToSquare(relpoint(g,1/16));
  }

Étiquettes : , , ,