Making quasiperiodic structures using waves: A simple program

 

// this is a simple program

// it shows more clearly how I get quasiperiodic structures

// from waves

// feel free to experiment

//————————————————

// to run the program you need processing

// simply download processing from processing.org

//

// note: processing is essentially JAVA with great additional

// libraries for doing computer graphics

 

float skala;

float offset, theWidth;

float oneOrTwo, deltaPhase;

int m, n; //anzahl richtungen

float phiZero;

float[] cosang=new float[20];

float[] sinang=new float[20];

 

void setup() {

 

size(600, 600);

smooth();

 

// here come the parameters to change and experiment with

//———————————————————–

 

skala=100;

 

oneOrTwo=1;

phiZero=PI/2; // 0 or PI/2

n=6;

m=2; // other valuies may surprise

 

 

offset=0;

theWidth=0.3;

 

//end of parameters

//———————————————————–

 

fSetup();

}

 

void draw() {

noLoop();

loadPixels();

int i, j, jj, index;

int widthh=width/2;

float x, y;

float ff;

float iWidth=skala/width;

for (j=0;j<width;j++) {

jj=width*j;

y=(j-widthh)*iWidth;

 

for (i=0;i<width;i++) {

index=i+jj;

x=(i-widthh)*iWidth;

 

ff=f(x, y);

ff=linear(ff);

 

// here comes a fancy nionlinear color model

 

pixels[index]=color(200*ff, 400*(1-ff)*(1-ff)*(1-ff), 400*(1-ff));

}

}

 

updatePixels();

}

//——————————————————————————

 

void fSetup() {

deltaPhase=oneOrTwo*PI*m/n;

for (int i=0;i<n; i++) {

cosang[i]=cos(oneOrTwo*PI/n*i);

sinang[i]=sin(oneOrTwo*PI/n*i);

}

}

//——————————————————————————

 

float f(float x, float y) {

float res=0, phase=phiZero;

for (int i=0;i<n; i++) {

res+=sin(cosang[i]*x+sinang[i]*y+phase);

phase+=deltaPhase;

}

res/=n;

 

return res;

}

 

///——————————————————————————

 

float linear(float ff) {

ff-=offset;

if (abs(ff)<theWidth) {

return( 0.5*(ff+theWidth)/theWidth);

}

if (ff<0) {

return 0;

}

return 1.;

// return color(abs(ff));

}

 

 

This entry was posted in Tilings and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s