Files Classes Functions Hierarchy
#include <cassert>#include <iostream>#include <GL/glut.h>#include <GL/glu.h>#include <GL/gl.h>#include <boxcollision.h>#include <cell.h>#include <commandline.h>#include <d2toindex.h>#include <graphmisc.h>#include <histogram.h>#include <integration.h>#include <particle.h>#include <particledisp.h>#include <particleranvd.h>#include <particlesampler.h>#include <zpr.h>
Go to the source code of this file.
Functions | |
| void | animate () |
| void | display () |
| void | reshape (int w, int h) |
| void | keyboard (unsigned char key, int x, int y) |
| void | test01 (int argc, char **argv) |
| void | test02 (int argc, char **argv) |
| void | test03 (int argc, char **argv) |
| int | main (int argc, char **argv) |
Variables | |
| integration< particlev0spaced, d2toindex > | G |
| void animate | ( | ) |
Definition at line 34 of file main.cpp.
References integration< D, F >::fr, integration< D, F >::run, integration< D, F >::step(), integration< D, F >::stepcount, integration< D, F >::stepcountmsg, framerate< period >::update(), and gltextmsg::updatevalue().
Referenced by test01().
00035 { 00036 if (G.run) 00037 G.step(); 00038 00039 G.fr.update(); 00040 G.stepcountmsg.updatevalue("stepcount: ",G.stepcount); 00041 glutPostRedisplay(); 00042 }
| void display | ( | ) |
Definition at line 45 of file main.cpp.
References integration< D, F >::draw().
00046 { 00047 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 00048 glPushMatrix(); 00049 00050 glDisable(GL_LIGHTING); 00051 //axes(10.0); 00052 00053 G.draw(); 00054 00055 00056 00057 glPopMatrix(); 00058 glutSwapBuffers(); 00059 }
| void keyboard | ( | unsigned char | key, | |
| int | x, | |||
| int | y | |||
| ) |
Definition at line 73 of file main.cpp.
References integration< D, F >::step(), integration< D, F >::steplarge(), and integration< D, F >::togglestartstop().
00078 { 00079 switch (key) 00080 { 00081 case 27: 00082 exit(0); 00083 break; 00084 case 'h': 00085 G.step(); 00086 break; 00087 case 'H': 00088 G.steplarge(); 00089 break; 00090 case 's': 00091 case 'S': 00092 G.togglestartstop(); 00093 break; 00094 00095 } 00096 }
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 250 of file main.cpp.
References commandline::mapvar(), test01(), and test02().
00251 { 00252 commandline c(argc,argv); 00253 bool benchmark(false); 00254 c.mapvar(benchmark,"benchmark"); 00255 00256 if (benchmark) 00257 test02(argc,argv); 00258 else 00259 test01(argc,argv); 00260 00261 00262 00263 return 0; 00264 }
| void reshape | ( | int | w, | |
| int | h | |||
| ) |
Definition at line 61 of file main.cpp.
Referenced by maze005::reshape01(), maze004::reshape01(), and test01().
00062 { 00063 glViewport(0, 0, w, h); 00064 glMatrixMode(GL_PROJECTION); 00065 glLoadIdentity(); 00066 00067 glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0); 00068 glMatrixMode(GL_MODELVIEW); 00069 glLoadIdentity(); 00070 }
| void test01 | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 99 of file main.cpp.
References animate(), display(), keyboard(), camera::lookat(), commandline::mapvar(), integration< D, F >::reset(), reshape(), and zpr::update().
00100 { 00101 glutInit(&argc, argv); 00102 glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 00103 glutInitWindowSize(600, 600); 00104 glutCreateWindow("Collision Detection and Dynamics: Particles in an Arena"); 00105 glutDisplayFunc(display); 00106 glutIdleFunc(animate); 00107 glutReshapeFunc(reshape); 00108 glutKeyboardFunc(keyboard); 00109 00110 G.reset(argc,argv); 00111 00112 zpr zz; 00113 00114 zz.update(); 00115 00116 commandline cmd(argc,argv); 00117 00118 double angle=20.0; 00119 double near=1.0; 00120 double far=100.0; 00121 uint choice(2); 00122 cmd.mapvar(choice,"choice"); 00123 cmd.mapvar(angle,"angle"); 00124 cmd.mapvar(near,"near"); 00125 cmd.mapvar(far,"far"); 00126 00127 double left=-1.0; 00128 double right=1.0; 00129 double bottom=-1.0; 00130 double top=1.0; 00131 00132 cmd.mapvar(left,"left"); 00133 cmd.mapvar(right,"right"); 00134 cmd.mapvar(bottom,"bottom"); 00135 cmd.mapvar(top,"top"); 00136 00137 if (choice!=0) 00138 { 00139 glMatrixMode(GL_PROJECTION); 00140 glLoadIdentity(); 00141 } 00142 00143 switch( choice ) 00144 { 00145 case 0: break; 00146 case 1: 00147 glFrustum(left,right,bottom,top,near,far); break; 00148 case 2: camera::lookat(cmd,4.8,4.7,5.6); break; 00149 // Can over-ride with 00150 // $./main choice=2 camerax=2.0 cameray=.4 cameraz=4.0 00151 // whatever numbers you want 00152 case 3: gluPerspective(angle,1.0,near,far); break; 00153 default: break; 00154 } 00155 00156 if (choice!=0) 00157 { 00158 glMatrixMode(GL_MODELVIEW); 00159 } 00160 00161 double eyex(0.0); 00162 double eyey(0.0); 00163 double eyez(0.0); 00164 cmd.mapvar(eyex,"eyex"); 00165 cmd.mapvar(eyey,"eyey"); 00166 cmd.mapvar(eyez,"eyez"); 00167 glTranslated(eyex,eyey,eyez); 00168 00169 glutPostRedisplay(); 00170 00171 glutMainLoop(); 00172 }
| void test02 | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 179 of file main.cpp.
References integration< D, F >::bruteforce(), commandline::mapvar(), integration< D, F >::numParticles, integration< D, F >::reset(), SHOW, integration< D, F >::uniform, and integration< D, F >::uniformgridtest().
00180 { 00181 int const milli = 1000; 00182 uint N = 1000; 00183 commandline c(argc,argv); 00184 c.mapvar(N,"N"); 00185 c.mapvar(G.uniform,"uniform"); 00186 c.mapvar(G.numParticles,"numParticles"); 00187 00188 G.reset(argc,argv); 00189 00190 float startTime = glutGet(GLUT_ELAPSED_TIME) / (float)milli; 00191 if (!G.uniform) 00192 { 00193 for (uint i=0; i<N; ++i) 00194 G.bruteforce(); 00195 } 00196 else 00197 { 00198 for (uint i=0; i<N; ++i) 00199 G.uniformgridtest(); 00200 } 00201 00202 float elapsedTime = glutGet(GLUT_ELAPSED_TIME) / (float)milli - startTime; 00203 cout << SHOW(elapsedTime) << endl; 00204 }
| void test03 | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 206 of file main.cpp.
References particledistribution::box, cell::eval(), d2toindex::getsurroundingcells(), d2toindex::index(), particledistribution::randomposition(), d2toindex::reset(), and d2toindex::W.
00207 { 00208 particlev0theta0 D 00209 ( 00210 0.2, //radius 00211 1.0, //vmax 00212 boxcollision(0.0,10.0,0.0,10.0) //box dimensions 00213 ); 00214 00215 uintc N(8); 00216 particle pi[N]; 00217 d2toindex f2(pi,D.box); 00218 f2.reset(); 00219 uint W = (uint)( sqrt((double)N) )+1; 00220 f2.W = W; 00221 00222 for (uint i=0; i<N; ++i) 00223 { 00224 D.randomposition(pi[i]); 00225 cout << pi[i]; 00226 cout << endl; 00227 cout << " indx=" << f2.index(i) << endl; 00228 } 00229 00230 cout << endl << endl; 00231 00232 cell C(N); 00233 C.eval(f2); 00234 00235 uint * nb; 00236 uint sz; 00237 for (uint i=0; i<W*W; ++i) 00238 { 00239 f2.getsurroundingcells(nb,sz,i); 00240 cout << "i=" << i << " "; 00241 for (uint k=0; k<sz; ++k) 00242 cout << nb[k] << " "; 00243 cout << endl; 00244 } 00245 00246 }
1.5.8