proj home

Files   Classes   Functions   Hierarchy  

diskinttest Class Reference

Disk intersection tests. More...

#include <diskinttest.h>

Collaboration diagram for diskinttest:

List of all members.

Public Member Functions

void test01 (int &argc, char **argv)
 Disk and plane intersection.
void test02 (int &argc, char **argv)
 Disk and disk intersection.
void test03 (int &argc, char **argv)
 Cylinder and cylinder intersection.

Static Public Member Functions

static void display01 ()
 Display handler.
static void keyboard01 (unsigned char key, int x, int y)
 Keyboard handler for test01.
static void keyboard02 (unsigned char key, int x, int y)
 Keyboard handler for test02.
static void keyboard03 (unsigned char key, int x, int y)
 Keyboard handler for test03.
static void update01 ()
static void update02 ()
static void update03 ()
static void update03lineline ()

Public Attributes

gobjContainer xGraphics
 Global graphics container.

Static Public Attributes

static diskD1ptr
static diskD2ptr
static planeP1ptr
static gobjMyCircleDrawD1cd
static gobjMyCircleDrawD2cd
static gobjContainerdiskintersection
 Holds the intersection graphics for test02.
static cylinderC1ptr
static cylinderC2ptr
static gobjContainercylinderintersection
static bool cylinderscollide = false
static gobjgluCylinderC1cd
static gobjgluCylinderC2cd
static float transparency = 0.6
static boolhelp = 0
 Toggle the help menu.


Detailed Description

Disk intersection tests.

Definition at line 13 of file diskinttest.h.


Member Function Documentation

void diskinttest::display01 (  )  [static]

Display handler.

Definition at line 37 of file diskinttest.cpp.

References gobjContainer::draw(), glerrordisplay(), and gobj::global.

Referenced by test01(), test02(), and test03().

00038 {
00039   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
00040 
00041   gobj::global->draw();
00042 
00043   glerrordisplay();
00044   
00045   glutSwapBuffers();
00046 }

void diskinttest::keyboard01 ( unsigned char  key,
int  x,
int  y 
) [static]

Keyboard handler for test01.

Definition at line 48 of file diskinttest.cpp.

References D1ptr, delta, disk::nml, disk::pos, update01(), point3< T >::x, point3< T >::y, and point3< T >::z.

Referenced by test01().

00049 {
00050   static double delta = 0.1;
00051   static bool mode=true;
00052 
00053   switch (key)
00054   {
00055     case 27:
00056       exit(0);
00057       break;
00058     case 'j': 
00059       if (mode)
00060         D1ptr->pos.x += delta; 
00061       else
00062         D1ptr->nml.x += delta;
00063     break;
00064     case 'J': 
00065       if (mode)
00066         D1ptr->pos.x -= delta; 
00067       else
00068         D1ptr->nml.x -= delta;
00069     break;
00070 
00071     case 'k': 
00072       if (mode)
00073         D1ptr->pos.y += delta; 
00074       else
00075         D1ptr->nml.y += delta;
00076       break;
00077     case 'K': 
00078       if (mode)
00079         D1ptr->pos.y -= delta; 
00080       else
00081         D1ptr->nml.y -= delta; 
00082 
00083       break;
00084 
00085     case 'l': 
00086       if (mode)
00087         D1ptr->pos.z += delta; 
00088       else
00089         D1ptr->nml.z += delta; 
00090       break;
00091     case 'L': 
00092       if (mode)
00093         D1ptr->pos.z -= delta; 
00094       else
00095         D1ptr->nml.z -= delta; 
00096       break;
00097     
00098     case '+': delta *= 10.0; if (delta==0.0) delta=0.1; break;
00099     case '-': delta /= 10.0; break;
00100 
00101     case 'm': mode = !mode; break;
00102 
00103     case 'p':
00104       cout << (stringc)*D1ptr << endl;
00105       break;
00106   }
00107 
00108   update01();
00109   glutPostRedisplay();
00110 }

void diskinttest::keyboard02 ( unsigned char  key,
int  x,
int  y 
) [static]

Keyboard handler for test02.

Definition at line 253 of file diskinttest.cpp.

References D1ptr, D2ptr, delta, help, disk::nml, disk::pos, disk::radius, update02(), point3< T >::x, point3< T >::y, and point3< T >::z.

Referenced by test02().

