Popcorn fractal map

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     float h = 0.05;
00008 
00009     int iter = 0;
00010     int maxiter = 5000;
00011 
00012     float x = 0.5;
00013     float y = 0;
00014 
00015     int xout = 0;
00016     int yout = 0;
00017  
00018  while (1) {
00019  
00020     double oldX = x;
00021     double oldY = y;
00022   
00023     x = oldX-h*sin(oldY+tan(3*oldY));
00024     y = oldY-h*sin(oldX+tan(3*oldX));
00025   
00026   iter++;
00027   
00028   if (iter == maxiter) {
00029   
00030     iter = 0;
00031     x=0.5;
00032     y=0;
00033     lcd.cls();
00034     
00035   }
00036             
00037   xout = 50+(x*35);
00038   yout = 120+(y*35);
00039   
00040     lcd.pixel(yout,xout,WHITE);
00041 
00042 }
00043 }