Tiling with Asymptote – fig0010

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

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

picture pavehexagonal(int depth=1)
{
  picture opic;
  path hexa=polygon(6);
  pair center;
  real a,ap,r,rp,r_d=180/pi;

  for(int j=0; j<depth; ++j)
    {
      for (int i=1; i<=6; ++i)
        {
          a=i*60-30;
          r=j*sqrt(3);
          center=r*(rotate(a)*(1,0));
          filldraw(opic, shift(center)*hexa, j/depth*.8red+(1-j/depth)*.8*blue);
          //Uncomment to see centers of hexagons
          dot(opic, shift(center)*midpoint(point(hexa,0)--point(hexa,3)));
          //Uncomment to see circles passing by centers
          //draw(opic, scale(r)*unitcircle, j/depth*red+(1-j/depth)*blue);
          rp=r;
          ap=0;
          for (real k=0; k<j-1; ++k)
            {
              r=sqrt((1.5*(j-1 - k))^2 + 3/4*(j+1 + k)^2);
              ap+=r_d*acos((rp^2 + r^2 - 3)/(2*r*rp));
              center=r*(rotate(a + ap)*(1,0));
              filldraw(opic, shift(center)*hexa, j/depth*.8*red+(1-j/depth)*.8*blue);
              //Uncomment to see the centers of hexagons
              //dot(opic, shift(center)*midpoint(point(hexa,0)--point(hexa,3)));
              rp=r;
              //Uncomment to see circles passing by centers
              //draw(opic, scale(r)*unitcircle, j/depth*red+(1-j/depth)*blue);
            }
        }
    }
  return opic;
}


add(pavehexagonal(7));

Étiquettes : , ,


Tiling with Asymptote – fig0020

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

Figure 0002
(Compiled with Asymptote version 1.87svn-r4652)
    
size(6cm,0);

//Circular paving with the unit hexagonal picture "hexa"
picture pavehexagonal(picture hexa, int depth=1)
{
  picture opic;
  pair center;
  real a,ap,r,rp,r_d=180/pi;

  add(opic, hexa);

  for(int j=0; j<depth; ++j)
    {
      for (int i=1; i<=6; ++i)
        {
          a=i*60-30;
          r=j*sqrt(3);
          center=r*(rotate(a)*(1,0));
          add(opic, shift(center)*hexa);
          rp=r;
          ap=0;
          for (real k=0; k<j-1; ++k)
            {
              r=sqrt((1.5*(j-1 - k))^2 + 3/4*(j+1 + k)^2);
              ap+=r_d*acos((rp^2 + r^2 - 3)/(2*r*rp));
              center=r*(rotate(a + ap)*(1,0));
              add(opic, shift(center)*hexa);
              rp=r;
            }
        }
    }
  return opic;
}

picture hexa;
fill(hexa, polygon(6));
path inh=(0,0)--(.6,sqrt(3)/4)--(.5,sqrt(3)/2)--cycle;

for(int i=0; i<6; ++i)
  {
    fill(hexa, rotate(60*i)*inh,.5red);
  }

draw(hexa, inh);
add(rotate(45)*pavehexagonal(hexa,10));
clip(scale(10)*shift(-.5,-.5)*unitsquare);

Étiquettes : ,


Tiling with Asymptote – fig0030

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

Figure 0003
(Compiled with Asymptote version 1.87svn-r4652)
    
size(10cm,0);

transform r60=rotate(60);

pair A=(sqrt(3)/2,-.5);
pair B=r60*A, C=r60*B, D=r60*C, E=r60*D, F=r60*E;

path AB=A{dir(90)}..(.6,.5)..B{dir(0)};
path DE=shift(E-A)*reverse(AB);
path BC=B{dir(45)}..(.75,.7){dir(150)}..{dir(135)}(.65,.75){dir(70)}..(.5,1.25)..C{dir(255)};
path EF=shift(F-B)*reverse(BC);
path CD=C{dir(255)}..(-.4,.5){dir(200)}..D{dir(160)};
path FA=shift(A-C)*reverse(CD);

draw(A--B--C--D--E--F--cycle,linewidth(2pt));
draw(AB,2pt+.8red);
draw(DE,2pt+.8red);
draw(BC,2pt+.8blue);
draw(EF,2pt+.8blue);
draw(CD,2pt+.8green);
draw(FA,2pt+.8green);

picture hexa;
picture eye;

filldraw(hexa,AB--BC--CD--DE--EF--FA--cycle,black,white);
filldraw(eye,rotate(5)*xscale(.4)*unitcircle,white);
filldraw(hexa,subpath(AB,1,2)--subpath(BC,0,2){dir(225)}..{dir(245)}cycle,.1red+yellow,white);
draw(hexa,point(BC,0.1){dir(115)}.. (.8,.55) ..(.6,.65){dir(180)},yellow+grey);
filldraw(eye,rotate(5)*xscale(.4)*unitcircle,white);
fill(eye,rotate(5)*shift(0,-.1)*xscale(.25)*scale(.5)*unitcircle);
add(hexa,shift(.6,.9)*scale(.1)*eye);