00254 {
00255   static double delta = 0.1;
00256   static bool mode=true;
00257 
00258   switch (key)
00259   {
00260     case 27:
00261       exit(0);
00262       break;
00263 
00264     case 'j': 
00265       if (mode)
00266         D2ptr->pos.x += delta; 
00267       else
00268         D2ptr->nml.x += delta;
00269     break;
00270     case 'J': 
00271       if (mode)
00272         D2ptr->pos.x -= delta; 
00273       else
00274         D2ptr->nml.x -= delta;
00275     break;
00276 
00277     case 'k': 
00278       if (mode)
00279         D2ptr->pos.y += delta; 
00280       else
00281         D2ptr->nml.y += delta;
00282       break;
00283     case 'K': 
00284       if (mode)
00285         D2ptr->pos.y -= delta; 
00286       else
00287         D2ptr->nml.y -= delta;
00288       break;
00289 
00290     case 'l': 
00291       if (mode)
00292         D2ptr->pos.z += delta; 
00293       else
00294         D2ptr->nml.z += delta;
00295       break;
00296     case 'L': 
00297       if (mode)
00298         D2ptr->pos.z -= delta; 
00299       else
00300         D2ptr->nml.z -= delta;
00301       break;
00302     
00303     case '+': delta *= 10.0; if (delta==0.0) delta=0.1; break;
00304     case '-': delta /= 10.0; break;
00305 
00306     case 'm': mode = !mode; break;
00307 
00308     case 'p':
00309       cout << (stringc)*D1ptr << endl;
00310       cout << (stringc)*D2ptr << endl;
00311       break;
00312 
00313     case 'x': D2ptr->radius += delta; break;
00314     case 'X': D2ptr->radius -= delta; break;
00315 
00316     case 'h': if (help!=0) *help = !*help; break;
00317       
00318   
00319   }
00320   update02();
00321   glutPostRedisplay();
00322 }

void diskinttest::keyboard03 ( unsigned char  key,
int  x,
int  y 
) [static]

Keyboard handler for test03.

Definition at line 479 of file diskinttest.cpp.

References C1ptr, C2ptr, delta, help, cylinder::nml, cylinder::pos, cylinder::radius, transparency, unitbound(), update03(), point3< T >::x, point3< T >::y, and point3< T >::z.

Referenced by test03().

00480 {
00481   static double delta = 0.1;
00482   static bool mode=true;
00483 
00484   switch (key)
00485   {
00486     case 27:
00487       exit(0);
00488       break;
00489 
00490     case 't':
00491       transparency += delta;
00492       unitbound(transparency);
00493       break;
00494     case 'T':
00495       transparency -= delta;
00496       unitbound(transparency);
00497       break;
00498 
00499     case 'j': 
00500       if (mode)
00501         C1ptr->pos.x += delta; 
00502       else
00503         C1ptr->nml.x += delta;
00504     break;
00505     case 'J': 
00506       if (mode)
00507         C1ptr->pos.x -= delta; 
00508       else
00509         C1ptr->nml.x -= delta;
00510     break;
00511     case 'k': 
00512       if (mode)
00513         C1ptr->pos.y += delta; 
00514       else
00515         C1ptr->nml.y += delta;
00516       break;
00517     case 'K': 
00518       if (mode)
00519         C1ptr->pos.y -= delta; 
00520       else
00521         C1ptr->nml.y -= delta;
00522       break;
00523     case 'l': 
00524       if (mode)
00525         C1ptr->pos.z += delta; 
00526       else
00527         C1ptr->nml.z += delta;
00528       break;
00529     case 'L': 
00530       if (mode)
00531         C1ptr->pos.z -= delta; 
00532       else
00533         C1ptr->nml.z -= delta;
00534       break;
00535     
00536     case '+': delta *= 10.0; if (delta==0.0) delta=0.1; break;
00537     case '-': delta /= 10.0; break;
00538 
00539     case 'm': mode = !mode; break;
00540 
00541     case 'p':
00542       cout << (stringc)*C1ptr << endl;
00543       cout << (stringc)*C2ptr << endl;
00544       break;
00545 
00546     case 'x': C1ptr->radius += delta; break;
00547     case 'X': C1ptr->radius -= delta; break;
00548 
00549     case 'h': if (help!=0) *help = !*help; break;
00550   }
00551 
00552   update03();
00553   glutPostRedisplay();
00554 }

void diskinttest::test01 ( int &  argc,
char **  argv 
)

Disk and plane intersection.

Definition at line 112 of file diskinttest.cpp.

