diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 9eb8ed535..dcb41435b 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -395,7 +395,7 @@ public: Transform& fromPositionOrientationScale(const MatrixBase &position, const OrientationType& orientation, const MatrixBase &scale); - inline const MatrixType inverse(TransformTraits traits = (TransformTraits)Mode) const; + inline Transform inverse(TransformTraits traits = (TransformTraits)Mode) const; /** \returns a const pointer to the column major internal matrix */ const Scalar* data() const { return m_matrix.data(); } @@ -874,7 +874,7 @@ Transform::fromPositionOrientationScale(const MatrixBase::fromPositionOrientationScale(const MatrixBase -const typename Transform::MatrixType +Transform Transform::inverse(TransformTraits hint) const { + Transform res; if (hint == Projective) { - return m_matrix.inverse(); + res.matrix() = m_matrix.inverse(); } else { - MatrixType res; if (hint == Isometry) { - res.template corner(TopLeft) = linear().transpose(); + res.matrix().template corner(TopLeft) = linear().transpose(); } else if(hint&Affine) { - res.template corner(TopLeft) = linear().inverse(); + res.matrix().template corner(TopLeft) = linear().inverse(); } else { ei_assert(false && "Invalid transform traits in Transform::Inverse"); } // translation and remaining parts - res.template corner(TopRight) = - res.template corner(TopLeft) * translation(); + res.matrix().template corner(TopRight) = - res.matrix().template corner(TopLeft) * translation(); if(int(Mode)!=int(AffineCompact)) { - res.template block<1,Dim>(Dim,0).setZero(); - res.coeffRef(Dim,Dim) = 1; + res.matrix().template block<1,Dim>(Dim,0).setZero(); + res.matrix().coeffRef(Dim,Dim) = 1; } - return res; } + return res; } /***************************************************** diff --git a/test/geo_transformations.cpp b/test/geo_transformations.cpp index 914dbaf74..2b05f2457 100644 --- a/test/geo_transformations.cpp +++ b/test/geo_transformations.cpp @@ -296,10 +296,10 @@ template void transformations(void) t0.setIdentity(); t0.translate(v0); t0.linear().setRandom(); - VERIFY_IS_APPROX(t0.inverse(Affine), t0.matrix().inverse()); + VERIFY_IS_APPROX(t0.inverse(Affine).matrix(), t0.matrix().inverse()); t0.setIdentity(); t0.translate(v0).rotate(q1); - VERIFY_IS_APPROX(t0.inverse(Isometry), t0.matrix().inverse()); + VERIFY_IS_APPROX(t0.inverse(Isometry).matrix(), t0.matrix().inverse()); } // test extract rotation and aligned scaling