mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-02-23 18:20:47 +08:00
* extractRotation ---> rotation
* expand the geometry/Transform tests, after Mek's reports * fix my own stupidity in eigensolver test
This commit is contained in:
parent
e4980616fd
commit
22875683b9
@ -238,7 +238,8 @@ public:
|
||||
template<typename Derived>
|
||||
inline Transform operator*(const RotationBase<Derived,Dim>& r) const;
|
||||
|
||||
LinearMatrixType extractRotation(TransformTraits traits = Affine) const;
|
||||
EIGEN_DEPRECATED LinearMatrixType extractRotation(TransformTraits traits = Affine) const { return rotation(traits); }
|
||||
LinearMatrixType rotation(TransformTraits traits = Affine) const;
|
||||
|
||||
template<typename PositionDerived, typename OrientationType, typename ScaleDerived>
|
||||
Transform& fromPositionOrientationScale(const MatrixBase<PositionDerived> &position,
|
||||
@ -600,7 +601,7 @@ inline Transform<Scalar,Dim> Transform<Scalar,Dim>::operator*(const RotationBase
|
||||
*/
|
||||
template<typename Scalar, int Dim>
|
||||
typename Transform<Scalar,Dim>::LinearMatrixType
|
||||
Transform<Scalar,Dim>::extractRotation(TransformTraits traits) const
|
||||
Transform<Scalar,Dim>::rotation(TransformTraits traits) const
|
||||
{
|
||||
ei_assert(traits!=Projective && "you cannot extract a rotation from a non affine transformation");
|
||||
if (traits == Affine)
|
||||
|
@ -109,8 +109,8 @@ template<typename MatrixType> void selfadjointeigensolver(const MatrixType& m)
|
||||
symmB * (eiSymmGen.eigenvectors() * eiSymmGen.eigenvalues().asDiagonal().eval()), largerEps));
|
||||
|
||||
MatrixType sqrtSymmA = eiSymm.operatorSqrt();
|
||||
VERIFY(symmA.isApprox(sqrtSymmA*sqrtSymmA, ei_sqrt(test_precision<RealScalar>())));
|
||||
VERIFY(sqrtSymmA.isApprox(symmA*eiSymm.operatorInverseSqrt(), ei_sqrt(test_precision<RealScalar>())));
|
||||
VERIFY_IS_APPROX(symmA, sqrtSymmA*sqrtSymmA);
|
||||
VERIFY_IS_APPROX(sqrtSymmA, symmA*eiSymm.operatorInverseSqrt());
|
||||
}
|
||||
|
||||
template<typename MatrixType> void eigensolver(const MatrixType& m)
|
||||
|
@ -177,6 +177,37 @@ template<typename Scalar> void geometry(void)
|
||||
VERIFY_IS_APPROX(t0.scale(a).matrix(), t1.scale(Vector3::Constant(a)).matrix());
|
||||
VERIFY_IS_APPROX(t0.prescale(a).matrix(), t1.prescale(Vector3::Constant(a)).matrix());
|
||||
|
||||
// More transform constructors and operator='s
|
||||
|
||||
Scalar a3 = ei_random<Scalar>(-M_PI, M_PI);
|
||||
Vector3 v3 = Vector3::Random().normalized();
|
||||
AngleAxisx aa3(a3, v3);
|
||||
Transform3 t3(aa3);
|
||||
Transform3 t4;
|
||||
t4 = aa3;
|
||||
VERIFY_IS_APPROX(t3.matrix(), t4.matrix());
|
||||
t4.rotate(AngleAxisx(-a,v3));
|
||||
VERIFY_IS_APPROX(t4.matrix(), Matrix4::Identity());
|
||||
|
||||
v3 = Vector3::Random();
|
||||
Translation3 tv3(v3);
|
||||
Transform3 t5(tv3);
|
||||
t4 = tv3;
|
||||
VERIFY_IS_APPROX(t5.matrix(), t4.matrix());
|
||||
t4.translate(-v3);
|
||||
VERIFY_IS_APPROX(t4.matrix(), Matrix4::Identity());
|
||||
|
||||
Scaling3 sv3(v3);
|
||||
Transform3 t6(sv3);
|
||||
t4 = sv3;
|
||||
VERIFY_IS_APPROX(t6.matrix(), t4.matrix());
|
||||
t4.scale(v3.cwise().inverse());
|
||||
VERIFY_IS_APPROX(t4.matrix(), Matrix4::Identity());
|
||||
|
||||
// chained Transform product
|
||||
|
||||
VERIFY_IS_APPROX(Transform3((t3*t4)*t5).matrix(), Transform3(t3*(t4*t5)).matrix());
|
||||
|
||||
// 2D transformation
|
||||
Transform2 t20, t21;
|
||||
Vector2 v20 = Vector2::Random();
|
||||
@ -283,7 +314,7 @@ template<typename Scalar> void geometry(void)
|
||||
// test extract rotation
|
||||
t0.setIdentity();
|
||||
t0.translate(v0).rotate(q1).scale(v1);
|
||||
VERIFY_IS_APPROX(t0.extractRotation(Affine) * v1, Matrix3(q1) * v1);
|
||||
VERIFY_IS_APPROX(t0.rotation(Affine) * v1, Matrix3(q1) * v1);
|
||||
|
||||
// test casting
|
||||
Transform<float,3> t1f = t1.template cast<float>();
|
||||
|
Loading…
Reference in New Issue
Block a user