Kamil Ondrousek
/
Popcorn
Popcorn fractal map
main.cpp@0:732044ed2f1d, 2010-12-25 (annotated)
- Committer:
- JLS
- Date:
- Sat Dec 25 20:01:32 2010 +0000
- Revision:
- 0:732044ed2f1d
- Child:
- 1:77a27904e76e
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JLS | 0:732044ed2f1d | 1 | #include "TFT_4DGL.h" |
JLS | 0:732044ed2f1d | 2 | |
JLS | 0:732044ed2f1d | 3 | TFT_4DGL lcd(p9,p10,p11); |
JLS | 0:732044ed2f1d | 4 | |
JLS | 0:732044ed2f1d | 5 | int main() { |
JLS | 0:732044ed2f1d | 6 | |
JLS | 0:732044ed2f1d | 7 | float h = 0.05; |
JLS | 0:732044ed2f1d | 8 | |
JLS | 0:732044ed2f1d | 9 | int iter = 0; |
JLS | 0:732044ed2f1d | 10 | int maxiter = 5000; |
JLS | 0:732044ed2f1d | 11 | |
JLS | 0:732044ed2f1d | 12 | float x = 0.5; |
JLS | 0:732044ed2f1d | 13 | float y = 0; |
JLS | 0:732044ed2f1d | 14 | |
JLS | 0:732044ed2f1d | 15 | int xout = 0; |
JLS | 0:732044ed2f1d | 16 | int yout = 0; |
JLS | 0:732044ed2f1d | 17 | |
JLS | 0:732044ed2f1d | 18 | lcd.baudrate(600000); |
JLS | 0:732044ed2f1d | 19 | |
JLS | 0:732044ed2f1d | 20 | while (1) { |
JLS | 0:732044ed2f1d | 21 | |
JLS | 0:732044ed2f1d | 22 | double oldX = x; |
JLS | 0:732044ed2f1d | 23 | double oldY = y; |
JLS | 0:732044ed2f1d | 24 | |
JLS | 0:732044ed2f1d | 25 | x = oldX-h*sin(oldY+tan(3*oldY)); |
JLS | 0:732044ed2f1d | 26 | y = oldY-h*sin(oldX+tan(3*oldX)); |
JLS | 0:732044ed2f1d | 27 | |
JLS | 0:732044ed2f1d | 28 | iter++; |
JLS | 0:732044ed2f1d | 29 | |
JLS | 0:732044ed2f1d | 30 | if (iter == maxiter) { |
JLS | 0:732044ed2f1d | 31 | |
JLS | 0:732044ed2f1d | 32 | iter = 0; |
JLS | 0:732044ed2f1d | 33 | x=0.5; |
JLS | 0:732044ed2f1d | 34 | y=0; |
JLS | 0:732044ed2f1d | 35 | lcd.cls(); |
JLS | 0:732044ed2f1d | 36 | |
JLS | 0:732044ed2f1d | 37 | } |
JLS | 0:732044ed2f1d | 38 | |
JLS | 0:732044ed2f1d | 39 | xout = 50+(x*35); |
JLS | 0:732044ed2f1d | 40 | yout = 120+(y*35); |
JLS | 0:732044ed2f1d | 41 | |
JLS | 0:732044ed2f1d | 42 | lcd.pixel(yout,xout,WHITE); |
JLS | 0:732044ed2f1d | 43 | |
JLS | 0:732044ed2f1d | 44 | } |
JLS | 0:732044ed2f1d | 45 | } |