mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-07 05:31:48 +08:00
fix bug #362 and add missing specialization for affine-compact * projective
(transplanted from 48f0bbb58624e3a65dc989d6e4b24ed58c4465e4 )
This commit is contained in:
parent
deeffdb245
commit
cafd34fa91
@ -61,7 +61,7 @@ template< typename Lhs,
|
|||||||
typename Rhs,
|
typename Rhs,
|
||||||
bool AnyProjective =
|
bool AnyProjective =
|
||||||
transform_traits<Lhs>::IsProjective ||
|
transform_traits<Lhs>::IsProjective ||
|
||||||
transform_traits<Lhs>::IsProjective>
|
transform_traits<Rhs>::IsProjective>
|
||||||
struct transform_transform_product_impl;
|
struct transform_transform_product_impl;
|
||||||
|
|
||||||
template< typename Other,
|
template< typename Other,
|
||||||
@ -1391,6 +1391,35 @@ struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename Scalar, int Dim, int LhsOptions, int RhsOptions>
|
||||||
|
struct transform_transform_product_impl<Transform<Scalar,Dim,AffineCompact,LhsOptions>,Transform<Scalar,Dim,Projective,RhsOptions>,true >
|
||||||
|
{
|
||||||
|
typedef Transform<Scalar,Dim,AffineCompact,LhsOptions> Lhs;
|
||||||
|
typedef Transform<Scalar,Dim,Projective,RhsOptions> Rhs;
|
||||||
|
typedef Transform<Scalar,Dim,Projective> ResultType;
|
||||||
|
static ResultType run(const Lhs& lhs, const Rhs& rhs)
|
||||||
|
{
|
||||||
|
ResultType res;
|
||||||
|
res.matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
|
||||||
|
res.matrix().row(Dim) = rhs.matrix().row(Dim);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename Scalar, int Dim, int LhsOptions, int RhsOptions>
|
||||||
|
struct transform_transform_product_impl<Transform<Scalar,Dim,Projective,LhsOptions>,Transform<Scalar,Dim,AffineCompact,RhsOptions>,true >
|
||||||
|
{
|
||||||
|
typedef Transform<Scalar,Dim,Projective,LhsOptions> Lhs;
|
||||||
|
typedef Transform<Scalar,Dim,AffineCompact,RhsOptions> Rhs;
|
||||||
|
typedef Transform<Scalar,Dim,Projective> ResultType;
|
||||||
|
static ResultType run(const Lhs& lhs, const Rhs& rhs)
|
||||||
|
{
|
||||||
|
ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
|
||||||
|
res.matrix().col(Dim) += lhs.matrix().col(Dim);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
|
|
||||||
#endif // EIGEN_TRANSFORM_H
|
#endif // EIGEN_TRANSFORM_H
|
||||||
|
@ -448,6 +448,29 @@ template<typename Scalar> void transform_alignment()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Scalar, int Dim, int Options> void transform_products()
|
||||||
|
{
|
||||||
|
typedef Matrix<Scalar,Dim+1,Dim+1> Mat;
|
||||||
|
typedef Transform<Scalar,Dim,Projective,Options> Proj;
|
||||||
|
typedef Transform<Scalar,Dim,Affine,Options> Aff;
|
||||||
|
typedef Transform<Scalar,Dim,AffineCompact,Options> AffC;
|
||||||
|
|
||||||
|
Proj p; p.matrix().setRandom();
|
||||||
|
Aff a; a.linear().setRandom(); a.translation().setRandom();
|
||||||
|
AffC ac = a;
|
||||||
|
|
||||||
|
Mat p_m(p.matrix()), a_m(a.matrix());
|
||||||
|
|
||||||
|
VERIFY_IS_APPROX((p*p).matrix(), p_m*p_m);
|
||||||
|
VERIFY_IS_APPROX((a*a).matrix(), a_m*a_m);
|
||||||
|
VERIFY_IS_APPROX((p*a).matrix(), p_m*a_m);
|
||||||
|
VERIFY_IS_APPROX((a*p).matrix(), a_m*p_m);
|
||||||
|
VERIFY_IS_APPROX((ac*a).matrix(), a_m*a_m);
|
||||||
|
VERIFY_IS_APPROX((a*ac).matrix(), a_m*a_m);
|
||||||
|
VERIFY_IS_APPROX((p*ac).matrix(), p_m*a_m);
|
||||||
|
VERIFY_IS_APPROX((ac*p).matrix(), a_m*p_m);
|
||||||
|
}
|
||||||
|
|
||||||
void test_geo_transformations()
|
void test_geo_transformations()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
@ -470,5 +493,9 @@ void test_geo_transformations()
|
|||||||
|
|
||||||
CALL_SUBTEST_6(( transformations<double,Projective,RowMajor|AutoAlign>() ));
|
CALL_SUBTEST_6(( transformations<double,Projective,RowMajor|AutoAlign>() ));
|
||||||
CALL_SUBTEST_6(( transformations<double,Projective,RowMajor|DontAlign>() ));
|
CALL_SUBTEST_6(( transformations<double,Projective,RowMajor|DontAlign>() ));
|
||||||
|
|
||||||
|
|
||||||
|
CALL_SUBTEST_7(( transform_products<double,3,RowMajor|AutoAlign>() ));
|
||||||
|
CALL_SUBTEST_7(( transform_products<float,2,AutoAlign>() ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user