Commit 13c2a7d4526567f89ba57edfb2d79efc62e8bdcb
1 parent
4cefeb6d
some changes to the rect class: new constructor. Further expansion of the spider class
Showing
2 changed files
with
72 additions
and
10 deletions
Show diff stats
gl/gl_spider.h
... | ... | @@ -28,8 +28,6 @@ class gl_spider : public virtual gl_texture<T> |
28 | 28 | // Also maybe we some texture representation of |
29 | 29 | // of the spider i.e [WH_pxl, BL_pxl, WH_pxl]. |
30 | 30 | using gl_texture<T>::texID; |
31 | - stim::rect<float> hor; | |
32 | - stim::rect<float> ver; | |
33 | 31 | |
34 | 32 | |
35 | 33 | void |
... | ... | @@ -74,34 +72,81 @@ class gl_spider : public virtual gl_texture<T> |
74 | 72 | { |
75 | 73 | /*find the optimum direction and scale */ |
76 | 74 | } |
77 | - | |
75 | + /* | |
78 | 76 | void |
79 | 77 | Step() |
80 | 78 | { |
81 | - /* move to the new position */ | |
79 | + // move to the new position | |
82 | 80 | } |
81 | + */ | |
83 | 82 | public: |
84 | 83 | |
85 | - gl_spider() | |
84 | + stim::rect<float> hor; | |
85 | + stim::rect<float> ver; | |
86 | + | |
87 | + | |
88 | + | |
89 | + gl_spider | |
90 | + () | |
86 | 91 | { |
87 | 92 | setPosition(0.0,0.0,0.0); |
88 | 93 | setDirection(1.0,1.0,1.0); |
89 | - setMagnitude(1.0,1.0); | |
94 | + setMagnitude(0.1,0.1); | |
90 | 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 | + /* | |
91 | 99 | hor = stim::rect<float>(position, direction, Y); |
92 | - ver = stim::rect<float>(magnitude, position, (Y.cross(direction)).norm()); | |
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()); | |
93 | 107 | } |
94 | 108 | |
95 | - gl_spider(vec<float> pos, vec<float> dir, vec<float> mag) | |
109 | + gl_spider | |
110 | + (vec<float> pos, vec<float> dir, vec<float> mag) | |
96 | 111 | { |
97 | 112 | position = pos; |
98 | 113 | direction = dir; |
99 | 114 | magnitude = mag; |
100 | 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()); | |
127 | + } | |
128 | + //temporary cost for convenience. | |
129 | + gl_spider | |
130 | + (float pos_x, float pos_y, float pos_z, float dir_x, float dir_y, float dir_z, | |
131 | + float mag_x, float mag_y) | |
132 | + { | |
133 | + setPosition(pos_x, pos_y, pos_z); | |
134 | + setDirection(dir_x, dir_y, dir_z); | |
135 | + setMagnitude(mag_x, mag_y); | |
136 | + vec<float> Y(1.0,0.0,0.0); | |
137 | + if(cos(Y.dot(direction))< 0.087){ | |
138 | + Y[0] = 0.0; Y[1] = 1.0;} | |
139 | + /* | |
101 | 140 | hor = stim::rect<float>(position, direction, Y); |
102 | - ver = stim::rect<float>(magnitude, position, (Y.cross(direction)).norm()); | |
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(), Y); | |
146 | + ver = stim::rect<float>(magnitude, position, direction.norm(), | |
147 | + (Y.cross(direction)).norm()); | |
103 | 148 | } |
104 | - | |
149 | + | |
105 | 150 | vec<float> |
106 | 151 | getCurrentPosition() |
107 | 152 | { |
... | ... | @@ -161,6 +206,16 @@ class gl_spider : public virtual gl_texture<T> |
161 | 206 | magnitude[1] = y; |
162 | 207 | } |
163 | 208 | |
209 | + void | |
210 | + Step() | |
211 | + { | |
212 | + std::cout << position[0] << "," << position[1] << "," << position[1] | |
213 | + << std::endl; | |
214 | + setPosition(direction*magnitude[1]+position); | |
215 | + std::cout << position[0] << "," << position[1] << "," << position[1] | |
216 | + << std::endl; | |
217 | + | |
218 | + } | |
164 | 219 | }; |
165 | 220 | } |
166 | 221 | #endif | ... | ... |
math/rect.h
... | ... | @@ -92,6 +92,13 @@ public: |
92 | 92 | Y = directionY; |
93 | 93 | } |
94 | 94 | |
95 | + CUDA_CALLABLE rect(vec<T,N> mag, vec<T, N> center, vec<T, N> directionX, vec<T, N> directionY ) | |
96 | + { | |
97 | + C = center; | |
98 | + X = directionX; | |
99 | + Y = directionY; | |
100 | + scale(mag[0], mag[1]); | |
101 | + } | |
95 | 102 | |
96 | 103 | CUDA_CALLABLE void scale(T factor1, T factor2){ |
97 | 104 | X *= factor1; | ... | ... |