Van der Pol limit cycle - 2D nonlinear attractor

Dependencies:   mbed

Committer:
JLS
Date:
Wed Feb 09 22:35:32 2011 +0000
Revision:
0:964911ed238a

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JLS 0:964911ed238a 1 #include "TFT_4DGL.h"
JLS 0:964911ed238a 2
JLS 0:964911ed238a 3 TFT_4DGL lcd(p9,p10,p11);
JLS 0:964911ed238a 4
JLS 0:964911ed238a 5 int main() {
JLS 0:964911ed238a 6
JLS 0:964911ed238a 7 int xp,yp;
JLS 0:964911ed238a 8
JLS 0:964911ed238a 9 int n = WHITE;
JLS 0:964911ed238a 10
JLS 0:964911ed238a 11 float x,y,xn,yn;
JLS 0:964911ed238a 12
JLS 0:964911ed238a 13 float dt = 0.314;
JLS 0:964911ed238a 14
JLS 0:964911ed238a 15 float x1 = 0.01;
JLS 0:964911ed238a 16 float y1 = 0.01;
JLS 0:964911ed238a 17
JLS 0:964911ed238a 18 x = x1;
JLS 0:964911ed238a 19 y = y1;
JLS 0:964911ed238a 20
JLS 0:964911ed238a 21 while(1)
JLS 0:964911ed238a 22
JLS 0:964911ed238a 23 {
JLS 0:964911ed238a 24
JLS 0:964911ed238a 25 xn = y1;
JLS 0:964911ed238a 26 yn = (1-(x1*x1))*y1-x1;
JLS 0:964911ed238a 27
JLS 0:964911ed238a 28 x = x+xn*dt;
JLS 0:964911ed238a 29 y = y+yn*dt;
JLS 0:964911ed238a 30
JLS 0:964911ed238a 31 xp = (int)floor(x*50);
JLS 0:964911ed238a 32 yp = (int)floor(y*35);
JLS 0:964911ed238a 33
JLS 0:964911ed238a 34 lcd.pixel(120+yp,160+xp,n);
JLS 0:964911ed238a 35
JLS 0:964911ed238a 36 x1 = x;
JLS 0:964911ed238a 37 y1 = y;
JLS 0:964911ed238a 38
JLS 0:964911ed238a 39 }
JLS 0:964911ed238a 40
JLS 0:964911ed238a 41 }