
Halvorsen chaotic attractor
main.cpp@0:5eff962a611d, 2011-01-02 (annotated)
- Committer:
- JLS
- Date:
- Sun Jan 02 11:13:51 2011 +0000
- Revision:
- 0:5eff962a611d
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JLS | 0:5eff962a611d | 1 | #include "TFT_4DGL.h" |
JLS | 0:5eff962a611d | 2 | |
JLS | 0:5eff962a611d | 3 | TFT_4DGL lcd(p9,p10,p11); |
JLS | 0:5eff962a611d | 4 | |
JLS | 0:5eff962a611d | 5 | int main() { |
JLS | 0:5eff962a611d | 6 | |
JLS | 0:5eff962a611d | 7 | double x1,y1,z1,x,y,z,t,dt; |
JLS | 0:5eff962a611d | 8 | int xp,yp; |
JLS | 0:5eff962a611d | 9 | |
JLS | 0:5eff962a611d | 10 | float a = 1.4; |
JLS | 0:5eff962a611d | 11 | |
JLS | 0:5eff962a611d | 12 | x1 = -5; |
JLS | 0:5eff962a611d | 13 | y1 = 0; |
JLS | 0:5eff962a611d | 14 | z1 = 0; |
JLS | 0:5eff962a611d | 15 | |
JLS | 0:5eff962a611d | 16 | dt = 0.005; |
JLS | 0:5eff962a611d | 17 | |
JLS | 0:5eff962a611d | 18 | while(1) |
JLS | 0:5eff962a611d | 19 | |
JLS | 0:5eff962a611d | 20 | { |
JLS | 0:5eff962a611d | 21 | |
JLS | 0:5eff962a611d | 22 | x = x1+(-a*x1-4*y1-4*z1-pow(y1,2))*dt; |
JLS | 0:5eff962a611d | 23 | y = y1+(-a*y1-4*z1-4*x1-pow(z1,2))*dt; |
JLS | 0:5eff962a611d | 24 | z = z1+(-a*z1-4*x1-4*y1-pow(x1,2))*dt; |
JLS | 0:5eff962a611d | 25 | t = t+dt; |
JLS | 0:5eff962a611d | 26 | |
JLS | 0:5eff962a611d | 27 | xp = 210+(int)floor(13*x); |
JLS | 0:5eff962a611d | 28 | yp = 155+(int)floor(9*y); |
JLS | 0:5eff962a611d | 29 | |
JLS | 0:5eff962a611d | 30 | lcd.pixel(yp,xp,WHITE); |
JLS | 0:5eff962a611d | 31 | |
JLS | 0:5eff962a611d | 32 | x1 = x; |
JLS | 0:5eff962a611d | 33 | y1 = y; |
JLS | 0:5eff962a611d | 34 | z1 = z; |
JLS | 0:5eff962a611d | 35 | |
JLS | 0:5eff962a611d | 36 | } |
JLS | 0:5eff962a611d | 37 | |
JLS | 0:5eff962a611d | 38 | } |