References menusystem::addfont10(), menusystem::addfont12(), menusystem::addnewline(), pointsurface< T, G >::addsurface2D(), D1cd, D1ptr, diskintersection, display01(), gobjpush, keyboard01(), commandline::mapvar(), disk::nml, P1ptr, disk::pos, gobjContainerPrePost::pre, gobjContainer::push(), disk::radius, gobjContainer::set(), zpr::update(), update01(), point3< T >::x, xGraphics, point3< T >::y, and point3< T >::z.

00113 {
00114   glutInit(&argc,argv);
00115   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00116   glutInitWindowSize(800,600);
00117   glutCreateWindow("");
00118   glutDisplayFunc(display01);
00119   glutKeyboardFunc(keyboard01);
00120 
00121   OpenGLinitialisation();
00122 
00123   glEnable(GL_DEPTH_TEST);
00124   glEnable(GL_CULL_FACE);
00125   glEnable(GL_NORMALIZE);
00126 
00127   zpr zz;
00128 
00129   xGraphics.set();
00130 
00131   commandline cmd(argc,argv);
00132 
00133   string in;
00134 
00135   cmd.mapvar(in,"in");
00136   if ( in.empty() )
00137   {
00138     cout << "error: in=filename expected" << endl;
00139     return;
00140   }
00141 
00142   ifstream filein(in.c_str());
00143   assert(filein.good()==true);
00144   if (filein.good()==false)
00145     return;
00146 
00147   point3<double> nml;
00148   point3<double> pos;
00149   double radius;
00150   double d;
00151 
00152   filein >> nml.x;
00153   filein >> nml.y;
00154   filein >> nml.z;
00155   filein >> pos.x;
00156   filein >> pos.y;
00157   filein >> pos.z;
00158   filein >> radius;
00159 
00160   disk D1(nml,pos,radius);
00161   D1ptr = & D1;
00162   
00163 
00164   cout << "disk:  " << (stringc)D1 << endl;
00165 
00166   filein >> nml.x;
00167   filein >> nml.y;
00168   filein >> nml.z;
00169   filein >> d;
00170 
00171   plane P1(nml,d);
00172   P1ptr = &P1;
00173 
00174   cout << "plane:  " << (stringc)P1 << endl;
00175 
00176   planepointsurface f1(P1);
00177   pointsurface<> ps1(6000);
00178   ps1.pre.push(new gobjglColor3ub(184,134,11) );
00179   ps1.addsurface2D(f1);
00180   gobjpush(&ps1);
00181 
00182   gobjpush(new gobjglColor3ub(255,255,0));
00183   gobjMyCircle * cir = new gobjMyCircle();
00184   gobjMyCircleDraw * cird = 
00185     new gobjMyCircleDraw(D1.radius,D1.pos,D1.nml,*cir);
00186   gobjpush(cir);
00187   gobjpush(cird);
00188 
00189   D1cd = cird;
00190 
00191   diskintersection = new gobjContainer(true);
00192   gobjpush(diskintersection);
00193 
00194   update01();
00195 
00196   menusystem * menu = 
00197     new menusystem(0,0,true,point2<GLint>(60,30),20);
00198   gobjpush(menu);
00199 
00200   menu->addfont12("Disk and Plane Intersection");
00201   menu->addnewline();
00202   menu->addnewline();
00203   menu->addfont10("'j' 'J' x position/normal"); 
00204   menu->addnewline();
00205   menu->addfont10("'k' 'K' y position/normal"); 
00206   menu->addnewline();
00207   menu->addfont10("'l' 'L' z position/normal"); 
00208   menu->addnewline();
00209   menu->addfont10("'m'  Toggle position/normal mode");
00210   menu->addnewline();
00211   menu->addfont10("'p'  Print the disk and plane to terminal.");
00212   menu->addnewline();
00213   menu->addnewline();
00214   menu->addfont10("ESC      Quit");
00215 
00216   zz.update();
00217   glutMainLoop();
00218 }

void diskinttest::test02 ( int &  argc,
char **  argv 
)

Disk and disk intersection.

Definition at line 325 of file diskinttest.cpp.

References D1cd, D1ptr, D2cd, D2ptr, diskintersection, display01(), gobjpush, help, gobjSwitch< BOOL >::isdrawn, keyboard02(), commandline::mapvar(), disk::nml, point3< T >::normalize(), disk::pos, disk::radius, gobjContainer::set(), zpr::update(), update02(), point3< T >::x, xGraphics, point3< T >::y, and point3< T >::z.

