Commit fac43319abb6213f2376a1bc993728d86eb8f30d
1 parent
af825cb9
Changed the position vector creation method to use a circle instead of square an…
…d added cyl2cart and cart2cyl functions to vec3
Showing
3 changed files
with
27 additions
and
4 deletions
Show diff stats
stim/gl/gl_spider.h
@@ -419,12 +419,16 @@ class gl_spider // : public virtual gl_texture<T> | @@ -419,12 +419,16 @@ class gl_spider // : public virtual gl_texture<T> | ||
419 | ver = stim::rect<float>(mag, ///generate anoth er rectangle that's perpendicular the first but parallel to the cart vector. | 419 | ver = stim::rect<float>(mag, ///generate anoth er rectangle that's perpendicular the first but parallel to the cart vector. |
420 | pos, dir, | 420 | pos, dir, |
421 | hor.n()); | 421 | hor.n()); |
422 | + ///The first vector is always in the center. | ||
422 | UpdateBuffer(0.0, 0.0+0*n_pixels); | 423 | UpdateBuffer(0.0, 0.0+0*n_pixels); |
423 | for(int i = 1; i < numSamplesPos; i++) ///for the number of position samples | 424 | for(int i = 1; i < numSamplesPos; i++) ///for the number of position samples |
424 | { | 425 | { |
425 | stim::vec3<float> temp = uniformRandVector(); ///generate a random point on a plane. | 426 | stim::vec3<float> temp = uniformRandVector(); ///generate a random point on a plane. |
426 | - temp = temp*delta*2.0 - delta; ///scale the point and center it around 0.0 | 427 | + temp[0] = temp[0]*delta; |
428 | + temp[1] = temp[1]*2*stim::PI; | ||
429 | + | ||
427 | temp[2] = 0.0; | 430 | temp[2] = 0.0; |
431 | + temp = temp.cyl2cart(); | ||
428 | pV.push_back(temp); ///save the point for further use. | 432 | pV.push_back(temp); ///save the point for further use. |
429 | hor = stim::rect<float>(mag, ///generate a rectangle with the new vector as a normal. | 433 | hor = stim::rect<float>(mag, ///generate a rectangle with the new vector as a normal. |
430 | temp, dir, | 434 | temp, dir, |
@@ -878,7 +882,7 @@ class gl_spider // : public virtual gl_texture<T> | @@ -878,7 +882,7 @@ class gl_spider // : public virtual gl_texture<T> | ||
878 | iter_dir = 0; | 882 | iter_dir = 0; |
879 | iter_siz = 0; | 883 | iter_siz = 0; |
880 | #endif | 884 | #endif |
881 | - stepsize = 3.0; | 885 | + stepsize = 10.0; |
882 | n_pixels = 16.0; | 886 | n_pixels = 16.0; |
883 | 887 | ||
884 | srand(100); | 888 | srand(100); |
stim/gl/gl_texture.h
@@ -64,7 +64,7 @@ class gl_texture : public virtual image_stack<T, F> | @@ -64,7 +64,7 @@ class gl_texture : public virtual image_stack<T, F> | ||
64 | case 4: | 64 | case 4: |
65 | return GL_RGBA; | 65 | return GL_RGBA; |
66 | default: | 66 | default: |
67 | - std::cout<<"Error in stim::gl_texture - unable to guess texture format based on number of channels ("<<R[4]<<")"<<std::endl; | 67 | + std::cout<<"Error in stim::gl_texture - unable to guess texture format based on number of channels" << std::endl; |
68 | exit(1); | 68 | exit(1); |
69 | } | 69 | } |
70 | } | 70 | } |
@@ -236,7 +236,7 @@ class gl_texture : public virtual image_stack<T, F> | @@ -236,7 +236,7 @@ class gl_texture : public virtual image_stack<T, F> | ||
236 | if(texID == 0) generate_texture(); //generate the texture if it doesn't already exist | 236 | if(texID == 0) generate_texture(); //generate the texture if it doesn't already exist |
237 | else{ | 237 | else{ |
238 | std::cout<<"Texture has already been attached to a context."<<std::endl; | 238 | std::cout<<"Texture has already been attached to a context."<<std::endl; |
239 | - exit(1); | 239 | + //exit(1); Why do we need to quit if it's attached. print the message and continue. |
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 |
stim/math/vec3.h
@@ -80,6 +80,15 @@ public: | @@ -80,6 +80,15 @@ public: | ||
80 | return sph; | 80 | return sph; |
81 | } | 81 | } |
82 | 82 | ||
83 | + CUDA_CALLABLE vec3<T> cart2cyl() const{ | ||
84 | + vec3<T> cyl; | ||
85 | + cyl.ptr[0] = sqrt(pow(ptr[0],2) + pow(ptr[1],2)); | ||
86 | + cyl.ptr[1] = atan(ptr[1]/ptr[0]); | ||
87 | + cyl.ptr[2] = ptr[2]; | ||
88 | + | ||
89 | + return cyl; | ||
90 | + } | ||
91 | + | ||
83 | /// Convert the vector from cartesian to spherical coordinates (r, theta, phi -> x, y, z where theta = [0, 2*pi]) | 92 | /// Convert the vector from cartesian to spherical coordinates (r, theta, phi -> x, y, z where theta = [0, 2*pi]) |
84 | CUDA_CALLABLE vec3<T> sph2cart() const{ | 93 | CUDA_CALLABLE vec3<T> sph2cart() const{ |
85 | vec3<T> cart; | 94 | vec3<T> cart; |
@@ -90,6 +99,16 @@ public: | @@ -90,6 +99,16 @@ public: | ||
90 | return cart; | 99 | return cart; |
91 | } | 100 | } |
92 | 101 | ||
102 | + /// Convert the vector from cylindrical to cart coordinates (r, theta, z -> x, y, z where theta = [0, 2*pi]) | ||
103 | + CUDA_CALLABLE vec3<T> cyl2cart() const{ | ||
104 | + vec3<T> cart; | ||
105 | + cart.ptr[0] = ptr[0] * std::cos(ptr[1]); | ||
106 | + cart.ptr[1] = ptr[0] * std::sin(ptr[1]); | ||
107 | + cart.ptr[2] = ptr[2]; | ||
108 | + | ||
109 | + return cart; | ||
110 | + } | ||
111 | + | ||
93 | /// Computes the normalized vector (where each coordinate is divided by the L2 norm) | 112 | /// Computes the normalized vector (where each coordinate is divided by the L2 norm) |
94 | CUDA_CALLABLE vec3<T> norm() const{ | 113 | CUDA_CALLABLE vec3<T> norm() const{ |
95 | vec3<T> result; | 114 | vec3<T> result; |