diff options
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/Core/MapBase.h | 4 | ||||
-rw-r--r-- | Eigen/src/Core/util/ForwardDeclarations.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/util/StaticAssert.h | 2 | ||||
-rw-r--r-- | Eigen/src/Geometry/Hyperplane.h | 2 | ||||
-rw-r--r-- | Eigen/src/Geometry/RotationBase.h | 4 | ||||
-rw-r--r-- | Eigen/src/Geometry/Scaling.h | 6 | ||||
-rw-r--r-- | Eigen/src/Geometry/Transform.h | 99 | ||||
-rw-r--r-- | Eigen/src/Geometry/Translation.h | 2 |
8 files changed, 63 insertions, 58 deletions
diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h index 3aa08aa8b..f7f9ccdb7 100644 --- a/Eigen/src/Core/MapBase.h +++ b/Eigen/src/Core/MapBase.h @@ -189,8 +189,8 @@ template<typename Derived> class MapBase EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(ei_traits<Derived>::Flags&PacketAccessBit, ei_inner_stride_at_compile_time<Derived>::ret==1), PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1); - ei_assert(EIGEN_IMPLIES(ei_traits<Derived>::Flags&AlignedBit, (size_t(m_data)&(sizeof(Scalar)*ei_packet_traits<Scalar>::size-1))==0) - && "data is not aligned"); + ei_assert(EIGEN_IMPLIES(ei_traits<Derived>::Flags&AlignedBit, (size_t(m_data) % 16 == 0)) + && "data is not aligned"); } const Scalar* EIGEN_RESTRICT m_data; diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index 423aa110e..84fa52ffb 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -180,7 +180,7 @@ template<typename Derived> class QuaternionBase; template<typename Scalar> class Quaternion; template<typename Scalar> class Rotation2D; template<typename Scalar> class AngleAxis; -template<typename Scalar,int Dim,int Mode=Projective> class Transform; +template<typename Scalar,int Dim,int Mode> class Transform; template <typename _Scalar, int _AmbientDim> class ParametrizedLine; template <typename _Scalar, int _AmbientDim> class Hyperplane; template<typename Scalar,int Dim> class Translation; diff --git a/Eigen/src/Core/util/StaticAssert.h b/Eigen/src/Core/util/StaticAssert.h index 23fb84c6c..eb7f3ef50 100644 --- a/Eigen/src/Core/util/StaticAssert.h +++ b/Eigen/src/Core/util/StaticAssert.h @@ -90,7 +90,7 @@ PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1, THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS, YOU_CANNOT_MIX_ARRAYS_AND_MATRICES, - YOU_CANT_CONVERT_A_PROJECTIVE_TRANSFORM_INTO_AN_AFFINE_TRANSFORM + YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION }; }; diff --git a/Eigen/src/Geometry/Hyperplane.h b/Eigen/src/Geometry/Hyperplane.h index 9a2e878a5..7b7d33a92 100644 --- a/Eigen/src/Geometry/Hyperplane.h +++ b/Eigen/src/Geometry/Hyperplane.h @@ -228,7 +228,7 @@ public: * or a more generic Affine transformation. The default is Affine. * Other kind of transformations are not supported. */ - inline Hyperplane& transform(const Transform<Scalar,AmbientDimAtCompileTime>& t, + inline Hyperplane& transform(const Transform<Scalar,AmbientDimAtCompileTime,Affine>& t, TransformTraits traits = Affine) { transform(t.linear(), traits); diff --git a/Eigen/src/Geometry/RotationBase.h b/Eigen/src/Geometry/RotationBase.h index 4f0eeca20..36f17584f 100644 --- a/Eigen/src/Geometry/RotationBase.h +++ b/Eigen/src/Geometry/RotationBase.h @@ -64,8 +64,8 @@ class RotationBase inline Derived inverse() const { return derived().inverse(); } /** \returns the concatenation of the rotation \c *this with a translation \a t */ - inline Transform<Scalar,Dim> operator*(const Translation<Scalar,Dim>& t) const - { return toRotationMatrix() * t; } + inline Transform<Scalar,Dim,Isometry> operator*(const Translation<Scalar,Dim>& t) const + { return Transform<Scalar,Dim,Isometry>(*this) * t; } /** \returns the concatenation of the rotation \c *this with a uniform scaling \a s */ inline RotationMatrixType operator*(const UniformScaling<Scalar>& s) const diff --git a/Eigen/src/Geometry/Scaling.h b/Eigen/src/Geometry/Scaling.h index 2bcf48630..05b3e0526 100644 --- a/Eigen/src/Geometry/Scaling.h +++ b/Eigen/src/Geometry/Scaling.h @@ -69,7 +69,7 @@ public: /** Concatenates a uniform scaling and a translation */ template<int Dim> - inline Transform<Scalar,Dim> operator* (const Translation<Scalar,Dim>& t) const; + inline Transform<Scalar,Dim,Affine> operator* (const Translation<Scalar,Dim>& t) const; /** Concatenates a uniform scaling and an affine transformation */ template<int Dim, int Mode> @@ -158,10 +158,10 @@ typedef DiagonalMatrix<double,3> AlignedScaling3d; template<typename Scalar> template<int Dim> -inline Transform<Scalar,Dim> +inline Transform<Scalar,Dim,Affine> UniformScaling<Scalar>::operator* (const Translation<Scalar,Dim>& t) const { - Transform<Scalar,Dim> res; + Transform<Scalar,Dim,Affine> res; res.matrix().setZero(); res.linear().diagonal().fill(factor()); res.translation() = factor() * t.vector(); diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 214b286bd..702e87663 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -26,6 +26,14 @@ #ifndef EIGEN_TRANSFORM_H #define EIGEN_TRANSFORM_H +template<typename Transform, typename OtherTransform> +struct ei_is_any_projective +{ + static const bool value = + ((int)Transform::Mode == Projective) || + ((int)OtherTransform::Mode == Projective); +}; + // Note that we have to pass Dim and HDim because it is not allowed to use a template // parameter to define a template specialization. To be more precise, in the following // specializations, it is not allowed to use Dim+1 instead of HDim. @@ -47,7 +55,10 @@ template< typename Other, int OtherCols=Other::ColsAtCompileTime> struct ei_transform_left_product_impl; -template<typename Lhs,typename Rhs> struct ei_transform_transform_product_impl; +template<typename Lhs, + typename Rhs, + bool AnyProjective = ei_is_any_projective<Lhs,Rhs>::value > +struct ei_transform_transform_product_impl; template< typename Other, int Mode, @@ -243,8 +254,15 @@ public: template<int OtherMode> inline Transform(const Transform<Scalar,Dim,OtherMode>& other) { + // prevent conversions as: + // Affine | AffineCompact | Isometry = Projective EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(OtherMode==int(Projective), Mode==int(Projective)), - YOU_CANT_CONVERT_A_PROJECTIVE_TRANSFORM_INTO_AN_AFFINE_TRANSFORM) + YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION) + + // prevent conversions as: + // Isometry = Affine | AffineCompact + EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(OtherMode==int(Affine)||OtherMode==int(AffineCompact), Mode!=int(Isometry)), + YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION) enum { ModeIsAffineCompact = Mode == int(AffineCompact), OtherModeIsAffineCompact = OtherMode == int(AffineCompact) @@ -252,7 +270,11 @@ public: if(ModeIsAffineCompact == OtherModeIsAffineCompact) { - m_matrix = other.matrix(); + // We need the block expression because the code is compiled for all + // combinations of transformations and will trigger a compile time error + // if one tries to assign the matrices directly + m_matrix.template block<Dim,Dim+1>(0,0) = other.matrix().template block<Dim,Dim+1>(0,0); + makeAffine(); } else if(OtherModeIsAffineCompact) { @@ -499,15 +521,6 @@ public: }; /** \ingroup Geometry_Module */ -typedef Transform<float,2> Transform2f; -/** \ingroup Geometry_Module */ -typedef Transform<float,3> Transform3f; -/** \ingroup Geometry_Module */ -typedef Transform<double,2> Transform2d; -/** \ingroup Geometry_Module */ -typedef Transform<double,3> Transform3d; - -/** \ingroup Geometry_Module */ typedef Transform<float,2,Isometry> Isometry2f; /** \ingroup Geometry_Module */ typedef Transform<float,3,Isometry> Isometry3f; @@ -981,6 +994,7 @@ Transform<Scalar,Dim,Mode>::inverse(TransformTraits hint) const // translation and remaining parts res.matrix().template topRightCorner<Dim,1>() = - res.matrix().template topLeftCorner<Dim,Dim>() * translation(); + res.makeAffine(); // we do need this, because in the beginning res is uninitialized } return res; } @@ -1058,7 +1072,18 @@ template<typename Lhs, typename D2> struct ei_general_product_return_type<Lhs, M template<typename D1, typename Rhs> struct ei_general_product_return_type<MatrixBase<D1>, Rhs > { typedef D1 Type; }; - +template<int LhsMode,int RhsMode> +struct ei_transform_product_result +{ + enum + { + Mode = + (LhsMode == (int)Projective || RhsMode == (int)Projective ) ? Projective : + (LhsMode == (int)Affine || RhsMode == (int)Affine ) ? Affine : + (LhsMode == (int)AffineCompact || RhsMode == (int)AffineCompact ) ? AffineCompact : + (LhsMode == (int)Isometry || RhsMode == (int)Isometry ) ? Isometry : Projective + }; +}; // Projective * set of homogeneous column vectors template<typename Other, int Dim, int HDim> @@ -1281,52 +1306,32 @@ struct ei_transform_left_product_impl<Other,Mode,Dim,HDim, Dim,Dim> *** Specializations of operator* with another Transform *** **********************************************************/ -template<typename Scalar, int Dim, int Mode> -struct ei_transform_transform_product_impl<Transform<Scalar,Dim,Mode>,Transform<Scalar,Dim,Mode> > -{ - typedef Transform<Scalar,Dim,Mode> TransformType; - typedef TransformType ResultType; - static ResultType run(const TransformType& lhs, const TransformType& rhs) - { - return ResultType(lhs.matrix() * rhs.matrix()); - } -}; - -template<typename Scalar, int Dim> -struct ei_transform_transform_product_impl<Transform<Scalar,Dim,AffineCompact>,Transform<Scalar,Dim,AffineCompact> > -{ - typedef Transform<Scalar,Dim,AffineCompact> TransformType; - typedef TransformType ResultType; - static ResultType run(const TransformType& lhs, const TransformType& rhs) - { - return ei_transform_right_product_impl<typename TransformType::MatrixType, - AffineCompact,Dim,Dim+1>::run(lhs,rhs.matrix()); - } -}; - template<typename Scalar, int Dim, int LhsMode, int RhsMode> -struct ei_transform_transform_product_impl<Transform<Scalar,Dim,LhsMode>,Transform<Scalar,Dim,RhsMode> > +struct ei_transform_transform_product_impl<Transform<Scalar,Dim,LhsMode>,Transform<Scalar,Dim,RhsMode>,false > { + enum { ResultMode = ei_transform_product_result<LhsMode,RhsMode>::Mode }; typedef Transform<Scalar,Dim,LhsMode> Lhs; typedef Transform<Scalar,Dim,RhsMode> Rhs; - typedef typename ei_transform_right_product_impl<typename Rhs::MatrixType, - LhsMode,Dim,Dim+1>::ResultType ResultType; + typedef Transform<Scalar,Dim,ResultMode> ResultType; static ResultType run(const Lhs& lhs, const Rhs& rhs) { - return ei_transform_right_product_impl<typename Rhs::MatrixType,LhsMode,Dim,Dim+1>::run(lhs,rhs.matrix()); + ResultType res; + res.linear() = lhs.linear() * rhs.linear(); + res.translation() = lhs.linear() * rhs.translation() + lhs.translation(); + res.makeAffine(); + return res; } }; -template<typename Scalar, int Dim> -struct ei_transform_transform_product_impl<Transform<Scalar,Dim,AffineCompact>, - Transform<Scalar,Dim,Affine> > +template<typename Scalar, int Dim, int LhsMode, int RhsMode> +struct ei_transform_transform_product_impl<Transform<Scalar,Dim,LhsMode>,Transform<Scalar,Dim,RhsMode>,true > { - typedef Transform<Scalar,Dim,AffineCompact> Lhs; - typedef Transform<Scalar,Dim,Affine> Rhs; - typedef Transform<Scalar,Dim,AffineCompact> ResultType; + typedef Transform<Scalar,Dim,LhsMode> Lhs; + typedef Transform<Scalar,Dim,RhsMode> Rhs; + typedef Transform<Scalar,Dim,Projective> ResultType; static ResultType run(const Lhs& lhs, const Rhs& rhs) { - return ResultType(lhs.matrix() * rhs.matrix()); + return ResultType( lhs.matrix() * rhs.matrix() ); } }; diff --git a/Eigen/src/Geometry/Translation.h b/Eigen/src/Geometry/Translation.h index 7a3482c8c..59d3e4a41 100644 --- a/Eigen/src/Geometry/Translation.h +++ b/Eigen/src/Geometry/Translation.h @@ -131,7 +131,7 @@ public: return res; } - /** Concatenates a translation and an affine transformation */ + /** Concatenates a translation and a transformation */ template<int Mode> inline Transform<Scalar,Dim,Mode> operator* (const Transform<Scalar,Dim,Mode>& t) const { |