PIPRIME.FR BLOG

Live fully to honor life

Tiling with the Asymptote drawing software

Tesselation or tiling with the Asymptote drawing and programming software

A tessellation or tiling is the covering of a surface using one or more geometric shapes with no overlaps and no gaps. In mathematics, tessellation can be generalized to higher dimensions and a variety of geometries.

🔗tiling-fig001

Figure tiling 001 Generated with Asymptote

Show tiling/fig0010.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Tiling
Tags : #Tiling | #Function (creating) | #Picture

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));

🔗tiling-fig002

Figure tiling 002 Generated with Asymptote

Show tiling/fig0020.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Tiling
Tags : #Tiling | #Clip

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);

🔗tiling-fig003

Figure tiling 003 Generated with Asymptote

Show tiling/fig0030.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Tiling
Tags : #Path | #Picture | #Tiling

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);

🔗tiling-fig004

Figure tiling 004 Generated with Asymptote

Show tiling/fig0040.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Tiling
Tags : #Tiling

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));

🔗tiling-fig005

Figure tiling 005 Generated with Asymptote

Show tiling/fig0050.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Tiling
Tags : #Tiling

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));

🔗tiling-fig006

Figure tiling 006 Generated with Asymptote

Show tiling/fig0060.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Tiling
Tags : #Tiling | #Clip

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));

🔗tiling-fig007

Figure tiling 007 Generated with Asymptote

Author: Guillaume Connan.

Show tiling/fig0070.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Tiling
Tags : #Tiling | #Transform | #Shipout | #Fill/Unfill

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)));

0%