mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-23 10:09:36 +08:00
fix bug #52: Transform::inverse() should return a Transform
This commit is contained in:
parent
fcae32cc3f
commit
760636a237
@ -395,7 +395,7 @@ public:
|
|||||||
Transform& fromPositionOrientationScale(const MatrixBase<PositionDerived> &position,
|
Transform& fromPositionOrientationScale(const MatrixBase<PositionDerived> &position,
|
||||||
const OrientationType& orientation, const MatrixBase<ScaleDerived> &scale);
|
const OrientationType& orientation, const MatrixBase<ScaleDerived> &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 */
|
/** \returns a const pointer to the column major internal matrix */
|
||||||
const Scalar* data() const { return m_matrix.data(); }
|
const Scalar* data() const { return m_matrix.data(); }
|
||||||
@ -874,7 +874,7 @@ Transform<Scalar,Dim,Mode>::fromPositionOrientationScale(const MatrixBase<Positi
|
|||||||
|
|
||||||
/** \nonstableyet
|
/** \nonstableyet
|
||||||
*
|
*
|
||||||
* \returns the inverse transformation matrix according to some given knowledge
|
* \returns the inverse transformation according to some given knowledge
|
||||||
* on \c *this.
|
* on \c *this.
|
||||||
*
|
*
|
||||||
* \param traits allows to optimize the inversion process when the transformion
|
* \param traits allows to optimize the inversion process when the transformion
|
||||||
@ -892,38 +892,38 @@ Transform<Scalar,Dim,Mode>::fromPositionOrientationScale(const MatrixBase<Positi
|
|||||||
* \sa MatrixBase::inverse()
|
* \sa MatrixBase::inverse()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, int Dim, int Mode>
|
template<typename Scalar, int Dim, int Mode>
|
||||||
const typename Transform<Scalar,Dim,Mode>::MatrixType
|
Transform<Scalar,Dim,Mode>
|
||||||
Transform<Scalar,Dim,Mode>::inverse(TransformTraits hint) const
|
Transform<Scalar,Dim,Mode>::inverse(TransformTraits hint) const
|
||||||
{
|
{
|
||||||
|
Transform res;
|
||||||
if (hint == Projective)
|
if (hint == Projective)
|
||||||
{
|
{
|
||||||
return m_matrix.inverse();
|
res.matrix() = m_matrix.inverse();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MatrixType res;
|
|
||||||
if (hint == Isometry)
|
if (hint == Isometry)
|
||||||
{
|
{
|
||||||
res.template corner<Dim,Dim>(TopLeft) = linear().transpose();
|
res.matrix().template corner<Dim,Dim>(TopLeft) = linear().transpose();
|
||||||
}
|
}
|
||||||
else if(hint&Affine)
|
else if(hint&Affine)
|
||||||
{
|
{
|
||||||
res.template corner<Dim,Dim>(TopLeft) = linear().inverse();
|
res.matrix().template corner<Dim,Dim>(TopLeft) = linear().inverse();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ei_assert(false && "Invalid transform traits in Transform::Inverse");
|
ei_assert(false && "Invalid transform traits in Transform::Inverse");
|
||||||
}
|
}
|
||||||
// translation and remaining parts
|
// translation and remaining parts
|
||||||
res.template corner<Dim,1>(TopRight) = - res.template corner<Dim,Dim>(TopLeft) * translation();
|
res.matrix().template corner<Dim,1>(TopRight) = - res.matrix().template corner<Dim,Dim>(TopLeft) * translation();
|
||||||
if(int(Mode)!=int(AffineCompact))
|
if(int(Mode)!=int(AffineCompact))
|
||||||
{
|
{
|
||||||
res.template block<1,Dim>(Dim,0).setZero();
|
res.matrix().template block<1,Dim>(Dim,0).setZero();
|
||||||
res.coeffRef(Dim,Dim) = 1;
|
res.matrix().coeffRef(Dim,Dim) = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
*** Specializations of take affine part ***
|
*** Specializations of take affine part ***
|
||||||
|
@ -296,10 +296,10 @@ template<typename Scalar, int Mode> void transformations(void)
|
|||||||
t0.setIdentity();
|
t0.setIdentity();
|
||||||
t0.translate(v0);
|
t0.translate(v0);
|
||||||
t0.linear().setRandom();
|
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.setIdentity();
|
||||||
t0.translate(v0).rotate(q1);
|
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
|
// test extract rotation and aligned scaling
|
||||||
|
Loading…
x
Reference in New Issue
Block a user