Commit a39577bf6661bcb962a7329abbebc66e501b1dac

Authored by Pavel Govyadinov
1 parent 879321c4

Changes to the spider class: New method to remove redundant code

Showing 1 changed file with 14 additions and 42 deletions   Show diff stats
gl/gl_spider.h
... ... @@ -92,18 +92,7 @@ class gl_spider : public virtual gl_texture<T>
92 92 setPosition(0.0,0.0,0.0);
93 93 setDirection(1.0,1.0,1.0);
94 94 setMagnitude(0.1,0.1);
95   - stim::vec<float> Y(1.0,0.0,0.0);
96   - if(cos(Y.dot(direction))< 0.087){
97   - Y[0] = 0.0; Y[1] = 1.0;}
98   - /*
99   - hor = stim::rect<float>(position, direction, Y);
100   - hor.scale(magnitude[0], magnitude[1]);
101   - ver = stim::rect<float>(position, direction, (Y.cross(direction)).norm());
102   - ver.scale(magnitude[0], magnitude[1]);
103   - */
104   - hor = stim::rect<float>(magnitude, position, direction, Y);
105   - ver = stim::rect<float>(magnitude, position, direction,
106   - (Y.cross(direction)).norm());
  95 + Update();
107 96 }
108 97  
109 98 gl_spider
... ... @@ -112,18 +101,7 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
112 101 position = pos;
113 102 direction = dir;
114 103 magnitude = mag;
115   - vec<float> Y(1.0,0.0,0.0);
116   - if(cos(Y.dot(direction))< 0.087){
117   - Y[0] = 0.0; Y[1] = 1.0;}
118   - /*
119   - hor = stim::rect<float>(position, direction, Y);
120   - hor.scale(magnitude[0], magnitude[1]);
121   - ver = stim::rect<float>(position, direction, (Y.cross(direction)).norm());
122   - ver.scale(magnitude[0], magnitude[1]);
123   - */
124   - hor = stim::rect<float>(magnitude, position, direction, Y);
125   - ver = stim::rect<float>(magnitude, position, direction,
126   - (Y.cross(direction)).norm());
  104 + Update();
127 105 }
128 106 //temporary cost for convenience.
129 107 gl_spider
... ... @@ -133,35 +111,35 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
133 111 setPosition(pos_x, pos_y, pos_z);
134 112 setDirection(dir_x, dir_y, dir_z);
135 113 setMagnitude(mag_x, mag_y);
  114 + Update();
  115 + }
  116 +
  117 + void
  118 + Update()
  119 + {
136 120 vec<float> Y(1.0,0.0,0.0);
137 121 if(cos(Y.dot(direction))< 0.087){
138 122 Y[0] = 0.0; Y[1] = 1.0;}
139   - /*
140   - hor = stim::rect<float>(position, direction, Y);
141   - hor.scale(magnitude[0], magnitude[1]);
142   - ver = stim::rect<float>(position, direction, (Y.cross(direction)).norm());
143   - ver.scale(magnitude[0], magnitude[1]);
144   - */
145 123 hor = stim::rect<float>(magnitude, position, direction.norm(),
146 124 ((Y.cross(direction)).cross(direction)).norm());
147 125 ver = stim::rect<float>(magnitude, position, direction.norm(),
148 126 hor.n());
149 127 }
150   -
  128 +
151 129 vec<float>
152   - getCurrentPosition()
  130 + getPosition()
153 131 {
154 132 return position;
155 133 }
156 134  
157 135 vec<float>
158   - getCurrentDirection()
  136 + getDirection()
159 137 {
160 138 return direction;
161 139 }
162 140  
163 141 vec<float>
164   - getCurrentMagnitude()
  142 + getMagnitude()
165 143 {
166 144 return magnitude;
167 145 }
... ... @@ -212,14 +190,8 @@ class gl_spider : public virtual gl_texture&lt;T&gt;
212 190 {
213 191 std::cout << position[0] << "," << position[1] << "," << position[1]
214 192 << std::endl;
215   - setPosition(direction*magnitude[1]+position);
216   - vec<float> Y(1.0,0.0,0.0);
217   - if(cos(Y.dot(direction))< 0.087){
218   - Y[0] = 0.0; Y[1] = 1.0;}
219   - hor = stim::rect<float>(magnitude, position, direction.norm(),
220   - ((Y.cross(direction)).cross(direction)).norm());
221   - ver = stim::rect<float>(magnitude, position, direction.norm(),
222   - hor.n());
  193 + setPosition(direction*magnitude[1]/2+position);
  194 + Update();
223 195 std::cout << position[0] << "," << position[1] << "," << position[1]
224 196 << std::endl;
225 197  
... ...