12 #ifndef EIGEN_TRANSFORM_H
13 #define EIGEN_TRANSFORM_H
15 #include "./InternalHeaderCheck.h"
21 template<
typename Transform>
22 struct transform_traits
27 HDim = Transform::HDim,
28 Mode = Transform::Mode,
33 template<
typename TransformType,
35 int Case = transform_traits<TransformType>::IsProjective ? 0
36 : int(MatrixType::RowsAtCompileTime) == int(transform_traits<TransformType>::HDim) ? 1
38 int RhsCols = MatrixType::ColsAtCompileTime>
39 struct transform_right_product_impl;
41 template<
typename Other,
46 int OtherRows=Other::RowsAtCompileTime,
47 int OtherCols=Other::ColsAtCompileTime>
48 struct transform_left_product_impl;
50 template<
typename Lhs,
53 transform_traits<Lhs>::IsProjective ||
54 transform_traits<Rhs>::IsProjective>
55 struct transform_transform_product_impl;
57 template<
typename Other,
62 int OtherRows=Other::RowsAtCompileTime,
63 int OtherCols=Other::ColsAtCompileTime>
64 struct transform_construct_from_matrix;
66 template<
typename TransformType>
struct transform_take_affine_part;
68 template<
typename Scalar_,
int Dim_,
int Mode_,
int Options_>
69 struct traits<Transform<Scalar_,Dim_,Mode_,Options_> >
71 typedef Scalar_ Scalar;
73 typedef Dense StorageKind;
75 Dim1 = Dim_==
Dynamic ? Dim_ : Dim_ + 1,
76 RowsAtCompileTime = Mode_==
Projective ? Dim1 : Dim_,
77 ColsAtCompileTime = Dim1,
78 MaxRowsAtCompileTime = RowsAtCompileTime,
79 MaxColsAtCompileTime = ColsAtCompileTime,
84 template<
int Mode>
struct transform_make_affine;
205 template<
typename Scalar_,
int Dim_,
int Mode_,
int Options_>
249 enum { TransformTimeDiagonalMode = ((Mode==int(
Isometry))?
Affine:
int(Mode)) };
263 check_template_params();
269 check_template_params();
272 EIGEN_DEVICE_FUNC
inline explicit Transform(
const UniformScaling<Scalar>& s)
274 check_template_params();
277 template<
typename Derived>
278 EIGEN_DEVICE_FUNC
inline explicit Transform(
const RotationBase<Derived, Dim>& r)
280 check_template_params();
284 typedef internal::transform_take_affine_part<Transform> take_affine_part;
287 template<
typename OtherDerived>
290 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
291 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
293 check_template_params();
294 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
298 template<
typename OtherDerived>
301 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
302 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
304 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
308 template<
int OtherOptions>
311 check_template_params();
313 m_matrix = other.
matrix();
316 template<
int OtherMode,
int OtherOptions>
317 EIGEN_DEVICE_FUNC
inline Transform(
const Transform<Scalar,Dim,OtherMode,OtherOptions>& other)
319 check_template_params();
322 EIGEN_STATIC_ASSERT(internal::check_implication(OtherMode==
int(
Projective), Mode==
int(
Projective)),
323 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
328 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
334 if(EIGEN_CONST_CONDITIONAL(ModeIsAffineCompact == OtherModeIsAffineCompact))
339 m_matrix.template block<Dim,Dim+1>(0,0) = other.matrix().template block<Dim,Dim+1>(0,0);
342 else if(EIGEN_CONST_CONDITIONAL(OtherModeIsAffineCompact))
345 internal::transform_construct_from_matrix<OtherMatrixType,Mode,Options,Dim,HDim>::run(
this, other.matrix());
352 linear() = other.linear();
357 template<
typename OtherDerived>
358 EIGEN_DEVICE_FUNC
Transform(
const ReturnByValue<OtherDerived>& other)
360 check_template_params();
364 template<
typename OtherDerived>
371 #ifdef EIGEN_QT_SUPPORT
372 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
375 inline QMatrix toQMatrix(
void)
const;
377 inline Transform(
const QTransform& other);
382 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
Index rows() const EIGEN_NOEXCEPT {
return int(Mode)==int(
Projective) ? m_matrix.cols() : (m_matrix.cols()-1); }
383 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
Index cols() const EIGEN_NOEXCEPT {
return m_matrix.cols(); }
437 template<
typename OtherDerived>
438 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const typename internal::transform_right_product_impl<Transform, OtherDerived>::ResultType
440 {
return internal::transform_right_product_impl<Transform, OtherDerived>::run(*
this,other.
derived()); }
449 template<
typename OtherDerived>
friend
450 EIGEN_DEVICE_FUNC
inline const typename internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim_,Dim_+1>::ResultType
452 {
return internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim,HDim>::run(a.
derived(),b); }
460 template<
typename DiagonalDerived>
465 res.linearExt() *= b;
475 template<
typename DiagonalDerived>
487 template<
typename OtherDerived>
493 return internal::transform_transform_product_impl<Transform,Transform>::run(*
this,other);
505 template<
int OtherMode,
int OtherOptions>
struct icc_11_workaround
507 typedef internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> > ProductType;
508 typedef typename ProductType::ResultType ResultType;
513 template<
int OtherMode,
int OtherOptions>
514 inline typename icc_11_workaround<OtherMode,OtherOptions>::ResultType
515 operator * (
const Transform<Scalar,Dim,OtherMode,OtherOptions>& other)
const
517 typedef typename icc_11_workaround<OtherMode,OtherOptions>::ProductType ProductType;
518 return ProductType::run(*
this,other);
522 template<
int OtherMode,
int OtherOptions>
523 EIGEN_DEVICE_FUNC
inline typename internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::ResultType
526 return internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::run(*
this,other);
542 template<
typename OtherDerived>
546 template<
typename OtherDerived>
553 template<
typename OtherDerived>
557 template<
typename OtherDerived>
561 template<
typename RotationType>
565 template<
typename RotationType>
583 inline Transform& operator*=(
const UniformScaling<Scalar>& s) {
return scale(s.factor()); }
589 res.scale(s.factor());
594 inline Transform& operator*=(
const DiagonalMatrix<Scalar,Dim>& s) { linearExt() *= s;
return *
this; }
596 template<
typename Derived>
598 template<
typename Derived>
599 EIGEN_DEVICE_FUNC
inline Transform& operator*=(
const RotationBase<Derived,Dim>& r) {
return rotate(r.toRotationMatrix()); }
600 template<
typename Derived>
601 EIGEN_DEVICE_FUNC
inline Transform operator*(
const RotationBase<Derived,Dim>& r)
const;
604 EIGEN_DEVICE_FUNC RotationReturnType
rotation()
const;
606 template<
typename RotationMatrixType,
typename ScalingMatrixType>
609 template<
typename ScalingMatrixType,
typename RotationMatrixType>
613 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
615 Transform& fromPositionOrientationScale(
const MatrixBase<PositionDerived> &position,
616 const OrientationType& orientation,
const MatrixBase<ScaleDerived> &scale);
631 template<
typename NewScalarType>
632 EIGEN_DEVICE_FUNC
inline typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type
cast()
const
633 {
return typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type(*
this); }
636 template<
typename OtherScalarType>
639 check_template_params();
640 m_matrix = other.
matrix().template cast<Scalar>();
648 {
return m_matrix.
isApprox(other.m_matrix, prec); }
654 internal::transform_make_affine<int(Mode)>::run(m_matrix);
662 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
667 EIGEN_DEVICE_FUNC
inline const Block<
MatrixType,int(Mode)==int(
Projective)?HDim:Dim,Dim> linearExt()
const
668 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
674 EIGEN_DEVICE_FUNC
inline Block<
MatrixType,int(Mode)==int(
Projective)?HDim:Dim,1> translationExt()
675 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
680 EIGEN_DEVICE_FUNC
inline const Block<
MatrixType,int(Mode)==int(
Projective)?HDim:Dim,1> translationExt()
const
681 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
684 #ifdef EIGEN_TRANSFORM_PLUGIN
685 #include EIGEN_TRANSFORM_PLUGIN
689 #ifndef EIGEN_PARSED_BY_DOXYGEN
690 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void check_template_params()
692 EIGEN_STATIC_ASSERT((Options & (
DontAlign|
RowMajor)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)
699 typedef Transform<float,2,Isometry> Isometry2f;
701 typedef Transform<float,3,Isometry> Isometry3f;
703 typedef Transform<double,2,Isometry> Isometry2d;
705 typedef Transform<double,3,Isometry> Isometry3d;
708 typedef Transform<float,2,Affine> Affine2f;
710 typedef Transform<float,3,Affine> Affine3f;
712 typedef Transform<double,2,Affine> Affine2d;
714 typedef Transform<double,3,Affine> Affine3d;
717 typedef Transform<float,2,AffineCompact> AffineCompact2f;
719 typedef Transform<float,3,AffineCompact> AffineCompact3f;
721 typedef Transform<double,2,AffineCompact> AffineCompact2d;
723 typedef Transform<double,3,AffineCompact> AffineCompact3d;
726 typedef Transform<float,2,Projective> Projective2f;
728 typedef Transform<float,3,Projective> Projective3f;
730 typedef Transform<double,2,Projective> Projective2d;
732 typedef Transform<double,3,Projective> Projective3d;
738 #ifdef EIGEN_QT_SUPPORT
740 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
745 template<
typename Scalar,
int Dim,
int Mode,
int Options>
748 check_template_params();
756 template<
typename Scalar,
int Dim,
int Mode,
int Options>
759 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
761 m_matrix << other.m11(), other.m21(), other.dx(),
762 other.m12(), other.m22(), other.dy();
764 m_matrix << other.m11(), other.m21(), other.dx(),
765 other.m12(), other.m22(), other.dy(),
776 template<
typename Scalar,
int Dim,
int Mode,
int Options>
777 QMatrix Transform<Scalar,Dim,Mode,Options>::toQMatrix(
void)
const
779 check_template_params();
780 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
781 return QMatrix(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0),
791 template<
typename Scalar,
int Dim,
int Mode,
int Options>
794 check_template_params();
802 template<
typename Scalar,
int Dim,
int Mode,
int Options>
805 check_template_params();
806 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
808 m_matrix << other.m11(), other.m21(), other.dx(),
809 other.m12(), other.m22(), other.dy();
811 m_matrix << other.m11(), other.m21(), other.dx(),
812 other.m12(), other.m22(), other.dy(),
813 other.m13(), other.m23(), other.m33();
821 template<
typename Scalar,
int Dim,
int Mode,
int Options>
824 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
826 return QTransform(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0),
830 return QTransform(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0), m_matrix.
coeff(2,0),
844 template<
typename Scalar,
int Dim,
int Mode,
int Options>
845 template<
typename OtherDerived>
849 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
850 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
851 linearExt().noalias() = (linearExt() * other.
asDiagonal());
859 template<
typename Scalar,
int Dim,
int Mode,
int Options>
862 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
871 template<
typename Scalar,
int Dim,
int Mode,
int Options>
872 template<
typename OtherDerived>
876 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
877 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
878 affine().noalias() = (other.
asDiagonal() * affine());
886 template<
typename Scalar,
int Dim,
int Mode,
int Options>
889 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
890 m_matrix.template topRows<Dim>() *= s;
898 template<
typename Scalar,
int Dim,
int Mode,
int Options>
899 template<
typename OtherDerived>
903 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
904 translationExt() += linearExt() * other;
912 template<
typename Scalar,
int Dim,
int Mode,
int Options>
913 template<
typename OtherDerived>
917 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
918 if(EIGEN_CONST_CONDITIONAL(
int(Mode)==
int(
Projective)))
919 affine() += other * m_matrix.row(Dim);
921 translation() += other;
942 template<
typename Scalar,
int Dim,
int Mode,
int Options>
943 template<
typename RotationType>
947 linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
958 template<
typename Scalar,
int Dim,
int Mode,
int Options>
959 template<
typename RotationType>
963 m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
964 * m_matrix.template block<Dim,HDim>(0,0);
973 template<
typename Scalar,
int Dim,
int Mode,
int Options>
977 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
978 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
979 VectorType tmp = linear().col(0)*sy + linear().col(1);
980 linear() << linear().col(0) + linear().col(1)*sx, tmp;
989 template<
typename Scalar,
int Dim,
int Mode,
int Options>
993 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
994 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
995 m_matrix.template block<Dim,HDim>(0,0) =
LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
1003 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1007 translation() = t.vector();
1012 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1015 Transform res = *
this;
1016 res.translate(t.vector());
1020 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1024 linear().diagonal().fill(s.factor());
1029 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1030 template<
typename Derived>
1033 linear() = internal::toRotationMatrix<Scalar,Dim>(r);
1034 translation().setZero();
1039 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1040 template<
typename Derived>
1043 Transform res = *
this;
1044 res.rotate(r.derived());
1052 namespace internal {
1053 template<
int Mode>
struct transform_rotation_impl {
1054 template<
typename TransformType>
1055 EIGEN_DEVICE_FUNC
static inline
1056 const typename TransformType::LinearMatrixType run(
const TransformType& t)
1058 typedef typename TransformType::LinearMatrixType LinearMatrixType;
1059 LinearMatrixType result;
1060 t.computeRotationScaling(&result, (LinearMatrixType*)0);
1064 template<>
struct transform_rotation_impl<
Isometry> {
1065 template<
typename TransformType>
1066 EIGEN_DEVICE_FUNC
static inline
1067 typename TransformType::ConstLinearPart run(
const TransformType& t)
1083 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1085 typename Transform<Scalar,Dim,Mode,Options>::RotationReturnType
1088 return internal::transform_rotation_impl<Mode>::run(*
this);
1103 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1104 template<
typename RotationMatrixType,
typename ScalingMatrixType>
1133 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1134 template<
typename ScalingMatrixType,
typename RotationMatrixType>
1155 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1156 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
1161 linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1163 translation() = position;
1168 namespace internal {
1171 struct transform_make_affine
1173 template<
typename MatrixType>
1174 EIGEN_DEVICE_FUNC
static void run(MatrixType &mat)
1176 static const int Dim = MatrixType::ColsAtCompileTime-1;
1177 mat.template block<1,Dim>(Dim,0).setZero();
1178 mat.coeffRef(Dim,Dim) =
typename MatrixType::Scalar(1);
1185 template<
typename MatrixType> EIGEN_DEVICE_FUNC
static void run(MatrixType &) { }
1189 template<
typename TransformType,
int Mode=TransformType::Mode>
1190 struct projective_transform_inverse
1192 EIGEN_DEVICE_FUNC
static inline void run(
const TransformType&, TransformType&)
1196 template<
typename TransformType>
1197 struct projective_transform_inverse<TransformType,
Projective>
1199 EIGEN_DEVICE_FUNC
static inline void run(
const TransformType& m, TransformType& res)
1201 res.matrix() = m.matrix().inverse();
1228 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1229 EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>
1235 internal::projective_transform_inverse<Transform>::run(*
this, res);
1241 res.
matrix().template topLeftCorner<Dim,Dim>() = linear().
transpose();
1245 res.
matrix().template topLeftCorner<Dim,Dim>() = linear().
inverse();
1249 eigen_assert(
false &&
"Invalid transform traits in Transform::Inverse");
1252 res.
matrix().template topRightCorner<Dim,1>()
1253 = - res.
matrix().template topLeftCorner<Dim,Dim>() * translation();
1259 namespace internal {
1265 template<
typename TransformType>
struct transform_take_affine_part {
1266 typedef typename TransformType::MatrixType MatrixType;
1267 typedef typename TransformType::AffinePart AffinePart;
1268 typedef typename TransformType::ConstAffinePart ConstAffinePart;
1269 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE AffinePart run(MatrixType& m)
1270 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1271 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ConstAffinePart run(
const MatrixType& m)
1272 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1275 template<
typename Scalar,
int Dim,
int Options>
1276 struct transform_take_affine_part<Transform<Scalar,Dim,
AffineCompact, Options> > {
1278 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE MatrixType& run(MatrixType& m) {
return m; }
1279 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const MatrixType& run(
const MatrixType& m) {
return m; }
1286 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1287 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1289 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1291 transform->linear() = other;
1292 transform->translation().setZero();
1293 transform->makeAffine();
1297 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1298 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1300 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1302 transform->affine() = other;
1303 transform->makeAffine();
1307 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1308 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1310 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1311 { transform->matrix() = other; }
1314 template<
typename Other,
int Options,
int Dim,
int HDim>
1315 struct transform_construct_from_matrix<Other,
AffineCompact,Options,Dim,HDim, HDim,HDim>
1317 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
void run(Transform<typename Other::Scalar,Dim,AffineCompact,Options> *transform,
const Other& other)
1318 { transform->matrix() = other.template block<Dim,HDim>(0,0); }
1325 template<
int LhsMode,
int RhsMode>
1326 struct transform_product_result
1338 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1339 struct transform_right_product_impl< TransformType, MatrixType, 0, RhsCols>
1341 typedef typename MatrixType::PlainObject ResultType;
1343 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1345 return T.matrix() * other;
1349 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1350 struct transform_right_product_impl< TransformType, MatrixType, 1, RhsCols>
1353 Dim = TransformType::Dim,
1354 HDim = TransformType::HDim,
1355 OtherRows = MatrixType::RowsAtCompileTime,
1356 OtherCols = MatrixType::ColsAtCompileTime
1359 typedef typename MatrixType::PlainObject ResultType;
1361 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1363 EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1365 typedef Block<ResultType, Dim, OtherCols, int(MatrixType::RowsAtCompileTime)==Dim> TopLeftLhs;
1367 ResultType res(other.rows(),other.cols());
1368 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1369 res.row(OtherRows-1) = other.row(OtherRows-1);
1375 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1376 struct transform_right_product_impl< TransformType, MatrixType, 2, RhsCols>
1379 Dim = TransformType::Dim,
1380 HDim = TransformType::HDim,
1381 OtherRows = MatrixType::RowsAtCompileTime,
1382 OtherCols = MatrixType::ColsAtCompileTime
1385 typedef typename MatrixType::PlainObject ResultType;
1387 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1389 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1391 typedef Block<ResultType, Dim, OtherCols, true> TopLeftLhs;
1392 ResultType res(Replicate<typename TransformType::ConstTranslationPart, 1, OtherCols>(T.translation(),1,other.cols()));
1393 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1399 template<
typename TransformType,
typename MatrixType >
1400 struct transform_right_product_impl< TransformType, MatrixType, 2, 1>
1402 typedef typename TransformType::MatrixType TransformMatrix;
1404 Dim = TransformType::Dim,
1405 HDim = TransformType::HDim,
1406 OtherRows = MatrixType::RowsAtCompileTime,
1407 WorkingRows = plain_enum_min(TransformMatrix::RowsAtCompileTime, HDim)
1410 typedef typename MatrixType::PlainObject ResultType;
1412 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1414 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1416 Matrix<typename ResultType::Scalar, Dim+1, 1> rhs;
1417 rhs.template head<Dim>() = other; rhs[Dim] =
typename ResultType::Scalar(1);
1418 Matrix<typename ResultType::Scalar, WorkingRows, 1> res(T.matrix() * rhs);
1419 return res.template head<Dim>();
1428 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1429 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1431 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1432 typedef typename TransformType::MatrixType MatrixType;
1433 typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1434 static ResultType run(
const Other& other,
const TransformType& tr)
1435 {
return ResultType(other * tr.matrix()); }
1439 template<
typename Other,
int Options,
int Dim,
int HDim>
1440 struct transform_left_product_impl<Other,
AffineCompact,Options,Dim,HDim, HDim,HDim>
1442 typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1443 typedef typename TransformType::MatrixType MatrixType;
1444 typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1445 static ResultType run(
const Other& other,
const TransformType& tr)
1448 res.matrix().noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1449 res.matrix().col(Dim) += other.col(Dim);
1455 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1456 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1458 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1459 typedef typename TransformType::MatrixType MatrixType;
1460 typedef TransformType ResultType;
1461 static ResultType run(
const Other& other,
const TransformType& tr)
1464 res.affine().noalias() = other * tr.matrix();
1465 res.matrix().row(Dim) = tr.matrix().row(Dim);
1471 template<
typename Other,
int Options,
int Dim,
int HDim>
1472 struct transform_left_product_impl<Other,
AffineCompact,Options,Dim,HDim, Dim,HDim>
1474 typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1475 typedef typename TransformType::MatrixType MatrixType;
1476 typedef TransformType ResultType;
1477 static ResultType run(
const Other& other,
const TransformType& tr)
1480 res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1481 res.translation() += other.col(Dim);
1487 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1488 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1490 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1491 typedef typename TransformType::MatrixType MatrixType;
1492 typedef TransformType ResultType;
1493 static ResultType run(
const Other& other,
const TransformType& tr)
1497 res.matrix().row(Dim) = tr.matrix().row(Dim);
1498 res.matrix().template topRows<Dim>().noalias()
1499 = other * tr.matrix().template topRows<Dim>();
1508 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1509 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >
1511 enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
1512 typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1513 typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1514 typedef Transform<Scalar,Dim,ResultMode,LhsOptions> ResultType;
1515 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1518 res.linear() = lhs.linear() * rhs.linear();
1519 res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1525 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1526 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >
1528 typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1529 typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1530 typedef Transform<Scalar,Dim,Projective> ResultType;
1531 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1533 return ResultType( lhs.matrix() * rhs.matrix() );
1537 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1538 struct transform_transform_product_impl<Transform<Scalar,Dim,
AffineCompact,LhsOptions>,Transform<Scalar,Dim,
Projective,RhsOptions>,true >
1540 typedef Transform<Scalar,Dim,AffineCompact,LhsOptions> Lhs;
1541 typedef Transform<Scalar,Dim,Projective,RhsOptions> Rhs;
1542 typedef Transform<Scalar,Dim,Projective> ResultType;
1543 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1546 res.matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1547 res.matrix().row(Dim) = rhs.matrix().row(Dim);
1552 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1553 struct transform_transform_product_impl<Transform<Scalar,Dim,
Projective,LhsOptions>,Transform<Scalar,Dim,
AffineCompact,RhsOptions>,true >
1555 typedef Transform<Scalar,Dim,Projective,LhsOptions> Lhs;
1556 typedef Transform<Scalar,Dim,AffineCompact,RhsOptions> Rhs;
1557 typedef Transform<Scalar,Dim,Projective> ResultType;
1558 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1560 ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1561 res.matrix().col(Dim) += lhs.matrix().col(Dim);
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:107
TransposeReturnType transpose()
Definition: Transpose.h:184
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:105
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: JacobiSVD.h:514
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
const DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:327
Derived & setIdentity()
Definition: CwiseNullaryOp.h:875
const Inverse< Derived > inverse() const
Definition: InverseImpl.h:350
static const IdentityReturnType Identity()
Definition: CwiseNullaryOp.h:801
const AdjointReturnType adjoint() const
Definition: Transpose.h:223
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:164
Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:187
const Scalar * data() const
Definition: PlainObjectBase.h:259
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:564
const MatrixVType & matrixV() const
Definition: SVDBase.h:191
const SingularValuesType & singularValues() const
Definition: SVDBase.h:203
const MatrixUType & matrixU() const
Definition: SVDBase.h:175
Represents a translation transformation.
Definition: Translation.h:33
TransformTraits
Definition: Constants.h:457
@ DontAlign
Definition: Constants.h:327
@ RowMajor
Definition: Constants.h:323
@ Affine
Definition: Constants.h:462
@ Projective
Definition: Constants.h:466
@ AffineCompact
Definition: Constants.h:464
@ Isometry
Definition: Constants.h:459
const unsigned int RowMajorBit
Definition: Constants.h:68
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59
const int Dynamic
Definition: Constants.h:24
Definition: EigenBase.h:32
Derived & derived()
Definition: EigenBase.h:48
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231