Rikitake chaotic system

Dependencies:   mbed

main.cpp

Committer:
JLS
Date:
2011-03-02
Revision:
0:0e1b2bdda33f

File content as of revision 0:0e1b2bdda33f:

#include "TFT_4DGL.h"

TFT_4DGL lcd(p9,p10,p11);

int main() {

     int   xp,yp;
     
     int n = WHITE;
   
     float x,y,z;
     
     float a = 2;
     float s = 10;
     float u = 2.1;

     float dt = 0.005;
  
     float x1 = 0.1;
     float y1 = 0.1;
     float z1 = 0.1;
     
     x = x1;
     y = y1;
     z = z1;

    while(1)
    
    {
    
        x = x1+(-u*x1+s*y1*z1)*dt;
        y = y1+(-u*y1+(s*z1-a)*x1)*dt;
        z = z1+(1-s*x1*y1)*dt;

        xp = (int)floor(x*85);
        yp = (int)floor(y*75);

        lcd.pixel(120+yp,160+xp,n);
     
        x1 = x;
        y1 = y;
        z1 = z;

    }
 
}