fix Transform() constructor taking a Transform with other mode.

Not really tested as the geometry tests are currently busted.
This commit is contained in:
Benoit Jacob
2010-08-16 12:30:33 -04:00
parent 19d9c835e0
commit 87aafc9169
2 changed files with 27 additions and 4 deletions

View File

@@ -243,9 +243,30 @@ public:
template<int OtherMode>
inline Transform(const Transform<Scalar,Dim,OtherMode>& other)
{
ei_assert(OtherMode!=int(Projective) && "You cannot directly assign a projective transform to an affine one.");
typedef typename Transform<Scalar,Dim,OtherMode>::MatrixType OtherMatrixType;
ei_transform_construct_from_matrix<OtherMatrixType,Mode,Dim,HDim>::run(this, other.matrix());
EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(OtherMode==int(Projective), Mode==int(Projective)),
YOU_CANT_CONVERT_A_PROJECTIVE_TRANSFORM_INTO_AN_AFFINE_TRANSFORM)
enum { ModeIsAffineCompact = Mode == int(AffineCompact),
OtherModeIsAffineCompact = OtherMode == int(AffineCompact)
};
if(ModeIsAffineCompact == OtherModeIsAffineCompact)
{
m_matrix = other.matrix();
}
else if(OtherModeIsAffineCompact)
{
typedef typename Transform<Scalar,Dim,OtherMode>::MatrixType OtherMatrixType;
ei_transform_construct_from_matrix<OtherMatrixType,Mode,Dim,HDim>::run(this, other.matrix());
}
else
{
// here we know that Mode == AffineCompact and OtherMode != AffineCompact.
// if OtherMode were Projective, the static assert above would already have caught it.
// So the only possibility is that OtherMode == Affine
linear() = other.linear();
translation() = other.translation();
}
}
template<typename OtherDerived>