bug #927: backport some unit tests for Rotation2D

This commit is contained in:
Gael Guennebaud 2015-01-13 10:11:44 +01:00
parent 5023afc0af
commit 699c80e404

View File

@ -98,7 +98,8 @@ template<typename Scalar, int Mode, int Options> void transformations()
Matrix3 matrot1, m;
Scalar a = internal::random<Scalar>(-Scalar(M_PI), Scalar(M_PI));
Scalar s0 = internal::random<Scalar>();
Scalar s0 = internal::random<Scalar>(),
s1 = internal::random<Scalar>();
while(v0.norm() < test_precision<Scalar>()) v0 = Vector3::Random();
while(v1.norm() < test_precision<Scalar>()) v1 = Vector3::Random();
@ -414,6 +415,20 @@ template<typename Scalar, int Mode, int Options> void transformations()
t21 = Translation2(v20) * Rotation2D<Scalar>(s0) * Eigen::Scaling(s0);
VERIFY_IS_APPROX(t20,t21);
Rotation2D<Scalar> R0(s0), R1(s1);
t20 = Translation2(v20) * (R0 * Eigen::Scaling(s0));
t21 = Translation2(v20) * R0 * Eigen::Scaling(s0);
VERIFY_IS_APPROX(t20,t21);
t20 = Translation2(v20) * (R0 * R0.inverse() * Eigen::Scaling(s0));
t21 = Translation2(v20) * Eigen::Scaling(s0);
VERIFY_IS_APPROX(t20,t21);
VERIFY_IS_APPROX(s0, (R0.slerp(0, R1)).angle());
VERIFY_IS_APPROX(s1, (R0.slerp(1, R1)).angle());
VERIFY_IS_APPROX(s0, (R0.slerp(0.5, R0)).angle());
VERIFY_IS_APPROX(Scalar(0), (R0.slerp(0.5, R0.inverse())).angle());
// check basic features
{
Rotation2D<Scalar> r1; // default ctor