add(shift(3,0)*hexa);

Étiquettes : , ,


Tiling with Asymptote – fig0040

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

Figure 0004
(Compiled with Asymptote version 1.87svn-r4652)
    
size(15cm,0);

transform r60=rotate(60);
picture hexa;
picture eye;

pair A=(sqrt(3)/2,-.5);
pair B=r60*A, C=r60*B, D=r60*C, E=r60*D, F=r60*E;

//Body - corps
path AB=A{dir(90)}..(.6,.5)..B{dir(0)};
path DE=shift(E-A)*reverse(AB);
path BC=B{dir(45)}..(.75,.7){dir(150)}..{dir(135)}(.65,.75){dir(70)}..(.5,1.25)..C{dir(255)};
path EF=shift(F-B)*reverse(BC);
path CD=C{dir(255)}..(-.4,.5){dir(200)}..D{dir(160)};
path FA=shift(A-C)*reverse(CD);

filldraw(hexa,AB--BC--CD--DE--EF--FA--cycle,black,white);

//Nozzle - bec
filldraw(hexa,subpath(AB,1,2)--subpath(BC,0,2){dir(225)}..{dir(245)}cycle,.1red+yellow,white);
draw(hexa,point(BC,0.1){dir(115)}.. (.8,.55) ..(.6,.65){dir(180)},yellow+grey);

//Eye - oeil
filldraw(eye,rotate(5)*xscale(.4)*unitcircle,white);
filldraw(eye,rotate(5)*xscale(.4)*unitcircle,white);
fill(eye,rotate(5)*shift(0,-.1)*xscale(.25)*scale(.5)*unitcircle);
add(hexa,shift(.6,.9)*scale(.1)*eye);

//Circular paving with the unit hexagonal picture "hexa"
picture pavehexagonal(picture hexa, int depth=1)
{
  picture opic;
  pair center;
  real a,ap,r,rp,r_d=180/pi;

  add(opic, hexa);

  for(int j=0; j<depth; ++j)
    {
      for (int i=1; i<=6; ++i)
 {
   a=i*60-30;
   r=j*sqrt(3);
   center=r*(rotate(a)*(1,0));
   add(opic, shift(center)*hexa);
   rp=r;
   ap=0;
   for (real k=0; k<j-1; ++k)
     {
       r=sqrt((1.5*(j-1 - k))^2 + 3/4*(j+1 + k)^2);
       ap+=r_d*acos((rp^2 + r^2 - 3)/(2*r*rp));
       center=r*(rotate(a + ap)*(1,0));
       add(opic, shift(center)*hexa);
       rp=r;
     }
 }
    }
  return opic;
}

add(pavehexagonal(rotate(30)*hexa,3));

Étiquettes :


Tiling with Asymptote – fig0050

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

Figure 0005
(Compiled with Asymptote version 1.87svn-r4652)
    
size(10cm,0);

transform r60=rotate(60);
picture hexa;

pair A=(1,0);
pair B=r60*A, C=r60*B, D=r60*C, E=r60*D, F=r60*E;

real ad=30;
real tensio=.15;
path AB=A {dir(120-ad)} .. shift(tensio*dir(30))*midpoint(A--B)  .. B {dir(120+ad)};
path BC=reverse(rotate(240,B)*AB);
path CD=reverse(rotate(240,C)*BC);
path DE=reverse(rotate(240,D)*CD);
path EF=reverse(rotate(240,E)*DE);
path FA=reverse(rotate(240,F)*EF);

real lux=-.3, sq=sqrt(3)/2;
radialshade(hexa,AB--BC--CD--DE--EF--FA--cycle,
            lightgrey,(lux*sq,lux/2),0,
            grey,(lux*sq,lux/2),1+abs(lux));

//Circular paving with the unit hexagonal picture "hexa"
picture pavehexagonal(picture hexa, int depth=1)
{
  picture opic;
  pair center;
  real a,ap,r,rp,r_d=180/pi;

  add(opic, hexa);

  for(int j=0; j<depth; ++j)
    {
      for (int i=1; i<=6; ++i)
 {
   a=i*60-30;
   r=j*sqrt(3);
   center=r*(rotate(a)*(1,0));
   add(opic, shift(center)*hexa);
   rp=r;
   ap=0;
   for (real k=0; k<j-1; ++k)
     {
       r=sqrt((1.5*(j-1 - k))^2 + 3/4*(j+1 + k)^2);
       ap+=r_d*acos((rp^2 + r^2 - 3)/(2*r*rp));
       center=r*(rotate(a + ap)*(1,0));
       add(opic, shift(center)*hexa);
       rp=r;
     }
 }
    }
  return opic;
}

add(pavehexagonal(hexa,4));

Étiquettes :


