#include #include #include #include #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 // for the assignment substitute the Pacific data set { X* = 0.5; Y = Y*0.9 - 0.05; dx = 0.5 + sin(0.12*Y) ; dy = 0.4* sin(0.4*X)+ 2.5*sin(0.1*X) +4.0*sin(0.06*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;igetVec(x[i]/winWid,y[i]/winHeight,dx,dy); //vel = sqrt(dx*dx + dy*dy)/10.0; // the magnitude x[i] += 0.1*dx; // how far does the particle move y[i] += 0.1*dy; //g = vel*2; //g = float(j)/AGE; //glColor3f(g,g,g); glPushMatrix(); glTranslatef(x[i],y[i],0.0); /circ->Filled(1.0); glRectf(-2.0,-2.0,2.0,2.0); glPopMatrix(); if (x[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