Commit a506d41f810f876b1358b5a7e03eb9e212329724

Authored by Pavel Govyadinov
1 parent d4721000

fixed the methods for vessel tracking, findOptPosition, Direction, and Magnitude…

…, and setMatrix. Added a -scalar method to the mathvec.h class that fixed a segfault
Showing 1 changed file with 6 additions and 53 deletions   Show diff stats
stim/gl/gl_spider.h
... ... @@ -63,9 +63,6 @@ class gl_spider
63 63 void
64 64 findOptimalDirection()
65 65 {
66   - //genTemplate(dV, 0);
67   - cout << "|||||||||||DIRECTION||||||||: " << endl;
68   - cout << "Direction Before: " << d << endl;
69 66 setMatrix();
70 67 glCallList(dList);
71 68 int best = getCost();
... ... @@ -74,16 +71,12 @@ class gl_spider
74 71 dV[best][1]*S[1]*R[1],
75 72 dV[best][2]*S[2]*R[2],
76 73 0);
77   - cout << "Best Vector: " << next << endl;
78 74 next = (cT*next).norm();
79   - cout << "Best Vector after Mat Mult: " << next << endl;
80 75 //next = (cT*next);
81 76 setPosition( p[0]+next[0]*m[0]/stepsize,
82 77 p[1]+next[1]*m[0]/stepsize,
83 78 p[2]+next[2]*m[0]/stepsize);
84 79 setDirection(next[0], next[1], next[2]);
85   - cout << "Direction After: " << d << endl;
86   - cout << "Direction After: " << d << endl;
87 80 }
88 81  
89 82 /// Method for finding the best d for the spider.
... ... @@ -92,7 +85,6 @@ class gl_spider
92 85 void
93 86 findOptimalPosition()
94 87 {
95   - cout << "|||||||||||POSITION||||||||: " << endl;
96 88 setMatrix();
97 89 glCallList(dList+1);
98 90 int best = getCost();
... ... @@ -101,18 +93,11 @@ class gl_spider
101 93 pV[best][1],
102 94 pV[best][2],
103 95 1);
104   - cout << "Best Vector: " << next << endl;
105   - next = cT*next;
106   - cout << "Best Vector after mat mult: " << next << endl;
107   - cout << "Best Vector after conversion:" << "[" << next[0]*S[0]*R[0]
108   - << ", " << next[1]*S[1]*R[1] << ", " << next[2]*S[2]*R[2] << "]" << endl;
109 96 setPosition(
110 97 next[0]*S[0]*R[0],
111 98 next[1]*S[1]*R[1],
112 99 next[2]*S[2]*R[2]
113 100 );
114   - std::cout << "Optimal p:"<< p << std::endl;
115   - cout << "Final Position: " << p << endl;
116 101 }
117 102  
118 103 /// Method for finding the best scale for the spider.
... ... @@ -124,14 +109,6 @@ class gl_spider
124 109 setMatrix();
125 110 glCallList(dList+2);
126 111 int best = getCost();
127   - //stim::vec<float> next(
128   - //mV[best][0]*S[0]*R[0],
129   - //mV[best][1]*S[1]*R[1],
130   - //mV[best][2]*S[2]*R[2],
131   - //1);
132   - //next = cT*next;
133   - std::cout << "Optimal Scale:"<< m[0]*mV[best][0] << std::endl;
134   - //setMagnitude(next[0]);
135 112 setMagnitude(m[0]*mV[best][0]);
136 113 }
137 114  
... ... @@ -221,7 +198,6 @@ class gl_spider
221 198 genPositionVectors(float delta = 0.2)
222 199 {
223 200 ofstream file;
224   - file.open("pvectors.txt");
225 201 //Set up the vectors necessary for Rectangle creation.
226 202 vec<float> Y(1.0,0.0,0.0);
227 203 vec<float> pos(0.0,0.0,0.0);
... ... @@ -233,7 +209,6 @@ class gl_spider
233 209 int dim = (sqrt(numSamples)-1)/2;
234 210 stim::rect<float> samplingPlane =
235 211 stim::rect<float>(p, d);
236   - cout << "Final Position: " << p << endl;
237 212 samplingPlane.scale(mag[0]*delta, mag[0]*delta);
238 213 float step = 1.0/(dim);
239 214  
... ... @@ -250,7 +225,6 @@ class gl_spider
250 225 0.5+step*i,
251 226 0.5+step*j
252 227 );
253   - file << temp[0] << "," << temp[1] << "," << temp[2] << endl;
254 228 pV.push_back(temp);
255 229 hor = stim::rect<float>(mag,
256 230 temp, dir,
... ... @@ -461,32 +435,21 @@ class gl_spider
461 435 glMatrixMode(GL_TEXTURE);
462 436 glLoadIdentity();
463 437 glScalef(1.0/S[0]/R[0], 1.0/S[1]/R[1], 1.0/S[2]/R[2]);
464   - //std::cout << "Scale by 1/S/R" << std::endl;
465   - //glGetFloatv(GL_TEXTURE_MATRIX, curTrans);
466   - //cT.set(curTrans);
467   - //printTransform();
468 438  
469 439  
470 440 glTranslatef(p[0],
471 441 p[1],
472 442 p[2]);
473   - // std::cout << "Translate" << std::endl;
474   - // glGetFloatv(GL_TEXTURE_MATRIX, curTrans);
475   - // cT.set(curTrans);
476   - // printTransform();
477   -
478   - // std::cout << "Rotation" << std::endl;
479   - // glGetFloatv(GL_TEXTURE_MATRIX, curTrans);
480   - // cT.set(curTrans);
481   - // printTransform();
  443 +
482 444 glRotatef(rot[0], rot[1], rot[2], rot[3]);
  445 +
483 446 glScalef(m[0],
484 447 m[0],
485 448 m[0]);
486   - std::cout << "ScaleTemp" << std::endl;
487   - glGetFloatv(GL_TEXTURE_MATRIX, curTrans);
488   - cT.set(curTrans);
489   - printTransform();
  449 +
  450 +// glGetFloatv(GL_TEXTURE_MATRIX, curTrans);
  451 +// cT.set(curTrans);
  452 +// printTransform();
490 453  
491 454 CHECK_OPENGL_ERROR
492 455 glMatrixMode(GL_MODELVIEW);
... ... @@ -729,16 +692,6 @@ class gl_spider
729 692 out[2] = temp[1];
730 693 out[3] = temp[2];
731 694 }
732   - std::cout << "Theta = " << out[0] << std::endl;
733   -/* stim::vec<float> rot = from.cross(dir);
734   - float theta = asin(rot.len());
735   - if(theta == 0){
736   - rot = rot.norm();
737   - }
738   - out[0] = theta;
739   - out[1] = rot[0];
740   - out[2] = rot[1];
741   - out[3] = rot[2]; */
742 695 return out;
743 696 }
744 697  
... ...