00326 {
00327   glutInit(&argc,argv);
00328   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00329   glutInitWindowSize(800,600);
00330   glutCreateWindow("");
00331   glutDisplayFunc(display01);
00332   glutKeyboardFunc(keyboard02);
00333 
00334   OpenGLinitialisation();
00335 
00336   glEnable(GL_DEPTH_TEST);
00337   glEnable(GL_CULL_FACE);
00338   glEnable(GL_NORMALIZE);
00339 
00340   zpr zz;
00341 
00342   xGraphics.set();
00343 
00344   commandline cmd(argc,argv);
00345 
00346   string in;
00347 
00348   cmd.mapvar(in,"in");
00349   if ( in.empty() )
00350   {
00351     cout << "error: in=filename expected" << endl;
00352     return;
00353   }
00354 
00355   ifstream filein(in.c_str());
00356   assert(filein.good()==true);
00357   if (filein.good()==false)
00358     return;
00359 
00360   point3<double> nml;
00361   point3<double> pos;
00362   double radius;
00363 
00364   filein >> nml.x;
00365   filein >> nml.y;
00366   filein >> nml.z;
00367   filein >> pos.x;
00368   filein >> pos.y;
00369   filein >> pos.z;
00370   filein >> radius;
00371 
00372   nml.normalize();
00373   disk D1(nml,pos,radius);
00374 
00375   filein >> nml.x;
00376   filein >> nml.y;
00377   filein >> nml.z;
00378   filein >> pos.x;
00379   filein >> pos.y;
00380   filein >> pos.z;
00381   filein >> radius;
00382 
00383   nml.normalize();
00384   disk D2(nml,pos,radius);
00385 
00386   //gobjpush(new myaxes(1.0));
00387 
00388   gobjpush(new gobjglColor3ub(255,255,0));
00389   gobjMyCircle * cir = new gobjMyCircle();
00390   gobjMyCircleDraw * cird = 
00391     new gobjMyCircleDraw(D1.radius,D1.pos,D1.nml,*cir);
00392   gobjpush(cir);
00393   gobjpush(cird);
00394 
00395   D1ptr = &D1;
00396   D1cd = cird;
00397 
00398   gobjpush(new gobjglColor3ub(153,50,204));
00399   cird = new gobjMyCircleDraw(D2.radius,D2.pos,D2.nml,*cir);
00400   gobjpush(cird);
00401 
00402   D2ptr = &D2;
00403   D2cd = cird;
00404 
00405   diskintersection = new gobjContainer(true);
00406   gobjpush(diskintersection);
00407 
00408 
00409   menusystem * menu = 
00410     new menusystem(0,0,true,point2<GLint>(60,30),20);
00411 
00412   gobjSwitch<> * menuswitch = new gobjSwitch<>(menu,true);
00413   help = & menuswitch->isdrawn;
00414   gobjpush(menuswitch);
00415 
00416   menu->addfont12("Disk and Disk Intersection");
00417   menu->addnewline();
00418   menu->addnewline();
00419   menu->addfont10("'j' 'J' x position/normal"); 
00420   menu->addnewline();
00421   menu->addfont10("'k' 'K' y position/normal"); 
00422   menu->addnewline();
00423   menu->addfont10("'l' 'L' z position/normal"); 
00424   menu->addnewline();
00425   menu->addfont10("'m'  Toggle position/normal mode");
00426   menu->addnewline();
00427   menu->addfont10("'p'  Print the two disks to terminal.");
00428   menu->addnewline();
00429   menu->addfont10("'x' 'X' Vary disk 2's radius.");
00430   menu->addnewline();
00431   menu->addfont10("'h'  Toggle this help menu.");
00432   menu->addnewline();
00433   menu->addnewline();
00434   menu->addfont10("ESC      Quit");
00435 
00436 
00437   update02();
00438 
00439   zz.update();
00440   glutMainLoop();
00441 }

void diskinttest::test03 ( int &  argc,
char **  argv 
)

Cylinder and cylinder intersection.

Definition at line 746 of file diskinttest.cpp.

References C1cd, C1ptr, C2cd, C2ptr, cylinderintersection, D1cd, D2cd, display01(), gobjpush, cylinder::height, help, gobjSwitch< BOOL >::isdrawn, keyboard03(), commandline::mapvar(), cylinder::nml, cylinder::pos, cylinder::radius, gobjContainer::set(), zpr::update(), update03(), point3< T >::x, xGraphics, point3< T >::y, and point3< T >::z.

