mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
Fix matrix to quaternion (and angleaxis) conversion for matrix expression.
This commit is contained in:
parent
844561939f
commit
6c02cbbb0f
@ -739,8 +739,9 @@ template<typename Other>
|
|||||||
struct quaternionbase_assign_impl<Other,3,3>
|
struct quaternionbase_assign_impl<Other,3,3>
|
||||||
{
|
{
|
||||||
typedef typename Other::Scalar Scalar;
|
typedef typename Other::Scalar Scalar;
|
||||||
template<class Derived> static inline void run(QuaternionBase<Derived>& q, const Other& mat)
|
template<class Derived> static inline void run(QuaternionBase<Derived>& q, const Other& a_mat)
|
||||||
{
|
{
|
||||||
|
const typename internal::nested_eval<Other,2>::type mat(a_mat);
|
||||||
using std::sqrt;
|
using std::sqrt;
|
||||||
// This algorithm comes from "Quaternion Calculus and Fast Animation",
|
// This algorithm comes from "Quaternion Calculus and Fast Animation",
|
||||||
// Ken Shoemake, 1987 SIGGRAPH course notes
|
// Ken Shoemake, 1987 SIGGRAPH course notes
|
||||||
|
@ -49,6 +49,7 @@ template<typename Scalar, int Options> void quaternion(void)
|
|||||||
*/
|
*/
|
||||||
using std::abs;
|
using std::abs;
|
||||||
typedef Matrix<Scalar,3,1> Vector3;
|
typedef Matrix<Scalar,3,1> Vector3;
|
||||||
|
typedef Matrix<Scalar,3,3> Matrix3;
|
||||||
typedef Matrix<Scalar,4,1> Vector4;
|
typedef Matrix<Scalar,4,1> Vector4;
|
||||||
typedef Quaternion<Scalar,Options> Quaternionx;
|
typedef Quaternion<Scalar,Options> Quaternionx;
|
||||||
typedef AngleAxis<Scalar> AngleAxisx;
|
typedef AngleAxis<Scalar> AngleAxisx;
|
||||||
@ -101,6 +102,11 @@ template<typename Scalar, int Options> void quaternion(void)
|
|||||||
q2 = q1.toRotationMatrix();
|
q2 = q1.toRotationMatrix();
|
||||||
VERIFY_IS_APPROX(q1*v1,q2*v1);
|
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
|
// angle-axis conversion
|
||||||
AngleAxisx aa = AngleAxisx(q1);
|
AngleAxisx aa = AngleAxisx(q1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user