diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index 1fdc55b0f..3c5f91533 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -246,7 +246,7 @@ template class Scaling; #endif #if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS -template class Transform; +template class Transform; template class ParametrizedLine; template class Hyperplane; template class UniformScaling; diff --git a/Eigen/src/Geometry/Homogeneous.h b/Eigen/src/Geometry/Homogeneous.h index 24ec66249..5c4f26042 100644 --- a/Eigen/src/Geometry/Homogeneous.h +++ b/Eigen/src/Geometry/Homogeneous.h @@ -112,12 +112,12 @@ template class Homogeneous return internal::homogeneous_left_product_impl(lhs.derived(),rhs.m_matrix); } - template friend - inline const internal::homogeneous_left_product_impl > - operator* (const Transform& lhs, const Homogeneous& rhs) + template friend + inline const internal::homogeneous_left_product_impl > + operator* (const Transform& lhs, const Homogeneous& rhs) { eigen_assert(int(Direction)==Vertical); - return internal::homogeneous_left_product_impl >(lhs,rhs.m_matrix); + return internal::homogeneous_left_product_impl >(lhs,rhs.m_matrix); } protected: @@ -212,18 +212,18 @@ struct take_matrix_for_product static const type& run(const type &x) { return x; } }; -template -struct take_matrix_for_product > +template +struct take_matrix_for_product > { - typedef Transform TransformType; + typedef Transform TransformType; typedef typename TransformType::ConstAffinePart type; static const type run (const TransformType& x) { return x.affine(); } }; -template -struct take_matrix_for_product > +template +struct take_matrix_for_product > { - typedef Transform TransformType; + typedef Transform TransformType; typedef typename TransformType::MatrixType type; static const type& run (const TransformType& x) { return x.matrix(); } }; diff --git a/Eigen/src/Geometry/Hyperplane.h b/Eigen/src/Geometry/Hyperplane.h index b532cad04..f22b23a24 100644 --- a/Eigen/src/Geometry/Hyperplane.h +++ b/Eigen/src/Geometry/Hyperplane.h @@ -229,7 +229,8 @@ public: * or a more generic Affine transformation. The default is Affine. * Other kind of transformations are not supported. */ - inline Hyperplane& transform(const Transform& t, + template + inline Hyperplane& transform(const Transform& t, TransformTraits traits = Affine) { transform(t.linear(), traits); diff --git a/Eigen/src/Geometry/RotationBase.h b/Eigen/src/Geometry/RotationBase.h index 65b9cd834..1abf06bb6 100644 --- a/Eigen/src/Geometry/RotationBase.h +++ b/Eigen/src/Geometry/RotationBase.h @@ -98,8 +98,8 @@ class RotationBase } /** \returns the concatenation of the rotation \c *this with a transformation \a t */ - template - inline Transform operator*(const Transform& t) const + template + inline Transform operator*(const Transform& t) const { return toRotationMatrix() * t; } template diff --git a/Eigen/src/Geometry/Scaling.h b/Eigen/src/Geometry/Scaling.h index 9ad67787d..c911d13e1 100644 --- a/Eigen/src/Geometry/Scaling.h +++ b/Eigen/src/Geometry/Scaling.h @@ -72,8 +72,8 @@ public: inline Transform operator* (const Translation& t) const; /** Concatenates a uniform scaling and an affine transformation */ - template - inline Transform operator* (const Transform& t) const; + template + inline Transform operator* (const Transform& t) const; /** Concatenates a uniform scaling and a linear transformation matrix */ // TODO returns an expression @@ -170,9 +170,9 @@ UniformScaling::operator* (const Translation& t) const } template -template +template inline Transform -UniformScaling::operator* (const Transform& t) const +UniformScaling::operator* (const Transform& t) const { Transform res = t; res.prescale(factor()); diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 2b679dc7a..2066e6810 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -48,6 +48,7 @@ struct transform_right_product_impl; template< typename Other, int Mode, + int Options, int Dim, int HDim, int OtherRows=Other::RowsAtCompileTime, @@ -63,6 +64,7 @@ struct transform_transform_product_impl; template< typename Other, int Mode, + int Options, int Dim, int HDim, int OtherRows=Other::RowsAtCompileTime, @@ -88,6 +90,7 @@ template struct transform_take_affine_part; * - AffineCompact: the transformation is stored as a (Dim)x(Dim+1) matrix. * - Projective: the transformation is stored as a (Dim+1)^2 matrix * without any assumption. + * \param _Options can be \b AutoAlign or \b DontAlign. Default is \b AutoAlign * * The homography is internally represented and stored by a matrix which * is available through the matrix() method. To understand the behavior of @@ -177,13 +180,14 @@ template struct transform_take_affine_part; * * \sa class Matrix, class Quaternion */ -template +template class Transform { public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_Dim==Dynamic ? Dynamic : (_Dim+1)*(_Dim+1)) enum { Mode = _Mode, + Options = _Options, Dim = _Dim, ///< space dimension in which the transformation holds HDim = _Dim+1, ///< size of a respective homogeneous vector Rows = int(Mode)==(AffineCompact) ? Dim : HDim @@ -192,7 +196,7 @@ public: typedef _Scalar Scalar; typedef DenseIndex Index; /** type of the matrix used to represent the transformation */ - typedef Matrix MatrixType; + typedef Matrix MatrixType; /** constified MatrixType */ typedef const MatrixType ConstMatrixType; /** type of the matrix used to represent the linear part of the transformation */ @@ -233,19 +237,33 @@ public: * If Mode==Affine, then the last row is set to [0 ... 0 1] */ inline Transform() { + check_template_params(); if (int(Mode)==Affine) makeAffine(); } inline Transform(const Transform& other) { + check_template_params(); m_matrix = other.m_matrix; } - inline explicit Transform(const TranslationType& t) { *this = t; } - inline explicit Transform(const UniformScaling& s) { *this = s; } + inline explicit Transform(const TranslationType& t) + { + check_template_params(); + *this = t; + } + inline explicit Transform(const UniformScaling& s) + { + check_template_params(); + *this = s; + } template - inline explicit Transform(const RotationBase& r) { *this = r; } + inline explicit Transform(const RotationBase& r) + { + check_template_params(); + *this = r; + } inline Transform& operator=(const Transform& other) { m_matrix = other.m_matrix; return *this; } @@ -256,20 +274,30 @@ public: template inline explicit Transform(const EigenBase& other) { - internal::transform_construct_from_matrix::run(this, other.derived()); + check_template_params(); + internal::transform_construct_from_matrix::run(this, other.derived()); } /** Set \c *this from a Dim^2 or (Dim+1)^2 matrix. */ template inline Transform& operator=(const EigenBase& other) { - internal::transform_construct_from_matrix::run(this, other.derived()); + internal::transform_construct_from_matrix::run(this, other.derived()); return *this; } - - template - inline Transform(const Transform& other) + + template + inline Transform(const Transform& other) { + check_template_params(); + // only the options change, we can directly copy the matrices + m_matrix = other.matrix(); + } + + template + inline Transform(const Transform& other) + { + check_template_params(); // prevent conversions as: // Affine | AffineCompact | Isometry = Projective EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(OtherMode==int(Projective), Mode==int(Projective)), @@ -294,8 +322,8 @@ public: } else if(OtherModeIsAffineCompact) { - typedef typename Transform::MatrixType OtherMatrixType; - internal::transform_construct_from_matrix::run(this, other.matrix()); + typedef typename Transform::MatrixType OtherMatrixType; + internal::transform_construct_from_matrix::run(this, other.matrix()); } else { @@ -310,6 +338,7 @@ public: template Transform(const ReturnByValue& other) { + check_template_params(); other.evalTo(*this); } @@ -381,9 +410,9 @@ public: * \li a general transformation matrix of size Dim+1 x Dim+1. */ template friend - inline const typename internal::transform_left_product_impl::ResultType + inline const typename internal::transform_left_product_impl::ResultType operator * (const EigenBase &a, const Transform &b) - { return internal::transform_left_product_impl::run(a.derived(),b); } + { return internal::transform_left_product_impl::run(a.derived(),b); } /** \returns The product expression of a transform \a a times a diagonal matrix \a b * @@ -428,12 +457,12 @@ public: } /** Concatenates two different transformations */ - template + template inline const typename internal::transform_transform_product_impl< - Transform,Transform >::ResultType - operator * (const Transform& other) const + Transform,Transform >::ResultType + operator * (const Transform& other) const { - return internal::transform_transform_product_impl >::run(*this,other); + return internal::transform_transform_product_impl >::run(*this,other); } /** \sa MatrixBase::setIdentity() */ @@ -512,13 +541,16 @@ public: * then this function smartly returns a const reference to \c *this. */ template - inline typename internal::cast_return_type >::type cast() const - { return typename internal::cast_return_type >::type(*this); } + inline typename internal::cast_return_type >::type cast() const + { return typename internal::cast_return_type >::type(*this); } /** Copy constructor with scalar type conversion */ template - inline explicit Transform(const Transform& other) - { m_matrix = other.matrix().template cast(); } + inline explicit Transform(const Transform& other) + { + check_template_params(); + m_matrix = other.matrix().template cast(); + } /** \returns \c true if \c *this is approximately equal to \a other, within the precision * determined by \a prec. @@ -568,6 +600,14 @@ public: #ifdef EIGEN_TRANSFORM_PLUGIN #include EIGEN_TRANSFORM_PLUGIN #endif + +protected: + #ifndef EIGEN_PARSED_BY_DOXYGEN + EIGEN_STRONG_INLINE static void check_template_params() + { + EIGEN_STATIC_ASSERT((Options & (DontAlign)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS) + } + #endif }; @@ -616,9 +656,10 @@ typedef Transform Projective3d; * * This function is available only if the token EIGEN_QT_SUPPORT is defined. */ -template -Transform::Transform(const QMatrix& other) +template +Transform::Transform(const QMatrix& other) { + check_template_params(); *this = other; } @@ -626,8 +667,8 @@ Transform::Transform(const QMatrix& other) * * This function is available only if the token EIGEN_QT_SUPPORT is defined. */ -template -Transform& Transform::operator=(const QMatrix& other) +template +Transform& Transform::operator=(const QMatrix& other) { EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE) m_matrix << other.m11(), other.m21(), other.dx(), @@ -642,9 +683,10 @@ Transform& Transform::operator=(const QMatrix& * * This function is available only if the token EIGEN_QT_SUPPORT is defined. */ -template -QMatrix Transform::toQMatrix(void) const +template +QMatrix Transform::toQMatrix(void) const { + check_template_params(); EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE) return QMatrix(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(0,1), m_matrix.coeff(1,1), @@ -655,9 +697,10 @@ QMatrix Transform::toQMatrix(void) const * * This function is available only if the token EIGEN_QT_SUPPORT is defined. */ -template -Transform::Transform(const QTransform& other) +template +Transform::Transform(const QTransform& other) { + check_template_params(); *this = other; } @@ -665,9 +708,10 @@ Transform::Transform(const QTransform& other) * * This function is available only if the token EIGEN_QT_SUPPORT is defined. */ -template -Transform& Transform::operator=(const QTransform& other) +template +Transform& Transform::operator=(const QTransform& other) { + check_template_params(); EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE) m_matrix << other.m11(), other.m21(), other.dx(), other.m12(), other.m22(), other.dy(), @@ -679,8 +723,8 @@ Transform& Transform::operator=(const QTransfo * * This function is available only if the token EIGEN_QT_SUPPORT is defined. */ -template -QTransform Transform::toQTransform(void) const +template +QTransform Transform::toQTransform(void) const { EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE) return QTransform(matrix.coeff(0,0), matrix.coeff(1,0), matrix.coeff(2,0) @@ -697,10 +741,10 @@ QTransform Transform::toQTransform(void) const * by the vector \a other to \c *this and returns a reference to \c *this. * \sa prescale() */ -template +template template -Transform& -Transform::scale(const MatrixBase &other) +Transform& +Transform::scale(const MatrixBase &other) { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim)) EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS) @@ -712,8 +756,8 @@ Transform::scale(const MatrixBase &other) * and returns a reference to \c *this. * \sa prescale(Scalar) */ -template -inline Transform& Transform::scale(Scalar s) +template +inline Transform& Transform::scale(Scalar s) { EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS) linearExt() *= s; @@ -724,10 +768,10 @@ inline Transform& Transform::scale(Scalar s) * by the vector \a other to \c *this and returns a reference to \c *this. * \sa scale() */ -template +template template -Transform& -Transform::prescale(const MatrixBase &other) +Transform& +Transform::prescale(const MatrixBase &other) { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim)) EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS) @@ -739,8 +783,8 @@ Transform::prescale(const MatrixBase &other) * and returns a reference to \c *this. * \sa scale(Scalar) */ -template -inline Transform& Transform::prescale(Scalar s) +template +inline Transform& Transform::prescale(Scalar s) { EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS) m_matrix.template topRows() *= s; @@ -751,10 +795,10 @@ inline Transform& Transform::prescale(Scalar s * to \c *this and returns a reference to \c *this. * \sa pretranslate() */ -template +template template -Transform& -Transform::translate(const MatrixBase &other) +Transform& +Transform::translate(const MatrixBase &other) { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim)) translationExt() += linearExt() * other; @@ -765,10 +809,10 @@ Transform::translate(const MatrixBase &other) * to \c *this and returns a reference to \c *this. * \sa translate() */ -template +template template -Transform& -Transform::pretranslate(const MatrixBase &other) +Transform& +Transform::pretranslate(const MatrixBase &other) { EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim)) if(int(Mode)==int(Projective)) @@ -795,10 +839,10 @@ Transform::pretranslate(const MatrixBase &other) * * \sa rotate(Scalar), class Quaternion, class AngleAxis, prerotate(RotationType) */ -template +template template -Transform& -Transform::rotate(const RotationType& rotation) +Transform& +Transform::rotate(const RotationType& rotation) { linearExt() *= internal::toRotationMatrix(rotation); return *this; @@ -811,10 +855,10 @@ Transform::rotate(const RotationType& rotation) * * \sa rotate() */ -template +template template -Transform& -Transform::prerotate(const RotationType& rotation) +Transform& +Transform::prerotate(const RotationType& rotation) { m_matrix.template block(0,0) = internal::toRotationMatrix(rotation) * m_matrix.template block(0,0); @@ -826,9 +870,9 @@ Transform::prerotate(const RotationType& rotation) * \warning 2D only. * \sa preshear() */ -template -Transform& -Transform::shear(Scalar sx, Scalar sy) +template +Transform& +Transform::shear(Scalar sx, Scalar sy) { EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE) EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS) @@ -842,9 +886,9 @@ Transform::shear(Scalar sx, Scalar sy) * \warning 2D only. * \sa shear() */ -template -Transform& -Transform::preshear(Scalar sx, Scalar sy) +template +Transform& +Transform::preshear(Scalar sx, Scalar sy) { EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE) EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS) @@ -856,8 +900,8 @@ Transform::preshear(Scalar sx, Scalar sy) *** Scaling, Translation and Rotation compatibility *** ******************************************************/ -template -inline Transform& Transform::operator=(const TranslationType& t) +template +inline Transform& Transform::operator=(const TranslationType& t) { linear().setIdentity(); translation() = t.vector(); @@ -865,16 +909,16 @@ inline Transform& Transform::operator=(const T return *this; } -template -inline Transform Transform::operator*(const TranslationType& t) const +template +inline Transform Transform::operator*(const TranslationType& t) const { Transform res = *this; res.translate(t.vector()); return res; } -template -inline Transform& Transform::operator=(const UniformScaling& s) +template +inline Transform& Transform::operator=(const UniformScaling& s) { m_matrix.setZero(); linear().diagonal().fill(s.factor()); @@ -882,17 +926,17 @@ inline Transform& Transform::operator=(const U return *this; } -template -inline Transform Transform::operator*(const UniformScaling& s) const +template +inline Transform Transform::operator*(const UniformScaling& s) const { Transform res = *this; res.scale(s.factor()); return res; } -template +template template -inline Transform& Transform::operator=(const RotationBase& r) +inline Transform& Transform::operator=(const RotationBase& r) { linear() = internal::toRotationMatrix(r); translation().setZero(); @@ -900,9 +944,9 @@ inline Transform& Transform::operator=(const R return *this; } -template +template template -inline Transform Transform::operator*(const RotationBase& r) const +inline Transform Transform::operator*(const RotationBase& r) const { Transform res = *this; res.rotate(r.derived()); @@ -920,9 +964,9 @@ inline Transform Transform::operator*(const Ro * * \sa computeRotationScaling(), computeScalingRotation(), class SVD */ -template -typename Transform::LinearMatrixType -Transform::rotation() const +template +typename Transform::LinearMatrixType +Transform::rotation() const { LinearMatrixType result; computeRotationScaling(&result, (LinearMatrixType*)0); @@ -941,9 +985,9 @@ Transform::rotation() const * * \sa computeScalingRotation(), rotation(), class SVD */ -template +template template -void Transform::computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const +void Transform::computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const { JacobiSVD svd(linear(), ComputeFullU | ComputeFullV); @@ -970,9 +1014,9 @@ void Transform::computeRotationScaling(RotationMatrixType *rota * * \sa computeRotationScaling(), rotation(), class SVD */ -template +template template -void Transform::computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const +void Transform::computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const { JacobiSVD svd(linear(), ComputeFullU | ComputeFullV); @@ -991,10 +1035,10 @@ void Transform::computeScalingRotation(ScalingMatrixType *scali /** Convenient method to set \c *this from a position, orientation and scale * of a 3D object. */ -template +template template -Transform& -Transform::fromPositionOrientationScale(const MatrixBase &position, +Transform& +Transform::fromPositionOrientationScale(const MatrixBase &position, const OrientationType& orientation, const MatrixBase &scale) { linear() = internal::toRotationMatrix(orientation); @@ -1045,9 +1089,9 @@ struct projective_transform_inverse * * \sa MatrixBase::inverse() */ -template -Transform -Transform::inverse(TransformTraits hint) const +template +Transform +Transform::inverse(TransformTraits hint) const { Transform res; if (hint == Projective) @@ -1103,10 +1147,10 @@ struct transform_take_affine_part > { *** Specializations of construct from matrix *** *****************************************************/ -template -struct transform_construct_from_matrix +template +struct transform_construct_from_matrix { - static inline void run(Transform *transform, const Other& other) + static inline void run(Transform *transform, const Other& other) { transform->linear() = other; transform->translation().setZero(); @@ -1114,25 +1158,25 @@ struct transform_construct_from_matrix } }; -template -struct transform_construct_from_matrix +template +struct transform_construct_from_matrix { - static inline void run(Transform *transform, const Other& other) + static inline void run(Transform *transform, const Other& other) { transform->affine() = other; transform->makeAffine(); } }; -template -struct transform_construct_from_matrix +template +struct transform_construct_from_matrix { - static inline void run(Transform *transform, const Other& other) + static inline void run(Transform *transform, const Other& other) { transform->matrix() = other; } }; -template -struct transform_construct_from_matrix +template +struct transform_construct_from_matrix { static inline void run(Transform *transform, const Other& other) { transform->matrix() = other.template block(0,0); } @@ -1204,23 +1248,23 @@ struct transform_right_product_impl< TransformType, MatrixType, false > **********************************************************/ // generic HDim x HDim matrix * T => Projective -template -struct transform_left_product_impl +template +struct transform_left_product_impl { - typedef Transform TransformType; + typedef Transform TransformType; typedef typename TransformType::MatrixType MatrixType; - typedef Transform ResultType; + typedef Transform ResultType; static ResultType run(const Other& other,const TransformType& tr) { return ResultType(other * tr.matrix()); } }; // generic HDim x HDim matrix * AffineCompact => Projective -template -struct transform_left_product_impl +template +struct transform_left_product_impl { - typedef Transform TransformType; + typedef Transform TransformType; typedef typename TransformType::MatrixType MatrixType; - typedef Transform ResultType; + typedef Transform ResultType; static ResultType run(const Other& other,const TransformType& tr) { ResultType res; @@ -1231,10 +1275,10 @@ struct transform_left_product_impl }; // affine matrix * T -template -struct transform_left_product_impl +template +struct transform_left_product_impl { - typedef Transform TransformType; + typedef Transform TransformType; typedef typename TransformType::MatrixType MatrixType; typedef TransformType ResultType; static ResultType run(const Other& other,const TransformType& tr) @@ -1247,10 +1291,10 @@ struct transform_left_product_impl }; // affine matrix * AffineCompact -template -struct transform_left_product_impl +template +struct transform_left_product_impl { - typedef Transform TransformType; + typedef Transform TransformType; typedef typename TransformType::MatrixType MatrixType; typedef TransformType ResultType; static ResultType run(const Other& other,const TransformType& tr) @@ -1263,10 +1307,10 @@ struct transform_left_product_impl }; // linear matrix * T -template -struct transform_left_product_impl +template +struct transform_left_product_impl { - typedef Transform TransformType; + typedef Transform TransformType; typedef typename TransformType::MatrixType MatrixType; typedef TransformType ResultType; static ResultType run(const Other& other, const TransformType& tr) @@ -1284,13 +1328,13 @@ struct transform_left_product_impl *** Specializations of operator* with another Transform *** **********************************************************/ -template -struct transform_transform_product_impl,Transform,false > +template +struct transform_transform_product_impl,Transform,false > { enum { ResultMode = transform_product_result::Mode }; - typedef Transform Lhs; - typedef Transform Rhs; - typedef Transform ResultType; + typedef Transform Lhs; + typedef Transform Rhs; + typedef Transform ResultType; static ResultType run(const Lhs& lhs, const Rhs& rhs) { ResultType res; @@ -1301,11 +1345,11 @@ struct transform_transform_product_impl,Transform< } }; -template -struct transform_transform_product_impl,Transform,true > +template +struct transform_transform_product_impl,Transform,true > { - typedef Transform Lhs; - typedef Transform Rhs; + typedef Transform Lhs; + typedef Transform Rhs; typedef Transform ResultType; static ResultType run(const Lhs& lhs, const Rhs& rhs) { diff --git a/Eigen/src/Geometry/Translation.h b/Eigen/src/Geometry/Translation.h index f442d825e..d8fe50f98 100644 --- a/Eigen/src/Geometry/Translation.h +++ b/Eigen/src/Geometry/Translation.h @@ -132,8 +132,8 @@ public: } /** Concatenates a translation and a transformation */ - template - inline Transform operator* (const Transform& t) const + template + inline Transform operator* (const Transform& t) const { Transform res = t; res.pretranslate(m_coeffs); diff --git a/test/geo_transformations.cpp b/test/geo_transformations.cpp index 43a4aeedd..317ed9a31 100644 --- a/test/geo_transformations.cpp +++ b/test/geo_transformations.cpp @@ -27,7 +27,7 @@ #include #include -template void non_projective_only(void) +template void non_projective_only() { /* this test covers the following files: Cross.h Quaternion.h, Transform.cpp @@ -40,10 +40,10 @@ template void non_projective_only(void) typedef Matrix Vector4; typedef Quaternion Quaternionx; typedef AngleAxis AngleAxisx; - typedef Transform Transform2; - typedef Transform Transform3; - typedef Transform Isometry2; - typedef Transform Isometry3; + typedef Transform Transform2; + typedef Transform Transform3; + typedef Transform Isometry2; + typedef Transform Isometry3; typedef typename Transform3::MatrixType MatrixType; typedef DiagonalMatrix AlignedScaling2; typedef DiagonalMatrix AlignedScaling3; @@ -102,7 +102,7 @@ template void non_projective_only(void) VERIFY_IS_APPROX((t0 * v1).template head<3>(), AlignedScaling3(v0) * v1); } -template void transformations(void) +template void transformations() { /* this test covers the following files: Cross.h Quaternion.h, Transform.cpp @@ -115,10 +115,10 @@ template void transformations(void) typedef Matrix Vector4; typedef Quaternion Quaternionx; typedef AngleAxis AngleAxisx; - typedef Transform Transform2; - typedef Transform Transform3; - typedef Transform Isometry2; - typedef Transform Isometry3; + typedef Transform Transform2; + typedef Transform Transform3; + typedef Transform Isometry2; + typedef Transform Isometry3; typedef typename Transform3::MatrixType MatrixType; typedef DiagonalMatrix AlignedScaling2; typedef DiagonalMatrix AlignedScaling3; @@ -427,15 +427,45 @@ template void transformations(void) } +template void transform_alignment() +{ + typedef Transform Projective4a; + typedef Transform Projective4u; + + EIGEN_ALIGN16 Scalar array1[16]; + EIGEN_ALIGN16 Scalar array2[16]; + EIGEN_ALIGN16 Scalar array3[16+1]; + Scalar* array3u = array3+1; + + Projective4a *p1 = ::new(reinterpret_cast(array1)) Projective4a; + Projective4u *p2 = ::new(reinterpret_cast(array2)) Projective4u; + Projective4u *p3 = ::new(reinterpret_cast(array3u)) Projective4u; + + p1->matrix().setRandom(); + *p2 = *p1; + *p3 = *p1; + + VERIFY_IS_APPROX(p1->matrix(), p2->matrix()); + VERIFY_IS_APPROX(p1->matrix(), p3->matrix()); + + VERIFY_IS_APPROX( (*p1) * (*p1), (*p2)*(*p3)); + + #ifdef EIGEN_VECTORIZE + VERIFY_RAISES_ASSERT((::new(reinterpret_cast(array3u)) Projective4a)); + #endif +} + void test_geo_transformations() { for(int i = 0; i < g_repeat; i++) { - CALL_SUBTEST_1(( transformations() )); - CALL_SUBTEST_1(( non_projective_only() )); + CALL_SUBTEST_1(( transformations() )); + CALL_SUBTEST_1(( non_projective_only() )); - CALL_SUBTEST_2(( transformations() )); - CALL_SUBTEST_2(( non_projective_only() )); + CALL_SUBTEST_2(( transformations() )); + CALL_SUBTEST_2(( non_projective_only() )); - CALL_SUBTEST_3(( transformations() )); + CALL_SUBTEST_3(( transformations() )); + CALL_SUBTEST_3(( transformations() )); + CALL_SUBTEST_3(( transform_alignment() )); } }