*fix compilation with MSVC 2005 in the Transform::construct_from_matrix

*fix warnings with MSVC 2005: converting M_PI to float gives loss-of-precision warnings
This commit is contained in:
Benoit Jacob 2009-01-05 14:47:38 +00:00
parent dae7f065d4
commit 7db3f2f72a
2 changed files with 8 additions and 8 deletions

View File

@ -106,7 +106,7 @@ public:
inline Transform& operator=(const Transform& other)
{ m_matrix = other.m_matrix; return *this; }
template<typename OtherDerived, bool select = OtherDerived::RowsAtCompileTime == Dim>
template<typename OtherDerived, bool BigMatrix> // MSVC 2005 will commit suicide if BigMatrix has a default value
struct construct_from_matrix
{
static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other)
@ -130,7 +130,7 @@ public:
template<typename OtherDerived>
inline explicit Transform(const MatrixBase<OtherDerived>& other)
{
construct_from_matrix<OtherDerived>::run(this, other);
construct_from_matrix<OtherDerived, int(OtherDerived::RowsAtCompileTime) == Dim>::run(this, other);
}
/** Set \c *this from a (Dim+1)^2 matrix. */

View File

@ -59,7 +59,7 @@ template<typename Scalar> void geometry(void)
Vector2 u0 = Vector2::Random();
Matrix3 matrot1;
Scalar a = ei_random<Scalar>(-M_PI, M_PI);
Scalar a = ei_random<Scalar>(-Scalar(M_PI), Scalar(M_PI));
// cross product
VERIFY_IS_MUCH_SMALLER_THAN(v1.cross(v2).dot(v1), Scalar(1));
@ -77,7 +77,7 @@ template<typename Scalar> void geometry(void)
VERIFY_IS_APPROX(v0, AngleAxisx(a, v0.normalized()) * v0);
VERIFY_IS_APPROX(-v0, AngleAxisx(M_PI, v0.unitOrthogonal()) * v0);
VERIFY_IS_APPROX(-v0, AngleAxisx(Scalar(M_PI), v0.unitOrthogonal()) * v0);
VERIFY_IS_APPROX(ei_cos(a)*v0.squaredNorm(), v0.dot(AngleAxisx(a, v0.unitOrthogonal()) * v0));
m = AngleAxisx(a, v0.normalized()).toRotationMatrix().adjoint();
VERIFY_IS_APPROX(Matrix3::Identity(), m * AngleAxisx(a, v0.normalized()));
@ -88,8 +88,8 @@ template<typename Scalar> void geometry(void)
// angular distance
Scalar refangle = ei_abs(AngleAxisx(q1.inverse()*q2).angle());
if (refangle>M_PI)
refangle = 2.*M_PI - refangle;
if (refangle>Scalar(M_PI))
refangle = 2.*Scalar(M_PI) - refangle;
VERIFY(ei_isApprox(q1.angularDistance(q2), refangle, largeEps));
// rotation matrix conversion
@ -138,7 +138,7 @@ template<typename Scalar> void geometry(void)
// TODO complete the tests !
a = 0;
while (ei_abs(a)<0.1)
a = ei_random<Scalar>(-0.4*M_PI, 0.4*M_PI);
a = ei_random<Scalar>(-0.4*Scalar(M_PI), 0.4*Scalar(M_PI));
q1 = AngleAxisx(a, v0.normalized());
Transform3 t0, t1, t2;
t0.setIdentity();
@ -188,7 +188,7 @@ template<typename Scalar> void geometry(void)
tmat4.matrix()(3,3) = Scalar(1);
VERIFY_IS_APPROX(tmat3.matrix(), tmat4.matrix());
Scalar a3 = ei_random<Scalar>(-M_PI, M_PI);
Scalar a3 = ei_random<Scalar>(-Scalar(M_PI), Scalar(M_PI));
Vector3 v3 = Vector3::Random().normalized();
AngleAxisx aa3(a3, v3);
Transform3 t3(aa3);