#include #include #include #include using namespace std; #define NP 400 #define AGE 200 float winWid,winHeight; float rx,ry; float x[NP], y[NP]; // the particles //This example implements a simple particle tracing system as a //starting point for assignment 1 void getVec(float X,float Y, float &dx,float &dy) // this is the Differential Equation that defines the flow { X *= 0.8; Y *= 0.9; dx = 0.5 + sin(0.12*Y) ; dy = 4.0*sin(0.6*sqrt(X))*cos(Y*0.03) + 2.7*sin(0.015*X)*(1.0*0.5*cos(Y/50.0)) + 0.02*(Y-200); } void initParticles() { // Sets up a set of random start positions int i; for (i=0;i (winWid-1.0)) x[i] = 0; // wrap around; if (x[i] < 0.0) x[i] = winWid-1.0; if (y[i] > (winHeight-1.0)) y[i] = 0; // wrap around; if (y[i] < 0.0) y[i] = winHeight-1.0; } } void redraw( void ) { int i; initParticles(); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0,1.0,0.0); glRectf(100.0,100.0,300.0,200.0); // to be removed for(i=0;i