mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-21 07:19:46 +08:00
Use true compile time "if" for Transform::makeAffine
This commit is contained in:
parent
1e109e1757
commit
26977e281e
@ -62,6 +62,8 @@ struct transform_construct_from_matrix;
|
|||||||
|
|
||||||
template<typename TransformType> struct transform_take_affine_part;
|
template<typename TransformType> struct transform_take_affine_part;
|
||||||
|
|
||||||
|
template<int Mode> struct transform_make_affine;
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
/** \geometry_module \ingroup Geometry_Module
|
/** \geometry_module \ingroup Geometry_Module
|
||||||
@ -230,8 +232,7 @@ public:
|
|||||||
inline Transform()
|
inline Transform()
|
||||||
{
|
{
|
||||||
check_template_params();
|
check_template_params();
|
||||||
if (int(Mode)==Affine)
|
internal::transform_make_affine<(int(Mode)==Affine) ? Affine : AffineCompact>::run(m_matrix);
|
||||||
makeAffine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Transform(const Transform& other)
|
inline Transform(const Transform& other)
|
||||||
@ -591,11 +592,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void makeAffine()
|
void makeAffine()
|
||||||
{
|
{
|
||||||
if(int(Mode)!=int(AffineCompact))
|
internal::transform_make_affine<int(Mode)>::run(m_matrix);
|
||||||
{
|
|
||||||
matrix().template block<1,Dim>(Dim,0).setZero();
|
|
||||||
matrix().coeffRef(Dim,Dim) = Scalar(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
@ -1079,6 +1076,24 @@ Transform<Scalar,Dim,Mode,Options>::fromPositionOrientationScale(const MatrixBas
|
|||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
template<int Mode>
|
||||||
|
struct transform_make_affine
|
||||||
|
{
|
||||||
|
template<typename MatrixType>
|
||||||
|
static void run(MatrixType &mat)
|
||||||
|
{
|
||||||
|
static const int Dim = MatrixType::ColsAtCompileTime-1;
|
||||||
|
mat.template block<1,Dim>(Dim,0).setZero();
|
||||||
|
mat.coeffRef(Dim,Dim) = typename MatrixType::Scalar(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct transform_make_affine<AffineCompact>
|
||||||
|
{
|
||||||
|
template<typename MatrixType> static void run(MatrixType &) { }
|
||||||
|
};
|
||||||
|
|
||||||
// selector needed to avoid taking the inverse of a 3x4 matrix
|
// selector needed to avoid taking the inverse of a 3x4 matrix
|
||||||
template<typename TransformType, int Mode=TransformType::Mode>
|
template<typename TransformType, int Mode=TransformType::Mode>
|
||||||
struct projective_transform_inverse
|
struct projective_transform_inverse
|
||||||
|
Loading…
Reference in New Issue
Block a user