Mira-Gumowski fractal

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  a,c;
00008     double  x,y,f,xa,ya;
00009 
00010     int xout = 0;
00011     int yout = 0;
00012     int n = WHITE;
00013     int m = 0;
00014     
00015     a = -0.6624;
00016 
00017     xa = 14.7176;
00018     ya = -14.6602;
00019     
00020     c = 2*(1-a);
00021     f = a*xa+c*xa*xa/(1+xa*xa);
00022  
00023  while (1) {
00024  
00025     x = f+1*ya;
00026     f = a*x+c*x*x/(1+x*x);
00027     y = f-xa;
00028     
00029     m++;
00030     
00031     if (m==300) {
00032     
00033     m = 0;
00034     
00035     n = rand();
00036     
00037     }
00038   
00039     xout = 110+(x*3);
00040     yout = 160+(y*5);
00041    
00042     lcd.pixel(xout,yout,n);
00043     
00044     xa = x;
00045     ya = y;
00046 }
00047 }