diff --git a/math/rect.h b/math/rect.h index 7dc48b5..174ac13 100644 --- a/math/rect.h +++ b/math/rect.h @@ -61,62 +61,22 @@ public: init(); } + //create a rectangle given a size and position CUDA_CALLABLE rect(T size, T z_pos = (T)0){ init(); //use the default setup scale(size); //scale the rectangle C[2] = z_pos; } + //create a rectangle from a center point, normal, and size CUDA_CALLABLE rect(T 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 - } - /*CUDA_CALLABLE rect(vec a, vec b, vec c) - { - A = a; - Y = b - a; - X = c - a - Y; - - }*/ - - /******************************************************************* - Constructor - create a rect from a position, normal, and rotation - *******************************************************************/ - /*CUDA_CALLABLE rect(stim::vec c, stim::vec normal, T width, T height, T theta) - { - - //compute the X direction - start along world-space X - Y = stim::vec(0, 1, 0); - if(Y == normal) - Y = stim::vec(0, 0, 1); - - X = Y.cross(normal).norm(); - - std::cout< q; - q.CreateRotation(theta, normal); - X = q.toMatrix3() * X; - Y = normal.cross(X); - - //normalize everything - X = X.norm(); - Y = Y.norm(); - - //scale to match the rect width and height - X = X * width; - Y = Y * height; - - //set the corner of the plane - A = c - X * 0.5f - Y * 0.5f; - - std::cout< & rhs) @@ -135,6 +95,7 @@ public: return (X.cross(Y)).norm(); } + //get the world space value given the planar coordinates a, b in [0, 1] CUDA_CALLABLE stim::vec p(T a, T b) { stim::vec result; @@ -145,6 +106,7 @@ public: return result; } + //parenthesis operator returns the world space given rectangular coordinates a and b in [0 1] CUDA_CALLABLE stim::vec operator()(T a, T b) { return p(a, b); @@ -162,6 +124,7 @@ public: } + //scales the rectangle by a value rhs CUDA_CALLABLE rect operator*(T rhs) { //scales the plane by a scalar value @@ -174,6 +137,7 @@ public: } + //computes the distance between the specified point and this rectangle CUDA_CALLABLE T dist(vec p) { //compute the distance between a point and this rect -- libgit2 0.21.4