From fac43319abb6213f2376a1bc993728d86eb8f30d Mon Sep 17 00:00:00 2001 From: pgovyadi Date: Fri, 9 Sep 2016 16:24:48 -0500 Subject: [PATCH] Changed the position vector creation method to use a circle instead of square and added cyl2cart and cart2cyl functions to vec3 --- stim/gl/gl_spider.h | 8 ++++++-- stim/gl/gl_texture.h | 4 ++-- stim/math/vec3.h | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/stim/gl/gl_spider.h b/stim/gl/gl_spider.h index 570e74d..1554e6b 100644 --- a/stim/gl/gl_spider.h +++ b/stim/gl/gl_spider.h @@ -419,12 +419,16 @@ class gl_spider // : public virtual gl_texture ver = stim::rect(mag, ///generate anoth er rectangle that's perpendicular the first but parallel to the cart vector. pos, dir, hor.n()); + ///The first vector is always in the center. UpdateBuffer(0.0, 0.0+0*n_pixels); for(int i = 1; i < numSamplesPos; i++) ///for the number of position samples { stim::vec3 temp = uniformRandVector(); ///generate a random point on a plane. - temp = temp*delta*2.0 - delta; ///scale the point and center it around 0.0 + temp[0] = temp[0]*delta; + temp[1] = temp[1]*2*stim::PI; + temp[2] = 0.0; + temp = temp.cyl2cart(); pV.push_back(temp); ///save the point for further use. hor = stim::rect(mag, ///generate a rectangle with the new vector as a normal. temp, dir, @@ -878,7 +882,7 @@ class gl_spider // : public virtual gl_texture iter_dir = 0; iter_siz = 0; #endif - stepsize = 3.0; + stepsize = 10.0; n_pixels = 16.0; srand(100); diff --git a/stim/gl/gl_texture.h b/stim/gl/gl_texture.h index 9806483..a1314b7 100644 --- a/stim/gl/gl_texture.h +++ b/stim/gl/gl_texture.h @@ -64,7 +64,7 @@ class gl_texture : public virtual image_stack case 4: return GL_RGBA; default: - std::cout<<"Error in stim::gl_texture - unable to guess texture format based on number of channels ("< if(texID == 0) generate_texture(); //generate the texture if it doesn't already exist else{ std::cout<<"Texture has already been attached to a context."< cart2cyl() const{ + vec3 cyl; + cyl.ptr[0] = sqrt(pow(ptr[0],2) + pow(ptr[1],2)); + cyl.ptr[1] = atan(ptr[1]/ptr[0]); + cyl.ptr[2] = ptr[2]; + + return cyl; + } + /// Convert the vector from cartesian to spherical coordinates (r, theta, phi -> x, y, z where theta = [0, 2*pi]) CUDA_CALLABLE vec3 sph2cart() const{ vec3 cart; @@ -90,6 +99,16 @@ public: return cart; } + /// Convert the vector from cylindrical to cart coordinates (r, theta, z -> x, y, z where theta = [0, 2*pi]) + CUDA_CALLABLE vec3 cyl2cart() const{ + vec3 cart; + cart.ptr[0] = ptr[0] * std::cos(ptr[1]); + cart.ptr[1] = ptr[0] * std::sin(ptr[1]); + cart.ptr[2] = ptr[2]; + + return cart; + } + /// Computes the normalized vector (where each coordinate is divided by the L2 norm) CUDA_CALLABLE vec3 norm() const{ vec3 result; -- libgit2 0.21.4