Commit 591f04ec6b06050229c27b58fc46acb37c434aa5

Authored by Pavel Govyadinov
1 parent d03b807e

fixed a very subtle constructor bug

Showing 2 changed files with 7 additions and 4 deletions   Show diff stats
stim/math/quaternion.h
@@ -41,13 +41,14 @@ public: @@ -41,13 +41,14 @@ public:
41 z = u_hat[2]*(T)sin(theta/2); 41 z = u_hat[2]*(T)sin(theta/2);
42 } 42 }
43 43
44 - CUDA_CALLABLE void CreateRotation(vec<T> from, vec<T> to){ 44 + void CreateRotation(vec<T> from, vec<T> to){
45 45
46 vec<T> r = from.cross(to); //compute the rotation vector 46 vec<T> r = from.cross(to); //compute the rotation vector
47 T theta = asin(r.len()); //compute the angle of the rotation about r 47 T theta = asin(r.len()); //compute the angle of the rotation about r
48 //deal with a zero vector (both k and kn point in the same direction) 48 //deal with a zero vector (both k and kn point in the same direction)
49 - if(theta == (T)0) 49 + if(theta == (T)0){
50 return; 50 return;
  51 + }
51 52
52 //create a quaternion to capture the rotation 53 //create a quaternion to capture the rotation
53 CreateRotation(theta, r.norm()); 54 CreateRotation(theta, r.norm());
@@ -70,7 +70,7 @@ public: @@ -70,7 +70,7 @@ public:
70 ///@param c: x,y,z location of the center. 70 ///@param c: x,y,z location of the center.
71 ///@param n: x,y,z direction of the normal. 71 ///@param n: x,y,z direction of the normal.
72 CUDA_CALLABLE rect(vec<T> c, vec<T> n = vec<T>(0, 0, 1)) 72 CUDA_CALLABLE rect(vec<T> c, vec<T> n = vec<T>(0, 0, 1))
73 - : plane<T>(n, c) 73 + : plane<T>()
74 { 74 {
75 init(); //start with the default setting 75 init(); //start with the default setting
76 normal(n); //orient 76 normal(n); //orient
@@ -81,10 +81,12 @@ public: @@ -81,10 +81,12 @@ public:
81 ///@param s: size of the rectangle. 81 ///@param s: size of the rectangle.
82 ///@param n: x,y,z direction of the normal. 82 ///@param n: x,y,z direction of the normal.
83 CUDA_CALLABLE rect(vec<T> c, T s, vec<T> n = vec<T>(0, 0, 1)) 83 CUDA_CALLABLE rect(vec<T> c, T s, vec<T> n = vec<T>(0, 0, 1))
84 - : plane<T>(n, c) 84 + : plane<T>()
85 { 85 {
86 init(); //start with the default setting 86 init(); //start with the default setting
87 scale(s); 87 scale(s);
  88 + center(c);
  89 + rotate(n, X, Y);
88 } 90 }
89 91
90 ///creates a rectangle from a centerpoint and an X and Y direction vectors. 92 ///creates a rectangle from a centerpoint and an X and Y direction vectors.