From 591f04ec6b06050229c27b58fc46acb37c434aa5 Mon Sep 17 00:00:00 2001 From: pgovyadi Date: Thu, 28 Jan 2016 18:15:07 -0600 Subject: [PATCH] fixed a very subtle constructor bug --- stim/math/quaternion.h | 5 +++-- stim/math/rect.h | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/stim/math/quaternion.h b/stim/math/quaternion.h index 57bfa45..1475037 100644 --- a/stim/math/quaternion.h +++ b/stim/math/quaternion.h @@ -41,13 +41,14 @@ public: z = u_hat[2]*(T)sin(theta/2); } - CUDA_CALLABLE void CreateRotation(vec from, vec to){ + void CreateRotation(vec from, vec to){ vec r = from.cross(to); //compute the rotation vector T theta = asin(r.len()); //compute the angle of the rotation about r //deal with a zero vector (both k and kn point in the same direction) - if(theta == (T)0) + if(theta == (T)0){ return; + } //create a quaternion to capture the rotation CreateRotation(theta, r.norm()); diff --git a/stim/math/rect.h b/stim/math/rect.h index 79179f5..ee49845 100644 --- a/stim/math/rect.h +++ b/stim/math/rect.h @@ -70,7 +70,7 @@ public: ///@param c: x,y,z location of the center. ///@param n: x,y,z direction of the normal. CUDA_CALLABLE rect(vec c, vec n = vec(0, 0, 1)) - : plane(n, c) + : plane() { init(); //start with the default setting normal(n); //orient @@ -81,10 +81,12 @@ public: ///@param s: size of the rectangle. ///@param n: x,y,z direction of the normal. CUDA_CALLABLE rect(vec c, T s, vec n = vec(0, 0, 1)) - : plane(n, c) + : plane() { init(); //start with the default setting scale(s); + center(c); + rotate(n, X, Y); } ///creates a rectangle from a centerpoint and an X and Y direction vectors. -- libgit2 0.21.4