Bläddra i källkod

rotate_vectors keeps the magnitude intact instead of changing it to 1

Former-commit-id: 6bdc7e12bd4e34ffa7c5c971b3ddd8796979c66d
Olga Diamanti 9 år sedan
förälder
incheckning
52ba9e6fd8
1 ändrade filer med 3 tillägg och 1 borttagningar
  1. 3 1
      include/igl/rotate_vectors.cpp

+ 3 - 1
include/igl/rotate_vectors.cpp

@@ -17,6 +17,8 @@ IGL_INLINE Eigen::MatrixXd igl::rotate_vectors(
 
   for (unsigned i=0; i<V.rows();++i)
   {
+    double norm = V.row(i).norm();
+    
     // project onto the tangent plane and convert to angle
     double a = atan2(B2.row(i).dot(V.row(i)),B1.row(i).dot(V.row(i)));
 
@@ -24,7 +26,7 @@ IGL_INLINE Eigen::MatrixXd igl::rotate_vectors(
     a += (A.size() == 1) ? A(0) : A(i);
 
     // move it back to global coordinates
-    RV.row(i) = cos(a) * B1.row(i) + sin(a) * B2.row(i);
+    RV.row(i) = norm*cos(a) * B1.row(i) + norm*sin(a) * B2.row(i);
   }
 
   return RV;