Simple chaotic flow attractor

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "TFT_4DGL.h"
00002 
00003 TFT_4DGL lcd(p9,p10,p11);
00004 
00005 int main() {
00006 
00007      int   xp,yp;
00008      
00009      int n = WHITE;
00010    
00011      float x,y,z,xn,yn,zn;
00012 
00013      float dt = 0.05;
00014   
00015      float x1 = 0.1;
00016      float y1 = 0;
00017      float z1 = 0;
00018 
00019 
00020     while(1)
00021     
00022     {
00023     
00024         xn = -y1+(z1*z1);
00025         yn = x1+0.43*y1;
00026         zn = x1-z1;
00027 
00028         x = x+xn*dt;
00029         y = y+yn*dt;
00030         z = z+zn*dt;
00031         
00032 
00033         xp = (int)floor(x*32);
00034         yp = (int)floor(y*48);
00035 
00036         lcd.pixel(170+xp,60+yp,n);
00037      
00038         x1 = x;
00039         y1 = y;
00040         z1 = z;
00041         
00042     }
00043  
00044 }