diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index 56fa2bfbf..32e7e76fa 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -739,8 +739,9 @@ template struct quaternionbase_assign_impl { typedef typename Other::Scalar Scalar; - template static inline void run(QuaternionBase& q, const Other& mat) + template static inline void run(QuaternionBase& q, const Other& a_mat) { + const typename internal::nested_eval::type mat(a_mat); using std::sqrt; // This algorithm comes from "Quaternion Calculus and Fast Animation", // Ken Shoemake, 1987 SIGGRAPH course notes diff --git a/test/geo_quaternion.cpp b/test/geo_quaternion.cpp index 17229be4a..761bb52b4 100644 --- a/test/geo_quaternion.cpp +++ b/test/geo_quaternion.cpp @@ -49,6 +49,7 @@ template void quaternion(void) */ using std::abs; typedef Matrix Vector3; + typedef Matrix Matrix3; typedef Matrix Vector4; typedef Quaternion Quaternionx; typedef AngleAxis AngleAxisx; @@ -101,6 +102,11 @@ template void quaternion(void) q2 = q1.toRotationMatrix(); VERIFY_IS_APPROX(q1*v1,q2*v1); + Matrix3 rot1(q1); + VERIFY_IS_APPROX(q1*v1,rot1*v1); + Quaternionx q3(rot1.transpose()*rot1); + VERIFY_IS_APPROX(q3*v1,v1); + // angle-axis conversion AngleAxisx aa = AngleAxisx(q1);