12 #ifndef EIGEN_TRANSFORM_H 13 #define EIGEN_TRANSFORM_H 19 template<
typename Transform>
20 struct transform_traits
25 HDim = Transform::HDim,
26 Mode = Transform::Mode,
31 template<
typename TransformType,
33 int Case = transform_traits<TransformType>::IsProjective ? 0
34 : int(MatrixType::RowsAtCompileTime) == int(transform_traits<TransformType>::HDim) ? 1
36 int RhsCols = MatrixType::ColsAtCompileTime>
37 struct transform_right_product_impl;
39 template<
typename Other,
44 int OtherRows=Other::RowsAtCompileTime,
45 int OtherCols=Other::ColsAtCompileTime>
46 struct transform_left_product_impl;
48 template<
typename Lhs,
51 transform_traits<Lhs>::IsProjective ||
52 transform_traits<Rhs>::IsProjective>
53 struct transform_transform_product_impl;
55 template<
typename Other,
60 int OtherRows=Other::RowsAtCompileTime,
61 int OtherCols=Other::ColsAtCompileTime>
62 struct transform_construct_from_matrix;
64 template<
typename TransformType>
struct transform_take_affine_part;
66 template<
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
67 struct traits<Transform<_Scalar,_Dim,_Mode,_Options> >
69 typedef _Scalar Scalar;
71 typedef Dense StorageKind;
73 Dim1 = _Dim==
Dynamic ? _Dim : _Dim + 1,
74 RowsAtCompileTime = _Mode==
Projective ? Dim1 : _Dim,
75 ColsAtCompileTime = Dim1,
76 MaxRowsAtCompileTime = RowsAtCompileTime,
77 MaxColsAtCompileTime = ColsAtCompileTime,
82 template<
int Mode>
struct transform_make_affine;
200 template<
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
227 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
231 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
244 enum { TransformTimeDiagonalMode = ((Mode==int(
Isometry))?
Affine:
int(Mode)) };
258 check_template_params();
259 internal::transform_make_affine<(int(Mode)==Affine) ? Affine : AffineCompact>::run(m_matrix);
264 check_template_params();
265 m_matrix = other.m_matrix;
268 inline explicit Transform(
const TranslationType& t)
270 check_template_params();
273 inline explicit Transform(
const UniformScaling<Scalar>& s)
275 check_template_params();
278 template<
typename Derived>
281 check_template_params();
286 { m_matrix = other.m_matrix;
return *
this; }
288 typedef internal::transform_take_affine_part<Transform> take_affine_part;
291 template<
typename OtherDerived>
294 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
295 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
297 check_template_params();
298 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
302 template<
typename OtherDerived>
305 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
306 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
308 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
312 template<
int OtherOptions>
315 check_template_params();
317 m_matrix = other.matrix();
320 template<
int OtherMode,
int OtherOptions>
323 check_template_params();
327 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
332 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
338 if(ModeIsAffineCompact == OtherModeIsAffineCompact)
343 m_matrix.template block<Dim,Dim+1>(0,0) = other.matrix().template block<Dim,Dim+1>(0,0);
346 else if(OtherModeIsAffineCompact)
349 internal::transform_construct_from_matrix<OtherMatrixType,Mode,Options,Dim,HDim>::run(
this, other.matrix());
356 linear() = other.linear();
357 translation() = other.translation();
361 template<
typename OtherDerived>
362 Transform(
const ReturnByValue<OtherDerived>& other)
364 check_template_params();
368 template<
typename OtherDerived>
369 Transform& operator=(
const ReturnByValue<OtherDerived>& other)
375 #ifdef EIGEN_QT_SUPPORT 377 inline Transform& operator=(
const QMatrix& other);
378 inline QMatrix toQMatrix(
void)
const;
379 inline Transform(
const QTransform& other);
380 inline Transform& operator=(
const QTransform& other);
381 inline QTransform toQTransform(
void)
const;
384 Index rows()
const {
return int(Mode)==int(
Projective) ? m_matrix.cols() : (m_matrix.cols()-1); }
385 Index cols()
const {
return m_matrix.cols(); }
389 inline Scalar operator() (Index row, Index col)
const {
return m_matrix(row,col); }
392 inline Scalar& operator() (Index row, Index col) {
return m_matrix(row,col); }
395 inline const MatrixType&
matrix()
const {
return m_matrix; }
397 inline MatrixType&
matrix() {
return m_matrix; }
400 inline ConstLinearPart
linear()
const {
return ConstLinearPart(m_matrix,0,0); }
402 inline LinearPart
linear() {
return LinearPart(m_matrix,0,0); }
405 inline ConstAffinePart
affine()
const {
return take_affine_part::run(m_matrix); }
407 inline AffinePart
affine() {
return take_affine_part::run(m_matrix); }
439 template<
typename OtherDerived>
440 EIGEN_STRONG_INLINE
const typename internal::transform_right_product_impl<Transform, OtherDerived>::ResultType
442 {
return internal::transform_right_product_impl<Transform, OtherDerived>::run(*
this,other.
derived()); }
451 template<
typename OtherDerived>
friend 452 inline const typename internal::transform_left_product_impl<OtherDerived,Mode,Options,_Dim,_Dim+1>::ResultType
454 {
return internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim,HDim>::run(a.
derived(),b); }
462 template<
typename DiagonalDerived>
463 inline const TransformTimeDiagonalReturnType
466 TransformTimeDiagonalReturnType res(*
this);
477 template<
typename DiagonalDerived>
478 friend inline TransformTimeDiagonalReturnType
481 TransformTimeDiagonalReturnType res;
482 res.
linear().noalias() = a*b.linear();
485 res.
matrix().
row(Dim) = b.matrix().row(Dim);
489 template<
typename OtherDerived>
495 return internal::transform_transform_product_impl<Transform,Transform>::run(*
this,other);
507 template<
int OtherMode,
int OtherOptions>
struct icc_11_workaround
509 typedef internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> > ProductType;
510 typedef typename ProductType::ResultType ResultType;
515 template<
int OtherMode,
int OtherOptions>
516 inline typename icc_11_workaround<OtherMode,OtherOptions>::ResultType
519 typedef typename icc_11_workaround<OtherMode,OtherOptions>::ProductType ProductType;
520 return ProductType::run(*
this,other);
524 template<
int OtherMode,
int OtherOptions>
525 inline typename internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::ResultType
528 return internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::run(*
this,other);
541 return Transform(MatrixType::Identity());
544 template<
typename OtherDerived>
547 template<
typename OtherDerived>
550 inline Transform& scale(
const Scalar& s);
551 inline Transform& prescale(
const Scalar& s);
553 template<
typename OtherDerived>
556 template<
typename OtherDerived>
559 template<
typename RotationType>
560 inline Transform& rotate(
const RotationType& rotation);
562 template<
typename RotationType>
563 inline Transform& prerotate(
const RotationType& rotation);
565 Transform& shear(
const Scalar& sx,
const Scalar& sy);
566 Transform& preshear(
const Scalar& sx,
const Scalar& sy);
568 inline Transform& operator=(
const TranslationType& t);
569 inline Transform& operator*=(
const TranslationType& t) {
return translate(t.vector()); }
572 inline Transform& operator=(
const UniformScaling<Scalar>& t);
573 inline Transform& operator*=(
const UniformScaling<Scalar>& s) {
return scale(s.factor()); }
574 inline TransformTimeDiagonalReturnType
operator*(
const UniformScaling<Scalar>& s)
const 576 TransformTimeDiagonalReturnType res = *
this;
577 res.scale(s.factor());
583 template<
typename Derived>
585 template<
typename Derived>
587 template<
typename Derived>
590 const LinearMatrixType rotation()
const;
591 template<
typename RotationMatrixType,
typename ScalingMatrixType>
592 void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling)
const;
593 template<
typename ScalingMatrixType,
typename RotationMatrixType>
594 void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation)
const;
596 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
603 const Scalar*
data()
const {
return m_matrix.
data(); }
612 template<
typename NewScalarType>
613 inline typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type
cast()
const 614 {
return typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type(*
this); }
617 template<
typename OtherScalarType>
620 check_template_params();
621 m_matrix = other.matrix().template cast<Scalar>();
629 {
return m_matrix.
isApprox(other.m_matrix, prec); }
635 internal::transform_make_affine<int(Mode)>::run(m_matrix);
643 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
649 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
656 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
662 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
665 #ifdef EIGEN_TRANSFORM_PLUGIN 666 #include EIGEN_TRANSFORM_PLUGIN 670 #ifndef EIGEN_PARSED_BY_DOXYGEN 671 static EIGEN_STRONG_INLINE
void check_template_params()
673 EIGEN_STATIC_ASSERT((Options & (
DontAlign|
RowMajor)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)
719 #ifdef EIGEN_QT_SUPPORT 724 template<
typename Scalar,
int Dim,
int Mode,
int Options>
727 check_template_params();
735 template<
typename Scalar,
int Dim,
int Mode,
int Options>
738 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
740 m_matrix << other.m11(), other.m21(), other.dx(),
741 other.m12(), other.m22(), other.dy();
743 m_matrix << other.m11(), other.m21(), other.dx(),
744 other.m12(), other.m22(), other.dy(),
755 template<
typename Scalar,
int Dim,
int Mode,
int Options>
758 check_template_params();
759 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
760 return QMatrix(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0),
769 template<
typename Scalar,
int Dim,
int Mode,
int Options>
772 check_template_params();
780 template<
typename Scalar,
int Dim,
int Mode,
int Options>
783 check_template_params();
784 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
786 m_matrix << other.m11(), other.m21(), other.dx(),
787 other.m12(), other.m22(), other.dy();
789 m_matrix << other.m11(), other.m21(), other.dx(),
790 other.m12(), other.m22(), other.dy(),
791 other.m13(), other.m23(), other.m33();
799 template<
typename Scalar,
int Dim,
int Mode,
int Options>
802 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
804 return QTransform(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0),
808 return QTransform(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0), m_matrix.
coeff(2,0),
822 template<
typename Scalar,
int Dim,
int Mode,
int Options>
823 template<
typename OtherDerived>
827 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
828 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
829 linearExt().noalias() = (linearExt() * other.
asDiagonal());
837 template<
typename Scalar,
int Dim,
int Mode,
int Options>
840 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
849 template<
typename Scalar,
int Dim,
int Mode,
int Options>
850 template<
typename OtherDerived>
854 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
855 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
856 m_matrix.template block<Dim,HDim>(0,0).noalias() = (other.
asDiagonal() * m_matrix.template block<Dim,HDim>(0,0));
864 template<
typename Scalar,
int Dim,
int Mode,
int Options>
867 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
868 m_matrix.template topRows<Dim>() *= s;
876 template<
typename Scalar,
int Dim,
int Mode,
int Options>
877 template<
typename OtherDerived>
881 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
882 translationExt() += linearExt() * other;
890 template<
typename Scalar,
int Dim,
int Mode,
int Options>
891 template<
typename OtherDerived>
895 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
897 affine() += other * m_matrix.
row(Dim);
899 translation() += other;
920 template<
typename Scalar,
int Dim,
int Mode,
int Options>
921 template<
typename RotationType>
925 linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
936 template<
typename Scalar,
int Dim,
int Mode,
int Options>
937 template<
typename RotationType>
941 m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
942 * m_matrix.template block<Dim,HDim>(0,0);
951 template<
typename Scalar,
int Dim,
int Mode,
int Options>
955 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
956 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
957 VectorType tmp = linear().col(0)*sy + linear().col(1);
958 linear() << linear().col(0) + linear().col(1)*sx, tmp;
967 template<
typename Scalar,
int Dim,
int Mode,
int Options>
971 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
972 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
973 m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
981 template<
typename Scalar,
int Dim,
int Mode,
int Options>
985 translation() = t.vector();
990 template<
typename Scalar,
int Dim,
int Mode,
int Options>
994 res.translate(t.vector());
998 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1002 linear().diagonal().fill(s.factor());
1007 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1008 template<
typename Derived>
1011 linear() = internal::toRotationMatrix<Scalar,Dim>(r);
1012 translation().setZero();
1017 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1018 template<
typename Derived>
1022 res.rotate(r.derived());
1037 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1041 LinearMatrixType result;
1042 computeRotationScaling(&result, (LinearMatrixType*)0);
1058 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1059 template<
typename RotationMatrixType,
typename ScalingMatrixType>
1064 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1066 sv.coeffRef(0) *= x;
1067 if(scaling) scaling->lazyAssign(svd.
matrixV() * sv.asDiagonal() * svd.
matrixV().adjoint());
1070 LinearMatrixType m(svd.
matrixU());
1072 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1087 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1088 template<
typename ScalingMatrixType,
typename RotationMatrixType>
1093 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1095 sv.coeffRef(0) *= x;
1096 if(scaling) scaling->lazyAssign(svd.
matrixU() * sv.asDiagonal() * svd.
matrixU().adjoint());
1099 LinearMatrixType m(svd.
matrixU());
1101 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1108 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1109 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
1114 linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1116 translation() = position;
1124 struct transform_make_affine
1126 template<
typename MatrixType>
1127 static void run(MatrixType &mat)
1129 static const int Dim = MatrixType::ColsAtCompileTime-1;
1130 mat.template block<1,Dim>(Dim,0).setZero();
1136 struct transform_make_affine<AffineCompact>
1138 template<
typename MatrixType>
static void run(MatrixType &) { }
1142 template<
typename TransformType,
int Mode=TransformType::Mode>
1143 struct projective_transform_inverse
1145 static inline void run(
const TransformType&, TransformType&)
1149 template<
typename TransformType>
1150 struct projective_transform_inverse<TransformType, Projective>
1152 static inline void run(
const TransformType& m, TransformType& res)
1154 res.matrix() = m.matrix().inverse();
1181 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1188 internal::projective_transform_inverse<Transform>::run(*
this, res);
1194 res.matrix().template topLeftCorner<Dim,Dim>() = linear().transpose();
1198 res.matrix().template topLeftCorner<Dim,Dim>() = linear().inverse();
1202 eigen_assert(
false &&
"Invalid transform traits in Transform::Inverse");
1205 res.matrix().template topRightCorner<Dim,1>()
1206 = - res.matrix().template topLeftCorner<Dim,Dim>() * translation();
1218 template<
typename TransformType>
struct transform_take_affine_part {
1219 typedef typename TransformType::MatrixType MatrixType;
1220 typedef typename TransformType::AffinePart AffinePart;
1221 typedef typename TransformType::ConstAffinePart ConstAffinePart;
1222 static inline AffinePart run(MatrixType& m)
1223 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1224 static inline ConstAffinePart run(
const MatrixType& m)
1225 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1228 template<
typename Scalar,
int Dim,
int Options>
1229 struct transform_take_affine_part<Transform<Scalar,Dim,AffineCompact, Options> > {
1231 static inline MatrixType& run(MatrixType& m) {
return m; }
1232 static inline const MatrixType& run(
const MatrixType& m) {
return m; }
1239 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1240 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1244 transform->linear() = other;
1245 transform->translation().setZero();
1246 transform->makeAffine();
1250 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1251 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1255 transform->affine() = other;
1256 transform->makeAffine();
1260 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1261 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1264 { transform->matrix() = other; }
1267 template<
typename Other,
int Options,
int Dim,
int HDim>
1268 struct transform_construct_from_matrix<Other, AffineCompact,Options,Dim,HDim, HDim,HDim>
1271 { transform->matrix() = other.template block<Dim,HDim>(0,0); }
1278 template<
int LhsMode,
int RhsMode>
1279 struct transform_product_result
1286 (LhsMode == (int)AffineCompact || RhsMode == (
int)
AffineCompact ) ? AffineCompact :
1291 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1292 struct transform_right_product_impl< TransformType, MatrixType, 0, RhsCols>
1294 typedef typename MatrixType::PlainObject ResultType;
1296 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1298 return T.matrix() * other;
1302 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1303 struct transform_right_product_impl< TransformType, MatrixType, 1, RhsCols>
1306 Dim = TransformType::Dim,
1307 HDim = TransformType::HDim,
1308 OtherRows = MatrixType::RowsAtCompileTime,
1309 OtherCols = MatrixType::ColsAtCompileTime
1312 typedef typename MatrixType::PlainObject ResultType;
1314 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1316 EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1320 ResultType res(other.rows(),other.cols());
1321 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1322 res.
row(OtherRows-1) = other.
row(OtherRows-1);
1328 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1329 struct transform_right_product_impl< TransformType, MatrixType, 2, RhsCols>
1332 Dim = TransformType::Dim,
1333 HDim = TransformType::HDim,
1334 OtherRows = MatrixType::RowsAtCompileTime,
1335 OtherCols = MatrixType::ColsAtCompileTime
1338 typedef typename MatrixType::PlainObject ResultType;
1340 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1342 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1346 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1352 template<
typename TransformType,
typename MatrixType >
1353 struct transform_right_product_impl< TransformType, MatrixType, 2, 1>
1355 typedef typename TransformType::MatrixType TransformMatrix;
1357 Dim = TransformType::Dim,
1358 HDim = TransformType::HDim,
1359 OtherRows = MatrixType::RowsAtCompileTime,
1360 WorkingRows = EIGEN_PLAIN_ENUM_MIN(TransformMatrix::RowsAtCompileTime,HDim)
1363 typedef typename MatrixType::PlainObject ResultType;
1365 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1367 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1370 rhs.template head<Dim>() = other; rhs[Dim] =
typename ResultType::Scalar(1);
1372 return res.template head<Dim>();
1381 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1382 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1385 typedef typename TransformType::MatrixType MatrixType;
1387 static ResultType run(
const Other& other,
const TransformType& tr)
1388 {
return ResultType(other * tr.matrix()); }
1392 template<
typename Other,
int Options,
int Dim,
int HDim>
1393 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, HDim,HDim>
1396 typedef typename TransformType::MatrixType MatrixType;
1398 static ResultType run(
const Other& other,
const TransformType& tr)
1401 res.
matrix().
noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1402 res.matrix().col(Dim) += other.col(Dim);
1408 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1409 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1412 typedef typename TransformType::MatrixType MatrixType;
1413 typedef TransformType ResultType;
1414 static ResultType run(
const Other& other,
const TransformType& tr)
1417 res.affine().noalias() = other * tr.matrix();
1418 res.matrix().row(Dim) = tr.matrix().row(Dim);
1424 template<
typename Other,
int Options,
int Dim,
int HDim>
1425 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, Dim,HDim>
1428 typedef typename TransformType::MatrixType MatrixType;
1429 typedef TransformType ResultType;
1430 static ResultType run(
const Other& other,
const TransformType& tr)
1433 res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1434 res.translation() += other.col(Dim);
1440 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1441 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1444 typedef typename TransformType::MatrixType MatrixType;
1445 typedef TransformType ResultType;
1446 static ResultType run(
const Other& other,
const TransformType& tr)
1449 if(Mode!=
int(AffineCompact))
1450 res.matrix().row(Dim) = tr.matrix().row(Dim);
1451 res.matrix().template topRows<Dim>().noalias()
1452 = other * tr.matrix().template topRows<Dim>();
1461 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1462 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >
1464 enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
1468 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1471 res.
linear() = lhs.linear() * rhs.linear();
1472 res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1478 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1479 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >
1484 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1486 return ResultType( lhs.matrix() * rhs.matrix() );
1490 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1491 struct transform_transform_product_impl<Transform<Scalar,Dim,AffineCompact,LhsOptions>,Transform<Scalar,Dim,Projective,RhsOptions>,true >
1496 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1499 res.
matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1500 res.matrix().
row(Dim) = rhs.matrix().row(Dim);
1505 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1506 struct transform_transform_product_impl<Transform<Scalar,Dim,Projective,LhsOptions>,Transform<Scalar,Dim,AffineCompact,RhsOptions>,true >
1511 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1513 ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1514 res.
matrix().
col(Dim) += lhs.matrix().col(Dim);
1523 #endif // EIGEN_TRANSFORM_H
Definition: Constants.h:383
ColXpr col(Index i)
Definition: DenseBase.h:783
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:66
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:691
Transform< double, 2, AffineCompact > AffineCompact2d
Definition: Transform.h:702
Definition: Constants.h:326
const MatrixUType & matrixU() const
Definition: SVDBase.h:83
Represents a diagonal matrix with its storage.
Definition: DiagonalMatrix.h:116
Namespace containing all symbols from the Eigen library.
Definition: Core:271
Definition: Constants.h:447
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:167
RowXpr row(Index i)
Definition: DenseBase.h:802
Derived & setIdentity()
Definition: CwiseNullaryOp.h:778
Derived & derived()
Definition: EigenBase.h:44
const unsigned int RowMajorBit
Definition: Constants.h:61
RotationMatrixType toRotationMatrix() const
Definition: RotationBase.h:45
Definition: Constants.h:454
Definition: EigenBase.h:28
Represents a translation transformation.
Definition: ForwardDeclarations.h:271
Transform< double, 2, Projective > Projective2d
Definition: Transform.h:711
Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:177
Transform< float, 2, AffineCompact > AffineCompact2f
Definition: Transform.h:698
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:519
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_inverse_op< typename Derived::Scalar >, const Derived > inverse(const Eigen::ArrayBase< Derived > &x)
Definition: Constants.h:452
TransformTraits
Definition: Constants.h:445
Transform< double, 3, Affine > Affine3d
Definition: Transform.h:695
const Product< MatrixDerived, PermutationDerived, AliasFreeProduct > operator*(const MatrixBase< MatrixDerived > &matrix, const PermutationBase< PermutationDerived > &permutation)
Definition: PermutationMatrix.h:543
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: XprHelper.h:35
Expression of the multiple replication of a matrix or vector.
Definition: Replicate.h:61
Common base class for compact rotation representations.
Definition: ForwardDeclarations.h:266
Transform< double, 3, Isometry > Isometry3d
Definition: Transform.h:686
const DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:277
Transform< float, 2, Projective > Projective2f
Definition: Transform.h:707
const Scalar * data() const
Definition: PlainObjectBase.h:249
Transform< float, 3, Projective > Projective3f
Definition: Transform.h:709
Definition: Eigen_Colamd.h:50
Transform< float, 3, AffineCompact > AffineCompact3f
Definition: Transform.h:700
Transform< double, 3, AffineCompact > AffineCompact3d
Definition: Transform.h:704
Transform< float, 2, Affine > Affine2f
Definition: Transform.h:689
const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:154
Transform< float, 3, Isometry > Isometry3f
Definition: Transform.h:682
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Transform< double, 2, Affine > Affine2d
Definition: Transform.h:693
Transform< double, 2, Isometry > Isometry2d
Definition: Transform.h:684
Definition: Constants.h:322
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: ForwardDeclarations.h:258
const SingularValuesType & singularValues() const
Definition: SVDBase.h:111
NoAlias< Derived, Eigen::MatrixBase > noalias()
Definition: NoAlias.h:101
const MatrixVType & matrixV() const
Definition: SVDBase.h:99
const int Dynamic
Definition: Constants.h:21
Definition: Constants.h:387
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
Definition: Constants.h:450
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Transform< float, 2, Isometry > Isometry2f
Definition: Transform.h:680
Transform< double, 3, Projective > Projective3d
Definition: Transform.h:713
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:103