Commit a39577bf6661bcb962a7329abbebc66e501b1dac
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,18 +92,7 @@ class gl_spider : public virtual gl_texture<T> | ||
92 | setPosition(0.0,0.0,0.0); | 92 | setPosition(0.0,0.0,0.0); |
93 | setDirection(1.0,1.0,1.0); | 93 | setDirection(1.0,1.0,1.0); |
94 | setMagnitude(0.1,0.1); | 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 | gl_spider | 98 | gl_spider |
@@ -112,18 +101,7 @@ class gl_spider : public virtual gl_texture<T> | @@ -112,18 +101,7 @@ class gl_spider : public virtual gl_texture<T> | ||
112 | position = pos; | 101 | position = pos; |
113 | direction = dir; | 102 | direction = dir; |
114 | magnitude = mag; | 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 | //temporary cost for convenience. | 106 | //temporary cost for convenience. |
129 | gl_spider | 107 | gl_spider |
@@ -133,35 +111,35 @@ class gl_spider : public virtual gl_texture<T> | @@ -133,35 +111,35 @@ class gl_spider : public virtual gl_texture<T> | ||
133 | setPosition(pos_x, pos_y, pos_z); | 111 | setPosition(pos_x, pos_y, pos_z); |
134 | setDirection(dir_x, dir_y, dir_z); | 112 | setDirection(dir_x, dir_y, dir_z); |
135 | setMagnitude(mag_x, mag_y); | 113 | setMagnitude(mag_x, mag_y); |
114 | + Update(); | ||
115 | + } | ||
116 | + | ||
117 | + void | ||
118 | + Update() | ||
119 | + { | ||
136 | vec<float> Y(1.0,0.0,0.0); | 120 | vec<float> Y(1.0,0.0,0.0); |
137 | if(cos(Y.dot(direction))< 0.087){ | 121 | if(cos(Y.dot(direction))< 0.087){ |
138 | Y[0] = 0.0; Y[1] = 1.0;} | 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 | hor = stim::rect<float>(magnitude, position, direction.norm(), | 123 | hor = stim::rect<float>(magnitude, position, direction.norm(), |
146 | ((Y.cross(direction)).cross(direction)).norm()); | 124 | ((Y.cross(direction)).cross(direction)).norm()); |
147 | ver = stim::rect<float>(magnitude, position, direction.norm(), | 125 | ver = stim::rect<float>(magnitude, position, direction.norm(), |
148 | hor.n()); | 126 | hor.n()); |
149 | } | 127 | } |
150 | - | 128 | + |
151 | vec<float> | 129 | vec<float> |
152 | - getCurrentPosition() | 130 | + getPosition() |
153 | { | 131 | { |
154 | return position; | 132 | return position; |
155 | } | 133 | } |
156 | 134 | ||
157 | vec<float> | 135 | vec<float> |
158 | - getCurrentDirection() | 136 | + getDirection() |
159 | { | 137 | { |
160 | return direction; | 138 | return direction; |
161 | } | 139 | } |
162 | 140 | ||
163 | vec<float> | 141 | vec<float> |
164 | - getCurrentMagnitude() | 142 | + getMagnitude() |
165 | { | 143 | { |
166 | return magnitude; | 144 | return magnitude; |
167 | } | 145 | } |
@@ -212,14 +190,8 @@ class gl_spider : public virtual gl_texture<T> | @@ -212,14 +190,8 @@ class gl_spider : public virtual gl_texture<T> | ||
212 | { | 190 | { |
213 | std::cout << position[0] << "," << position[1] << "," << position[1] | 191 | std::cout << position[0] << "," << position[1] << "," << position[1] |
214 | << std::endl; | 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 | std::cout << position[0] << "," << position[1] << "," << position[1] | 195 | std::cout << position[0] << "," << position[1] << "," << position[1] |
224 | << std::endl; | 196 | << std::endl; |
225 | 197 |