SNERKT done :)

Here is the newest recoding 🙂

/** Sne Comp Art: Routine SNE RKT

originally developed in 1976 by Reiner Schneeberger
recoded in Processing in 2013 by Dietrich M. Scheringer
version 2.0

*/

void setup() // Setting up the area for drawing
{
size(400,600); // 0 <= x <= 1280, 0 <= y <= 1024
background(0); // backround colour: black
stroke(255); // colour of the lines: white
noLoop(); // execute method draw only once
}

void draw()
{
/* Parameters für snerkt */

float x1 = 10.; // Lower boundary for x-ccodinates
float x2 = 370.; // Upper boundary for x-coodinates
float y1 = 10.; // Lower boundary for y-ccordinates
float y2 = 595.; // Upper boundary for y-coordinates
float anzpkt = 1000.; // Maximal number of points
float amplx = 12.; // Maximal distance between two consecutive points in direction of the x-axis
float amply = 18.; // Maximal distance between two consecutive points in direction of the y-axis
float startx; // Start of the number of consecutive lines in the direction of the x-axis
float starty; // Start of the number of consecutive lines in the direction of the y-axis
float period = 12.; // Defines the period of repetition of the number of consecutive lines

for (int i=1; i <= 40; i++)
{
startx = rad(4., 350., 999.);
starty = rad(400., 450., 999.);
snerkt(x1, x2, y1, y2, anzpkt, amplx, amply, startx, starty, period);
}

} // end of draw
void snerkt(float x1, float x2, float y1, float y2, float anzpkt, float amplx, float amply, float startx, float starty, float period)
{
float xl = min(x1,x2);
float xr = max(x1,x2);
float yu = min(y1,y2);
float yo = max(y1,y2);

float x_new = min(max(xl,startx),xr);
float y_new = min(max(yu,starty),yo);
float x_old;
float y_old;

int k = (int) rad(1.1,2.9);
int l = (int)round(abs(anzpkt)) + (int)k – 2;
float h;

for (int i = k; i <= l; i++)
{
x_old = x_new;
y_old = y_new;
h = rad(0., TWO_PI, period);
if (i % 2 == 1)
{
y_new = y_old + sin(h)*amply;
}
else
{
x_new = x_old + sin(h)*amplx;
}
if (x_new >= xr || x_new <= xl || y_new >= yo || y_new <= yu)
{
break;
}
else
{
line(x_old,y_old, x_new, y_new);
}
}
}

/*———————————————————————*/

// Methods for generating random numbers

float [] zzuf = {0., 3.1415926, 3.1415926};
float [] rrad = {0., 3.1415926, 3.1415926, -1., 3.1415926, 3.1415926};
float rrga = 3.1415926;
float pi = 3.1415926;
float e = 2.71828182;

float rad(float von, float bis)
{
zzuf[1] = amod(zzuf[1]*pi + zzuf[2],1.);
zzuf[2] = amod(zzuf[2]*e,1.) + 1.;
return zzuf[1]*abs(von – bis) + min(von,bis);
}

float rad(float von, float bis, float period)
{
float izaehl = 0.;
if (rrad[3] != period)
{
rrad[3] = period;
rrad[4] = rrad[1];
rrad[5] = rrad[2];
izaehl = 0.;
}
izaehl = izaehl + 1.;
if (izaehl >= period)
{
rrad[1] = rrad[4];
rrad[2] = rrad[5];
izaehl = 1.;
}
rrad[1] = amod(rrad[1]*pi + rrad[2],1.);
rrad[2] = amod(rrad[2]*e, 1.) + 1.;
return rrad[1]*abs(von – bis) + min(von, bis);
}

// modulo-calculation for numbers of type float

float amod (float x, float y) // calculates x modulo y
{
while ( x >= y)
{
x = x – y;
}

return x;
}

And this happens, when you use it:

snerkt_docu-final

 

Soon I there will be the documentation online. The “rad” routine makes random numbers. In this example: startx will be in the range between 4 and 350 and sequence repeating after 999 numbers

Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s