Mira-Gumowski fractal

Dependencies:   mbed

Committer:
JLS
Date:
Sat Jan 15 20:23:44 2011 +0000
Revision:
0:e3b22c15d05a

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JLS 0:e3b22c15d05a 1 #include "TFT_4DGL.h"
JLS 0:e3b22c15d05a 2
JLS 0:e3b22c15d05a 3 TFT_4DGL lcd(p9,p10,p11);
JLS 0:e3b22c15d05a 4
JLS 0:e3b22c15d05a 5 int main() {
JLS 0:e3b22c15d05a 6
JLS 0:e3b22c15d05a 7 double a,c;
JLS 0:e3b22c15d05a 8 double x,y,f,xa,ya;
JLS 0:e3b22c15d05a 9
JLS 0:e3b22c15d05a 10 int xout = 0;
JLS 0:e3b22c15d05a 11 int yout = 0;
JLS 0:e3b22c15d05a 12 int n = WHITE;
JLS 0:e3b22c15d05a 13 int m = 0;
JLS 0:e3b22c15d05a 14
JLS 0:e3b22c15d05a 15 a = -0.6624;
JLS 0:e3b22c15d05a 16
JLS 0:e3b22c15d05a 17 xa = 14.7176;
JLS 0:e3b22c15d05a 18 ya = -14.6602;
JLS 0:e3b22c15d05a 19
JLS 0:e3b22c15d05a 20 c = 2*(1-a);
JLS 0:e3b22c15d05a 21 f = a*xa+c*xa*xa/(1+xa*xa);
JLS 0:e3b22c15d05a 22
JLS 0:e3b22c15d05a 23 while (1) {
JLS 0:e3b22c15d05a 24
JLS 0:e3b22c15d05a 25 x = f+1*ya;
JLS 0:e3b22c15d05a 26 f = a*x+c*x*x/(1+x*x);
JLS 0:e3b22c15d05a 27 y = f-xa;
JLS 0:e3b22c15d05a 28
JLS 0:e3b22c15d05a 29 m++;
JLS 0:e3b22c15d05a 30
JLS 0:e3b22c15d05a 31 if (m==300) {
JLS 0:e3b22c15d05a 32
JLS 0:e3b22c15d05a 33 m = 0;
JLS 0:e3b22c15d05a 34
JLS 0:e3b22c15d05a 35 n = rand();
JLS 0:e3b22c15d05a 36
JLS 0:e3b22c15d05a 37 }
JLS 0:e3b22c15d05a 38
JLS 0:e3b22c15d05a 39 xout = 110+(x*3);
JLS 0:e3b22c15d05a 40 yout = 160+(y*5);
JLS 0:e3b22c15d05a 41
JLS 0:e3b22c15d05a 42 lcd.pixel(xout,yout,n);
JLS 0:e3b22c15d05a 43
JLS 0:e3b22c15d05a 44 xa = x;
JLS 0:e3b22c15d05a 45 ya = y;
JLS 0:e3b22c15d05a 46 }
JLS 0:e3b22c15d05a 47 }