00747 {
00748   glutInit(&argc,argv);
00749   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
00750   glutInitWindowSize(800,600);
00751   glutCreateWindow("");
00752   glutDisplayFunc(display01);
00753   glutKeyboardFunc(keyboard03);
00754 
00755   OpenGLinitialisation();
00756 
00757   glEnable(GL_DEPTH_TEST);
00758   glEnable(GL_CULL_FACE);
00759   glEnable(GL_NORMALIZE);
00760 
00761   zpr zz;
00762 
00763   xGraphics.set();
00764   gobjpush(new myaxes(1.0));
00765 
00766   commandline cmd(argc,argv);
00767 
00768   string in;
00769   cmd.mapvar(in,"in");
00770   if ( in.empty() )
00771   {
00772     cout << "error: in=filename expected" << endl;
00773     return;
00774   }
00775 
00776   ifstream filein(in.c_str());
00777   assert(filein.good()==true);
00778   if (filein.good()==false)
00779     return;
00780 
00781   point3<double> nml;
00782   point3<double> pos;
00783   double radius;
00784   double height;
00785 
00786   filein >> nml.x;
00787   filein >> nml.y;
00788   filein >> nml.z;
00789   filein >> pos.x;
00790   filein >> pos.y;
00791   filein >> pos.z;
00792   filein >> radius;
00793   filein >> height;
00794 
00795   cylinder C1(nml,pos,radius,height);
00796 
00797   filein >> nml.x;
00798   filein >> nml.y;
00799   filein >> nml.z;
00800   filein >> pos.x;
00801   filein >> pos.y;
00802   filein >> pos.z;
00803   filein >> radius;
00804   filein >> height;
00805 
00806   cylinder C2(nml,pos,radius,height);
00807 
00808 //cout << (stringc)C1 << endl;
00809 //cout << (stringc)C2 << endl;
00810 
00811 
00812   typedef point2<double> pt2;
00813   typedef point3<double> pt3;
00814 
00815 
00816   GLUquadricObj * quad = gluNewQuadric();
00817   C1cd = new 
00818     gobjgluCylinder(quad,C1.radius,C1.radius,C1.height,20,20);
00819   C2cd = new 
00820     gobjgluCylinder(quad,C2.radius,C2.radius,C2.height,20,20);
00821   C1ptr = & C1;
00822   C2ptr = & C2;
00823 
00824   gobjMyCircle * cir = new gobjMyCircle();
00825   gobjpush(cir);
00826   gobjMyCircleDraw * cird;
00827   cird = new gobjMyCircleDraw(C1.radius,C1.pos,C1.nml,*cir);
00828   gobjpush(cird);
00829   D1cd = cird;
00830   cird = new gobjMyCircleDraw(C2.radius,C2.pos,C2.nml,*cir);
00831   gobjpush(cird);
00832   D2cd = cird;
00833 
00834 
00835 
00836   cylinderintersection = new gobjContainer(true);
00837   gobjpush(cylinderintersection);
00838 
00839 
00840   menusystem * menu = 
00841     new menusystem(0,0,true,point2<GLint>(60,30),20);
00842 
00843   gobjSwitch<> * menuswitch = new gobjSwitch<>(menu,true);
00844   help = & menuswitch->isdrawn;
00845   gobjpush(menuswitch);
00846 
00847   menu->addfont12("Cylinder and Cylinder Intersection");
00848   menu->addnewline();
00849   menu->addfont12("STATUS:  Not complete - in progress.");
00850   menu->addnewline();
00851   menu->addnewline();
00852   menu->addfont10("'j' 'J' x position/normal"); 
00853   menu->addnewline();
00854   menu->addfont10("'k' 'K' y position/normal"); 
00855   menu->addnewline();
00856   menu->addfont10("'l' 'L' z position/normal"); 
00857   menu->addnewline();
00858   menu->addfont10("'m'  Toggle position/normal mode");
00859   menu->addnewline();
00860   menu->addfont10("'p'  Print the two cylinders to terminal.");
00861   menu->addnewline();
00862   menu->addfont10("'t'  Adjust the transparency.");
00863   menu->addnewline();
00864   menu->addfont10("'h'  Toggle this help menu.");
00865   menu->addnewline();
00866   menu->addnewline();
00867   menu->addfont10("ESC      Quit");
00868 
00869 
00870   update03();
00871 
00872   zz.update();
00873   glutMainLoop();
00874 }

void diskinttest::update01 (  )  [static]

