## Iterative method for the Ammann-Beenker tiling – the code

// needs class Vector and saveImage code
// for details see Iterative method for the Ammann-Beenker tiling using “Vector”

Vector a,b,c;
float f;

void setup(){
size(600,600);
f=1./(1.+sqrt(2.));
strokeWeight(2);
smooth();
}

void draw(){
noLoop();
a=new Vector(-10,-10);
b=new Vector(1200,-10);
c=new Vector(-10,1200);
int ite=4;
triangle(a,b,c,ite);
saveImage();
}

Vector d=sub(c,a);
}

void triangle(Vector a,Vector b,Vector c,int ite){
if(ite==0){
fill(255,128,128);
return;
}
Vector m=interpolate(0.5,b,c);
Vector z=interpolate(f,m,a);
Vector mc=interpolate(f,m,c);
Vector mb=interpolate(f,m,b);
Vector ac=interpolate(f,a,c);
Vector ba=interpolate(f,b,a);
triangle(z,mc,mb,ite-1);
triangle(mc,c,ac,ite-1);
triangle(z,a,ba,ite-1);
rhomb(z,mb,ba,ite-1);
rhomb(a,ac,z,ite-1);
}

void rhomb(Vector a,Vector b,Vector c,int ite){
if(ite==0){
fill(128,128,255);
return;
}
Vector d=sub(c,a);
Vector z=interpolate(0.5,a,d);
Vector za=interpolate(f/(2+f),z,a);
Vector zd=interpolate(f/(2+f),z,d);
Vector ac=interpolate(f,a,c);
Vector ab=interpolate(f,a,b);
Vector dc=interpolate(f,d,c);
Vector db=interpolate(f,d,b);
triangle(za,c,ac,ite-1);
triangle(za,b,ab,ite-1);
triangle(zd,c,dc,ite-1);
triangle(zd,b,db,ite-1);
rhomb(c,za,zd,ite-1);
rhomb(a,ab,ac,ite-1);
rhomb(d,dc,db,ite-1);
}
This entry was posted in programming, Quasiperiodic design and tagged , , , . Bookmark the permalink.

This site uses Akismet to reduce spam. Learn how your comment data is processed.