/* wobblemovie.c Oliver Knill, Austin, TX, February 8, 2000 */ #include #include #include #include #include // initialisation of rand #define N_BODIES 120 // number of bodies to evolve #define N_MAX 1000 // number of frames in movie #define FILE_INDEX(x) ((x) < 10) ? "00" : (((x) < 100) ? "0" : ""), (x) #define ERR "/dev/null" typedef float particlearray[N_BODIES][3]; // position and typedef float momentumarray[N_BODIES][3]; // momentum of bodies typedef float distancearray[N_BODIES][N_BODIES];// distance array of particles particlearray position; particlearray momentum; distancearray distance; /*---------------------------------------------------------------------------*/ /* function random number generator */ /*---------------------------------------------------------------------------*/ void initialize_number_generator(void) { srand((unsigned) time(NULL)); } float R(void) { return(1.0*random()/RAND_MAX); // Random number in [0,1] } float pow2(float a) { return(a*a); } /*---------------------------------------------------------------------------*/ /* function update_distance */ /*---------------------------------------------------------------------------*/ void update_distances(void){ int i,j; for (i=0; i up y right (4/3)*x look_at <0,0,5> }\n" "light_source { <-100,50,-200> color rgb <1,1,1> } \n" "light_source { <100,-50,-200> color rgb <1,1,0> } \n" "#macro d(xx,yy,zz,rr) \n" " sphere { ,rr,rr } \n" "#end \n" "blob { \n" "threshold " "%f\n" "#declare i=0; \n",f); for (i=0; i}" "finish { phong 1 }\n" "} \n"); fclose(pov); printf("Running povray on %s",povfile); sprintf(run,"povray good.ini %s;",povfile); system(run); } /*---------------------------------------------------------------------------*/ /* Function `main' */ /*---------------------------------------------------------------------------*/ int main() { int i = 0, n_max = N_MAX; char run[256]; initialize_number_generator(); initialize_array(); for(i = 1; i < n_max; i++) { make_wobble(i,run); evolve_particles(); } printf("All done.\n"); return 0; }