Triadic map and lines

posted by on 2013.02.19, under Processing
19:

The “triadic” discrete time dynamical system, i.e. the one obtained by iterating the function f(x)=3*x mod 1, is a very interesting one, showing a chaotic behaviour for given values of the starting point. I have used a bidimensional version of this in the following code, done with Processing: the starting point is given by (0.12,2.13), and at each iteration you have a line connecting the point at step n with the one at step n-1.
The number of points per frame is dictated by the x-position of the mouse, while the y-position controls the transparency of the lines. The x-position also controls their thickness.

float x;
float y;
float a=0.12;
float b=2.13;
float points=500;
float s;
boolean paused=true;

void setup(){
  size(400,400);
  background(255);
  }

void draw(){
if (!paused){
  points=map(mouseX,0,width,0,500);
  s=map(mouseY,0,height,0,100);
  background(255);
  translate(width/2,height/2);
  stroke(0,int(s));
  strokeWeight(int(points/100));
  for (int i=0;i<points;i++){
  x=(3*a) % 1;
  y=(3*b) % 1;
  line(map(a,0,1,-width/2,width/2),map(b,0,1,-height/2,height/2),map(x,0,1,-width/2,width/2),map(y,0,1,-height/2,height/2));
  a=x;
  b=y;
  };
};
};

void mousePressed() {
 // if paused == true make it false
 if(paused) {
  paused = false;  
 }
 // otherwise make it true
 else {
  paused = true;
 }
};

Click on the white square to start/stop the animation. 😉

There are no comments.

Please Leave a Reply

Current ye@r *

TrackBack URL :

pagetop