Definition at line 221 of file diskinttest.cpp.

References gobjMyCircleDraw::axis, gobjMyCircleDraw::center, D1cd, D1ptr, diskintersection, disk::intersects(), disk::nml, point3< T >::normalize(), gobjContainer::nuke(), P1ptr, disk::pos, and gobjContainer::push().

Referenced by keyboard01(), and test01().

00222 {
00223   assert(D1ptr!=0);
00224   assert(P1ptr!=0);
00225 
00226   D1ptr->nml.normalize();
00227   D1cd->center = D1ptr->pos;
00228   D1cd->axis = D1ptr->nml;
00229 
00230   point3<double> p0;
00231   point3<double> p1;
00232 
00233   diskintersection->nuke();
00234   if (D1ptr->intersects(p0,p1,*P1ptr))
00235   {
00236     diskintersection->push(new gobjglPushAttrib(GL_LIGHTING));
00237     diskintersection->push(new gobjglPushAttrib(GL_CURRENT_BIT));
00238     diskintersection->push(new gobjglDisable(GL_LIGHTING));
00239     diskintersection->push(new gobjglColor3ub(255,0,0));
00240 
00241     diskintersection->push(new gobjglBegin(GL_LINES));
00242     diskintersection->push(new gobjglVertex3d(p0));
00243     diskintersection->push(new gobjglVertex3d(p1));
00244     diskintersection->push(new gobjglEnd());
00245 
00246     diskintersection->push(new gobjglPopAttrib());
00247     diskintersection->push(new gobjglPopAttrib());
00248   }
00249 
00250 
00251 }

void diskinttest::update02 (  )  [static]

Definition at line 443 of file diskinttest.cpp.

References gobjMyCircleDraw::axis, gobjMyCircleDraw::center, D1cd, D1ptr, D2cd, D2ptr, diskintersection, disk::intersects(), disk::nml, point3< T >::normalize(), gobjContainer::nuke(), disk::pos, gobjContainer::push(), disk::radius, and gobjMyCircleDraw::radiusset().

Referenced by keyboard02(), and test02().

00444 {
00445   assert(D1ptr!=0);
00446   assert(D2ptr!=0);
00447 
00448   D1ptr->nml.normalize();
00449   D2ptr->nml.normalize();
00450 
00451   point3<double> p0;
00452   point3<double> p1;
00453   diskintersection->nuke();
00454   if (D1ptr->intersects(p0,p1,*D2ptr))
00455   {
00456     diskintersection->push(new gobjglPushAttrib(GL_LIGHTING));
00457     diskintersection->push(new gobjglPushAttrib(GL_CURRENT_BIT));
00458     diskintersection->push(new gobjglDisable(GL_LIGHTING));
00459     diskintersection->push(new gobjglColor3ub(255,0,0));
00460 
00461     diskintersection->push(new gobjglBegin(GL_LINES));
00462     diskintersection->push(new gobjglVertex3d(p0));
00463     diskintersection->push(new gobjglVertex3d(p1));
00464     diskintersection->push(new gobjglEnd());
00465 
00466     diskintersection->push(new gobjglPopAttrib());
00467     diskintersection->push(new gobjglPopAttrib());
00468   }
00469 
00470   
00471   D1cd->axis = D1ptr->nml;
00472   D2cd->axis = D2ptr->nml;
00473   D1cd->center = D1ptr->pos;
00474   D2cd->center = D2ptr->pos;
00475   D2cd->radiusset(D2ptr->radius);
00476 
00477 }

void diskinttest::update03 (  )  [static]

Definition at line 653 of file diskinttest.cpp.

References gobjgluCylinder::baseRadius, C1cd, C1ptr, C2cd, C2ptr, cylinderintersection, cylinderscollide, cylinder::height, gobjgluCylinder::height, gobjContainer::kill(), cylinder::nml, gobjContainer::nuke(), cylinder::pos, gobjContainer::push(), cylinder::radius, radtodeg, gobjgluCylinder::topRadius, transparency, update03lineline(), gobjContainer::vg, point3< T >::x, point3< T >::y, and point3< T >::z.

Referenced by keyboard03(), and test03().

