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