Tiling with Asymptote – fig0060

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

Figure 0006
(Compiled with Asymptote version 1.87svn-r4652)
    
size(10cm,0);

transform r60=rotate(60);

pair A=(1,0);
pair B=r60*A, C=r60*B, D=r60*C, E=r60*D, F=r60*E;

real ad=30;
real tensio=.25;
path AB=A {dir(120-ad)} .. shift(tensio*dir(30))*midpoint(A--B)  .. B {dir(120+ad)};
path BC=reverse(rotate(240,B)*AB);
path CD=reverse(rotate(240,C)*BC);
path DE=reverse(rotate(240,D)*CD);
path EF=reverse(rotate(240,E)*DE);
path FA=reverse(rotate(240,F)*EF);
path pth1=AB--BC--CD--DE--EF--FA;

real tensio=.5;
path AB=A {dir(120-ad)} .. shift(tensio*dir(30))*midpoint(A--B)  .. B {dir(120+ad)};
path BC=reverse(rotate(240,B)*AB);
path CD=reverse(rotate(240,C)*BC);
path DE=reverse(rotate(240,D)*CD);
path EF=reverse(rotate(240,E)*DE);
path FA=reverse(rotate(240,F)*EF);
path pth2=AB--BC--CD--DE--EF--FA;


//Circular paving with the unit hexagonal picture "hexa"
picture pavehexagonal(picture hexa, int depth=1)
{
  picture opic;
  pair center;
  real a,ap,r,rp,r_d=180/pi;

  add(opic, hexa);

  for(int j=0; j<depth; ++j)
    {
      for (int i=1; i<=6; ++i)
 {
   a=i*60-30;
   r=j*sqrt(3);
   center=r*(rotate(a)*(1,0));
   add(opic, shift(center)*hexa);
   rp=r;
   ap=0;
   for (real k=0; k<j-1; ++k)
     {
       r=sqrt((1.5*(j-1 - k))^2 + 3/4*(j+1 + k)^2);
       ap+=r_d*acos((rp^2 + r^2 - 3)/(2*r*rp));
       center=r*(rotate(a + ap)*(1,0));
       add(opic, shift(center)*hexa);
       rp=r;
     }
 }
    }
  return opic;
}

picture hexa, hexat;

real lux=-.3, sq=sqrt(3);
radialshade(hexa,pth1--cycle,
            lightgrey,(lux*sq/2,lux/2),0,
            grey,(lux*sq/2,lux/2),1+abs(lux));


add(hexat,scale(1/(3*sq))*pavehexagonal(hexa,5));
clip(hexat,pth2--cycle);
draw(hexat,pth2);
add(pavehexagonal(hexat,4));

É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 : , , ,


Fractals with Asymptote – fig0010

Category: Asymptote,Examples 2D,FractalsPh. Ivaldi @ 21 h 53 min

Figure 0001
(Compiled with Asymptote version 1.87svn-r4652)
    
// From documentation of Asymptote
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));

Étiquettes : , , , ,


Fractals with Asymptote – fig0020

Category: Asymptote,Examples 2D,FractalsPh. Ivaldi @ 22 h 53 min

Figure 0002
(Compiled with Asymptote version 1.87svn-r4652)
    
size(10cm,0);

transform scale(pair center, real k) {
  return shift(center)*scale(k)*shift(-center);
}

path trk=(0,0)--(0,1);

void tree(path p, int n, real a=30, real b=40, real r=.75) {
  if (n!=0) {
    pair h=point(p,length(p));
    transform tb=rotate(180-b,h)*scale(h,r);
    transform ta=rotate(-180+a,h)*scale(h,r);
    draw(p,n/3+1/(n+1)*green+n/(n+1)*brown);
    tree(tb*reverse(p),n-1,a,b,r);
    tree(ta*reverse(p),n-1,a,b,r);
  }
}

tree(trk,12,a=25,b=40,r=.75);

Étiquettes : , , ,


Fractals with Asymptote – fig0030

Category: Asymptote,Examples 2D,FractalsPh. Ivaldi @ 23 h 53 min

Figure 0003
(Compiled with Asymptote version 1.87svn-r4652)
    
// Barnsley's fern
// Fougère de Barnsley
size(5cm,0);

real ab=85, ac=-5;
real rc=.85, rb=-.31;
path trk=(0,0)--(0,1);

transform ta=shift(0,1)*rotate(ab)*scale(rb);
transform tb=shift(0,1)*rotate(-ab)*scale(rb);
transform tc=shift(0,1)*rotate(ac)*scale(rc);

picture fern(int n) {
  picture opic;
  draw(opic,trk^^ta*trk^^tb*trk^^tc*trk);
  if (n==0) return opic;
  picture branch=fern(n-1);
  add(opic,branch);
  add(opic,ta*branch);
  add(opic,tb*branch);
  add(opic,tc*branch);
  return opic;
}

add(fern(6));

Étiquettes : , , , ,