00654 {
00655   assert(C1ptr!=0);
00656   assert(C1cd!=0);
00657   assert(C2ptr!=0);
00658   assert(C2cd!=0);
00659   assert(cylinderintersection!=0);
00660 
00661 
00662 
00663   C1cd->baseRadius = C1ptr->radius;
00664   C1cd->topRadius = C1ptr->radius;
00665   C1cd->height = C1ptr->height;
00666 
00667   C2cd->baseRadius = C2ptr->radius;
00668   C2cd->topRadius = C2ptr->radius;
00669   C2cd->height = C2ptr->height;
00670 
00671   static uint c1=0;
00672   static uint c2=0;
00673 
00674   if (c1!=0)
00675     cylinderintersection->kill(c1);
00676   if (c2!=0)
00677     cylinderintersection->kill(c2);
00678 
00679   cylinderintersection->nuke();
00680 
00681   update03lineline();
00682 
00683   cylinderintersection->push(new gobjglEnable(GL_BLEND));
00684   cylinderintersection->push(
00685     new gobjglBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) );
00686 
00687 
00688   cylinderintersection->push(new gobjglPushMatrix());
00689 
00690   cylinderintersection->push(new gobjglTranslated(C1ptr->pos));
00691 
00692   double th1;
00693   point3<double> axis;
00694 
00695   angles::rotateaboutaxis(th1,axis,C1ptr->nml);
00696 
00697   th1 *= angles::radtodeg;
00698   cylinderintersection->push(new gobjglRotated(th1,axis.x,axis.y,axis.z));
00699 
00700   cylinderintersection->push(new myaxes(1.0));
00701   if (cylinderscollide==false)
00702     cylinderintersection->push(
00703       new gobjglColor4f(0.0,0.0,1.0,transparency));
00704   else
00705     cylinderintersection->push(
00706       new gobjglColor4f(1.0,0.0,0.0,transparency));
00707 
00708   cylinderintersection->push(C1cd);
00709   c1 = cylinderintersection->vg.size()-1;
00710 
00711   cylinderintersection->push(new gobjglPopMatrix());
00712 
00713 
00714   cylinderintersection->push(new gobjglPushMatrix());
00715 
00716   cylinderintersection->push(new gobjglTranslated(C2ptr->pos));
00717   angles::rotateaboutaxis(th1,axis,C2ptr->nml);
00718   th1 *= angles::radtodeg;
00719   cylinderintersection->push(new gobjglRotated(th1,axis.x,axis.y,axis.z));
00720 
00721   cylinderintersection->push(new myaxes(1.0));
00722 
00723   if (cylinderscollide==false)
00724     cylinderintersection->push(
00725       new gobjglColor4f(0.0,1.0,1.0,transparency));
00726   else
00727     cylinderintersection->push(
00728       new gobjglColor4f(1.0,0.0,0.0,transparency));
00729 
00730   cylinderintersection->push(C2cd);
00731   c2 = cylinderintersection->vg.size()-1;
00732 
00733   cylinderintersection->push(new gobjglPopMatrix());
00734 
00735 
00736 
00737   cylinderintersection->push(new gobjglDisable(GL_BLEND));
00738 
00739 
00740 
00741 
00742 }

void diskinttest::update03lineline (  )  [static]

Definition at line 557 of file diskinttest.cpp.

References gobjMyCircleDraw::axis, C1ptr, C2ptr, gobjMyCircleDraw::center, cylinderintersection, cylinderscollide, D1cd, D2cd, cylinder::height, disk::intersects(), line< PT, PD >::lineD3minimized(), disk::nml, line< PT, PD >::nml, cylinder::nml, line< PT, PD >::normalize(), disk::pos, cylinder::pos, gobjContainer::push(), disk::radius, cylinder::radius, gobjMyCircleDraw::radiusset(), and unitbound().

Referenced by update03().

