Lorenz limit cycle - 2D nonlinear 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,xn,yn;
00012 
00013      float dt = 0.55;
00014   
00015      float x1 = 0.1;
00016      float y1 = 0;
00017      
00018      x = x1;
00019      y = y1;
00020 
00021     while(1)
00022     
00023     {
00024     
00025         xn = x1-y1-pow(x1,3);
00026         yn = x1-(x1*x1)*y1;
00027         
00028         x = x+xn*dt;
00029         y = y+yn*dt;
00030 
00031         xp = (int)floor(x*65);
00032         yp = (int)floor(y*110);
00033 
00034         lcd.pixel(120+xp,160+yp,n);
00035      
00036         x1 = x;
00037         y1 = y;
00038         
00039     }
00040  
00041 }