Quadratic 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     double x1,y1,z1,x,y,z,dt;
00008     int   xp,yp;
00009    
00010     float a = 2.017;
00011 
00012     x1 = -0.9;
00013     y1 = 0;
00014     z1 = 0.5;
00015     
00016     dt = 0.01;
00017 
00018     while(1)
00019     
00020     {
00021     
00022         x = x1+(y1)*dt;
00023         y = y1+(z1)*dt;
00024         z = z1+(-a*z1+pow(y1,2)-x1)*dt;
00025 
00026         xp = 55+(int)floor(34*x);
00027         yp = 135+(int)floor(39*y);
00028 
00029         lcd.pixel(yp,xp,WHITE);
00030       
00031         x1 = x;
00032         y1 = y;
00033         z1 = z;
00034 
00035     }
00036  
00037 }