00558 {
00559   if (C1ptr==0)
00560     return;
00561   if (C2ptr==0)
00562     return;
00563   if (D1cd==0)
00564     return;
00565   if (D2cd==0)
00566     return;
00567 
00568   if (zero<double>::test(C1ptr->height))
00569     return;
00570   if (zero<double>::test(C2ptr->height))
00571     return;
00572 
00573 
00574 
00575   
00576   typedef point3<double> pt3;
00577   line<pt3,double> L1(C1ptr->nml,C1ptr->pos);
00578   L1.normalize(C1ptr->height);
00579   line<pt3,double> L2(C2ptr->nml,C2ptr->pos);
00580   L2.normalize(C2ptr->height);
00581 
00582   double t1;
00583   double t2;
00584   bool res;
00585   res = L1.lineD3minimized(t1,t2,L2);
00586 
00587   if (res==false)
00588     return;
00589 
00590   unitbound(t1);
00591   unitbound(t2);
00592 
00593   disk D1(L1.nml,L1(t1),C1ptr->radius);
00594   disk D2(L2.nml,L2(t2),C2ptr->radius);
00595 
00596   D1cd->center = D1.pos;
00597   D1cd->axis = D1.nml;
00598   D1cd->radiusset(D1.radius);
00599   D2cd->center = D2.pos;
00600   D2cd->axis = D2.nml;
00601   D2cd->radiusset(D2.radius);
00602 
00603 
00604   // Infinite cylinders intersection case only.
00605   point3<double> p0;
00606   point3<double> p1;
00607   cylinderscollide = D1.intersects(p0,p1,D2);
00608 
00609 
00610   cylinderintersection->push(new gobjglPushAttrib(GL_LIGHTING));
00611   cylinderintersection->push(new gobjglPushAttrib(GL_CURRENT_BIT));
00612 
00613   cylinderintersection->push(new gobjglDisable(GL_LIGHTING) );
00614 
00615   cylinderintersection->push(new gobjglBegin(GL_LINES));
00616 
00617   // Write the minimal line.
00618   //cylinderintersection->push(
00619   //  new gobjglColor4ub(127,255,212,(GLubyte)(floor(transparency*256))));
00620   cylinderintersection->push( new gobjglColor3ub(127,255,212));
00621   cylinderintersection->push(new gobjglVertex3d(L1(t1)));
00622   cylinderintersection->push(new gobjglVertex3d(L2(t2)));
00623 
00624 
00625   // Write cylinder1's axis.
00626   //cylinderintersection->push(
00627   //  new gobjglColor4ub(255,20,147,(GLubyte)(floor(transparency*256))));
00628   cylinderintersection->push( new gobjglColor3ub(255,20,147));
00629   cylinderintersection->push(new gobjglVertex3d(L1(0.0)));
00630   cylinderintersection->push(new gobjglVertex3d(L1(1.0)));
00631 
00632   // Write cylinder2's axis.
00633   //cylinderintersection->push(
00634   //  new gobjglColor4ub(255,140,0,(GLubyte)(floor(transparency*256))));
00635   cylinderintersection->push( new gobjglColor3ub(255,140,0));
00636   cylinderintersection->push(new gobjglVertex3d(L2(0.0)));
00637   cylinderintersection->push(new gobjglVertex3d(L2(1.0)));
00638 
00639   cylinderintersection->push(new gobjglEnd());
00640 
00641   cylinderintersection->push(new gobjglPopAttrib());
00642   cylinderintersection->push(new gobjglPopAttrib());
00643 
00644 
00645 
00646 
00647 
00648 
00649 
00650 }


Member Data Documentation

Definition at line 53 of file diskinttest.h.

Referenced by test03(), and update03().

Definition at line 47 of file diskinttest.h.

Referenced by keyboard03(), test03(), update03(), and update03lineline().

Definition at line 54 of file diskinttest.h.

Referenced by test03(), and update03().

Definition at line 48 of file diskinttest.h.

Referenced by keyboard03(), test03(), update03(), and update03lineline().

Definition at line 50 of file diskinttest.h.

Referenced by test03(), update03(), and update03lineline().

Definition at line 51 of file diskinttest.h.

Referenced by update03(), and update03lineline().

Definition at line 41 of file diskinttest.h.

Referenced by test01(), test02(), test03(), update01(), update02(), and update03lineline().

Definition at line 38 of file diskinttest.h.

Referenced by keyboard01(), keyboard02(), test01(), test02(), update01(), and update02().

Definition at line 42 of file diskinttest.h.

Referenced by test02(), test03(), update02(), and update03lineline().

Definition at line 39 of file diskinttest.h.

Referenced by keyboard02(), test02(), and update02().

Holds the intersection graphics for test02.

Definition at line 45 of file diskinttest.h.

Referenced by test01(), test02(), update01(), and update02().

bool * diskinttest::help = 0 [static]

Toggle the help menu.

Definition at line 60 of file diskinttest.h.

Referenced by keyboard02(), keyboard03(), test02(), and test03().

Definition at line 40 of file diskinttest.h.

Referenced by test01(), and update01().

float diskinttest::transparency = 0.6 [static]

Definition at line 57 of file diskinttest.h.

Referenced by keyboard03(), and update03().

Global graphics container.

Definition at line 18 of file diskinttest.h.

Referenced by test01(), test02(), and test03().


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:49:55 2011 for Chelton Evans Source by  doxygen 1.5.8