From 4cefeb6db2ba2fe11b6a921ef30b3ac87b8ab1ff Mon Sep 17 00:00:00 2001 From: Pavel Govyadinov Date: Fri, 10 Apr 2015 19:50:17 -0500 Subject: [PATCH] Changes to the rect.h class: Added a new constructor, and some methods for scaling. Changes to gl_spider.h. Support for two rects that generate the coordinates of the two spider templates and constructors --- gl/gl_spider.h | 43 ++++++++++++++++++++++++++++++++----------- math/rect.h | 22 +++++++++++++++++++++- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/gl/gl_spider.h b/gl/gl_spider.h index ae32bfd..1ef5867 100644 --- a/gl/gl_spider.h +++ b/gl/gl_spider.h @@ -2,10 +2,12 @@ #define STIM_GL_SPIDER_H #include +//#include +#include "gl_texture.h" #include "../visualization/camera.h" #include "./error.h" #include "../math/vector.h" - +#include "../math/rect.h" namespace stim { @@ -14,18 +16,20 @@ template class gl_spider : public virtual gl_texture { //doen't use gl_texture really, just needs the GLuint id. + //doesn't even need the texture iD really. private: stim::camera rotator; stim::vec position; //vector designating the position of the spider. stim::vec direction; //vector designating the orientation of the spider //always a unit vector. stim::vec magnitude; //magnitude of the direction vector. - //maybe a vector in order to scale the spider - // in the x, y, z directions. - + //mag[0] = length. + //mag[1] = width. // Also maybe we some texture representation of // of the spider i.e [WH_pxl, BL_pxl, WH_pxl]. - stim::gl_texture; + using gl_texture::texID; + stim::rect hor; + stim::rect ver; void @@ -76,8 +80,28 @@ class gl_spider : public virtual gl_texture { /* move to the new position */ } - public: + + gl_spider() + { + setPosition(0.0,0.0,0.0); + setDirection(1.0,1.0,1.0); + setMagnitude(1.0,1.0); + stim::vec Y(1.0,0.0,0.0); + hor = stim::rect(position, direction, Y); + ver = stim::rect(magnitude, position, (Y.cross(direction)).norm()); + } + + gl_spider(vec pos, vec dir, vec mag) + { + position = pos; + direction = dir; + magnitude = mag; + vec Y(1.0,0.0,0.0); + hor = stim::rect(position, direction, Y); + ver = stim::rect(magnitude, position, (Y.cross(direction)).norm()); + } + vec getCurrentPosition() { @@ -131,15 +155,12 @@ class gl_spider : public virtual gl_texture } void - setPosition(float x, float y, float z) + setMagnitude(float x, float y) { magnitude[0] = x; magnitude[1] = y; - magnitude[2] = z; } - - -} +}; } #endif diff --git a/math/rect.h b/math/rect.h index 174ac13..5a2de07 100644 --- a/math/rect.h +++ b/math/rect.h @@ -36,6 +36,7 @@ private: X *= factor; Y *= factor; } + CUDA_CALLABLE void normal(vec n){ //orient the rectangle along the specified normal @@ -75,8 +76,27 @@ public: scale(size); //scale the rectangle normal(n); //orient } + + //create a rectangle from a center point, normal, and size + CUDA_CALLABLE rect(vec size, vec c, vec n = vec(0, 0, 1)){ + init(); //start with the default setting + C = c; + scale(size); //scale the rectangle + normal(n); //orient + } - //Pavel - write a constructor to create a rectangle given a center point (c), direction vector (v) + CUDA_CALLABLE rect(vec center, vec directionX, vec directionY ) + { + C = center; + X = directionX; + Y = directionY; + } + + + CUDA_CALLABLE void scale(T factor1, T factor2){ + X *= factor1; + Y *= factor2; + } //boolean comparison bool operator==(const rect & rhs) -- libgit2 0.21.4