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 struct transform_right_product_impl;
38 template<
typename Other,
43 int OtherRows=Other::RowsAtCompileTime,
44 int OtherCols=Other::ColsAtCompileTime>
45 struct transform_left_product_impl;
47 template<
typename Lhs,
50 transform_traits<Lhs>::IsProjective ||
51 transform_traits<Rhs>::IsProjective>
52 struct transform_transform_product_impl;
54 template<
typename Other,
59 int OtherRows=Other::RowsAtCompileTime,
60 int OtherCols=Other::ColsAtCompileTime>
61 struct transform_construct_from_matrix;
63 template<
typename TransformType>
struct transform_take_affine_part;
65 template<
int Mode>
struct transform_make_affine;
183 template<
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
197 typedef DenseIndex Index;
209 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
213 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
226 enum { TransformTimeDiagonalMode = ((Mode==int(
Isometry))?
Affine:
int(Mode)) };
240 check_template_params();
241 internal::transform_make_affine<(int(Mode)==Affine) ? Affine : AffineCompact>::run(m_matrix);
246 check_template_params();
247 m_matrix = other.m_matrix;
250 inline explicit Transform(
const TranslationType& t)
252 check_template_params();
255 inline explicit Transform(
const UniformScaling<Scalar>& s)
257 check_template_params();
260 template<
typename Derived>
263 check_template_params();
268 { m_matrix = other.m_matrix;
return *
this; }
270 typedef internal::transform_take_affine_part<Transform> take_affine_part;
273 template<
typename OtherDerived>
276 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
277 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
279 check_template_params();
280 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
284 template<
typename OtherDerived>
287 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
288 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
290 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
294 template<
int OtherOptions>
297 check_template_params();
299 m_matrix = other.matrix();
302 template<
int OtherMode,
int OtherOptions>
305 check_template_params();
309 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
314 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
320 if(ModeIsAffineCompact == OtherModeIsAffineCompact)
325 m_matrix.template block<Dim,Dim+1>(0,0) = other.matrix().template block<Dim,Dim+1>(0,0);
328 else if(OtherModeIsAffineCompact)
331 internal::transform_construct_from_matrix<OtherMatrixType,Mode,Options,Dim,HDim>::run(
this, other.matrix());
338 linear() = other.linear();
339 translation() = other.translation();
343 template<
typename OtherDerived>
344 Transform(
const ReturnByValue<OtherDerived>& other)
346 check_template_params();
350 template<
typename OtherDerived>
351 Transform& operator=(
const ReturnByValue<OtherDerived>& other)
357 #ifdef EIGEN_QT_SUPPORT 359 inline Transform& operator=(
const QMatrix& other);
360 inline QMatrix toQMatrix(
void)
const;
361 inline Transform(
const QTransform& other);
362 inline Transform& operator=(
const QTransform& other);
363 inline QTransform toQTransform(
void)
const;
368 inline Scalar operator() (Index row, Index col)
const {
return m_matrix(row,col); }
371 inline Scalar& operator() (Index row, Index col) {
return m_matrix(row,col); }
374 inline const MatrixType&
matrix()
const {
return m_matrix; }
376 inline MatrixType&
matrix() {
return m_matrix; }
379 inline ConstLinearPart
linear()
const {
return ConstLinearPart(m_matrix,0,0); }
381 inline LinearPart
linear() {
return LinearPart(m_matrix,0,0); }
384 inline ConstAffinePart
affine()
const {
return take_affine_part::run(m_matrix); }
386 inline AffinePart
affine() {
return take_affine_part::run(m_matrix); }
389 inline ConstTranslationPart
translation()
const {
return ConstTranslationPart(m_matrix,0,Dim); }
391 inline TranslationPart
translation() {
return TranslationPart(m_matrix,0,Dim); }
418 template<
typename OtherDerived>
419 EIGEN_STRONG_INLINE
const typename OtherDerived::PlainObject
421 {
return internal::transform_right_product_impl<Transform, OtherDerived>::run(*
this,other.
derived()); }
430 template<
typename OtherDerived>
friend 431 inline const typename internal::transform_left_product_impl<OtherDerived,Mode,Options,_Dim,_Dim+1>::ResultType
433 {
return internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim,HDim>::run(a.
derived(),b); }
441 template<
typename DiagonalDerived>
442 inline const TransformTimeDiagonalReturnType
443 operator * (
const DiagonalBase<DiagonalDerived> &b)
const 445 TransformTimeDiagonalReturnType res(*
this);
446 res.linearExt() *= b;
456 template<
typename DiagonalDerived>
457 friend inline TransformTimeDiagonalReturnType
458 operator * (
const DiagonalBase<DiagonalDerived> &a,
const Transform &b)
460 TransformTimeDiagonalReturnType res;
461 res.
linear().noalias() = a*b.linear();
464 res.
matrix().
row(Dim) = b.matrix().row(Dim);
468 template<
typename OtherDerived>
474 return internal::transform_transform_product_impl<Transform,Transform>::run(*
this,other);
477 #ifdef __INTEL_COMPILER 486 template<
int OtherMode,
int OtherOptions>
struct icc_11_workaround
488 typedef internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> > ProductType;
489 typedef typename ProductType::ResultType ResultType;
494 template<
int OtherMode,
int OtherOptions>
495 inline typename icc_11_workaround<OtherMode,OtherOptions>::ResultType
498 typedef typename icc_11_workaround<OtherMode,OtherOptions>::ProductType ProductType;
499 return ProductType::run(*
this,other);
503 template<
int OtherMode,
int OtherOptions>
504 inline typename internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::ResultType
507 return internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::run(*
this,other);
520 return Transform(MatrixType::Identity());
523 template<
typename OtherDerived>
526 template<
typename OtherDerived>
529 inline Transform& scale(
const Scalar& s);
530 inline Transform& prescale(
const Scalar& s);
532 template<
typename OtherDerived>
535 template<
typename OtherDerived>
538 template<
typename RotationType>
539 inline Transform& rotate(
const RotationType& rotation);
541 template<
typename RotationType>
542 inline Transform& prerotate(
const RotationType& rotation);
544 Transform& shear(
const Scalar& sx,
const Scalar& sy);
545 Transform& preshear(
const Scalar& sx,
const Scalar& sy);
547 inline Transform& operator=(
const TranslationType& t);
548 inline Transform& operator*=(
const TranslationType& t) {
return translate(t.vector()); }
549 inline Transform operator*(
const TranslationType& t)
const;
551 inline Transform& operator=(
const UniformScaling<Scalar>& t);
552 inline Transform& operator*=(
const UniformScaling<Scalar>& s) {
return scale(s.factor()); }
556 res.scale(s.factor());
562 template<
typename Derived>
564 template<
typename Derived>
566 template<
typename Derived>
569 const LinearMatrixType rotation()
const;
570 template<
typename RotationMatrixType,
typename ScalingMatrixType>
571 void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling)
const;
572 template<
typename ScalingMatrixType,
typename RotationMatrixType>
573 void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation)
const;
575 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
582 const Scalar*
data()
const {
return m_matrix.
data(); }
591 template<
typename NewScalarType>
592 inline typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type
cast()
const 593 {
return typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type(*
this); }
596 template<
typename OtherScalarType>
599 check_template_params();
600 m_matrix = other.matrix().template cast<Scalar>();
608 {
return m_matrix.
isApprox(other.m_matrix, prec); }
614 internal::transform_make_affine<int(Mode)>::run(m_matrix);
622 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
628 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
635 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
641 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
644 #ifdef EIGEN_TRANSFORM_PLUGIN 645 #include EIGEN_TRANSFORM_PLUGIN 649 #ifndef EIGEN_PARSED_BY_DOXYGEN 650 static EIGEN_STRONG_INLINE
void check_template_params()
652 EIGEN_STATIC_ASSERT((Options & (
DontAlign|
RowMajor)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)
698 #ifdef EIGEN_QT_SUPPORT 703 template<
typename Scalar,
int Dim,
int Mode,
int Options>
706 check_template_params();
714 template<
typename Scalar,
int Dim,
int Mode,
int Options>
717 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
718 m_matrix << other.m11(), other.m21(), other.dx(),
719 other.m12(), other.m22(), other.dy(),
730 template<
typename Scalar,
int Dim,
int Mode,
int Options>
733 check_template_params();
734 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
735 return QMatrix(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
736 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
737 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
744 template<
typename Scalar,
int Dim,
int Mode,
int Options>
747 check_template_params();
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)
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(),
766 other.m13(), other.m23(), other.m33();
774 template<
typename Scalar,
int Dim,
int Mode,
int Options>
777 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
779 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
780 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
781 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
783 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0),
784 m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1),
785 m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2));
797 template<
typename Scalar,
int Dim,
int Mode,
int Options>
798 template<
typename OtherDerived>
802 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
803 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
804 linearExt().noalias() = (linearExt() * other.
asDiagonal());
812 template<
typename Scalar,
int Dim,
int Mode,
int Options>
815 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
824 template<
typename Scalar,
int Dim,
int Mode,
int Options>
825 template<
typename OtherDerived>
829 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
830 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
831 affine().noalias() = (other.
asDiagonal() * affine());
839 template<
typename Scalar,
int Dim,
int Mode,
int Options>
842 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
843 m_matrix.template topRows<Dim>() *= s;
851 template<
typename Scalar,
int Dim,
int Mode,
int Options>
852 template<
typename OtherDerived>
856 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
857 translationExt() += linearExt() * other;
865 template<
typename Scalar,
int Dim,
int Mode,
int Options>
866 template<
typename OtherDerived>
870 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
872 affine() += other * m_matrix.
row(Dim);
874 translation() += other;
895 template<
typename Scalar,
int Dim,
int Mode,
int Options>
896 template<
typename RotationType>
900 linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
911 template<
typename Scalar,
int Dim,
int Mode,
int Options>
912 template<
typename RotationType>
916 m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
917 * m_matrix.template block<Dim,HDim>(0,0);
926 template<
typename Scalar,
int Dim,
int Mode,
int Options>
930 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
931 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
932 VectorType tmp = linear().col(0)*sy + linear().col(1);
933 linear() << linear().col(0) + linear().col(1)*sx, tmp;
942 template<
typename Scalar,
int Dim,
int Mode,
int Options>
946 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
947 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
948 m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
956 template<
typename Scalar,
int Dim,
int Mode,
int Options>
960 translation() = t.vector();
965 template<
typename Scalar,
int Dim,
int Mode,
int Options>
969 res.translate(t.vector());
973 template<
typename Scalar,
int Dim,
int Mode,
int Options>
977 linear().diagonal().fill(s.factor());
982 template<
typename Scalar,
int Dim,
int Mode,
int Options>
983 template<
typename Derived>
986 linear() = internal::toRotationMatrix<Scalar,Dim>(r);
987 translation().setZero();
992 template<
typename Scalar,
int Dim,
int Mode,
int Options>
993 template<
typename Derived>
997 res.rotate(r.derived());
1012 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1016 LinearMatrixType result;
1017 computeRotationScaling(&result, (LinearMatrixType*)0);
1033 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1034 template<
typename RotationMatrixType,
typename ScalingMatrixType>
1039 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1041 sv.coeffRef(0) *= x;
1042 if(scaling) scaling->lazyAssign(svd.
matrixV() * sv.asDiagonal() * svd.
matrixV().adjoint());
1045 LinearMatrixType m(svd.
matrixU());
1047 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1062 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1063 template<
typename ScalingMatrixType,
typename RotationMatrixType>
1068 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1070 sv.coeffRef(0) *= x;
1071 if(scaling) scaling->lazyAssign(svd.
matrixU() * sv.asDiagonal() * svd.
matrixU().adjoint());
1074 LinearMatrixType m(svd.
matrixU());
1076 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1083 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1084 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
1089 linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1091 translation() = position;
1099 struct transform_make_affine
1101 template<
typename MatrixType>
1102 static void run(MatrixType &mat)
1104 static const int Dim = MatrixType::ColsAtCompileTime-1;
1105 mat.template block<1,Dim>(Dim,0).setZero();
1106 mat.coeffRef(Dim,Dim) =
typename MatrixType::Scalar(1);
1111 struct transform_make_affine<AffineCompact>
1113 template<
typename MatrixType>
static void run(MatrixType &) { }
1117 template<
typename TransformType,
int Mode=TransformType::Mode>
1118 struct projective_transform_inverse
1120 static inline void run(
const TransformType&, TransformType&)
1124 template<
typename TransformType>
1125 struct projective_transform_inverse<TransformType, Projective>
1127 static inline void run(
const TransformType& m, TransformType& res)
1129 res.matrix() = m.matrix().inverse();
1156 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1163 internal::projective_transform_inverse<Transform>::run(*
this, res);
1169 res.matrix().template topLeftCorner<Dim,Dim>() = linear().transpose();
1173 res.matrix().template topLeftCorner<Dim,Dim>() = linear().inverse();
1177 eigen_assert(
false &&
"Invalid transform traits in Transform::Inverse");
1180 res.matrix().template topRightCorner<Dim,1>()
1181 = - res.matrix().template topLeftCorner<Dim,Dim>() * translation();
1193 template<
typename TransformType>
struct transform_take_affine_part {
1194 typedef typename TransformType::MatrixType MatrixType;
1195 typedef typename TransformType::AffinePart AffinePart;
1196 typedef typename TransformType::ConstAffinePart ConstAffinePart;
1197 static inline AffinePart run(MatrixType& m)
1198 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1199 static inline ConstAffinePart run(
const MatrixType& m)
1200 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1203 template<
typename Scalar,
int Dim,
int Options>
1204 struct transform_take_affine_part<Transform<Scalar,Dim,AffineCompact, Options> > {
1206 static inline MatrixType& run(MatrixType& m) {
return m; }
1207 static inline const MatrixType& run(
const MatrixType& m) {
return m; }
1214 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1215 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1219 transform->linear() = other;
1220 transform->translation().setZero();
1221 transform->makeAffine();
1225 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1226 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1230 transform->affine() = other;
1231 transform->makeAffine();
1235 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1236 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1239 { transform->matrix() = other; }
1242 template<
typename Other,
int Options,
int Dim,
int HDim>
1243 struct transform_construct_from_matrix<Other, AffineCompact,Options,Dim,HDim, HDim,HDim>
1246 { transform->matrix() = other.template block<Dim,HDim>(0,0); }
1253 template<
int LhsMode,
int RhsMode>
1254 struct transform_product_result
1261 (LhsMode == (int)AffineCompact || RhsMode == (
int)
AffineCompact ) ? AffineCompact :
1266 template<
typename TransformType,
typename MatrixType >
1267 struct transform_right_product_impl< TransformType, MatrixType, 0 >
1269 typedef typename MatrixType::PlainObject ResultType;
1271 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1273 return T.matrix() * other;
1277 template<
typename TransformType,
typename MatrixType >
1278 struct transform_right_product_impl< TransformType, MatrixType, 1 >
1281 Dim = TransformType::Dim,
1282 HDim = TransformType::HDim,
1283 OtherRows = MatrixType::RowsAtCompileTime,
1284 OtherCols = MatrixType::ColsAtCompileTime
1287 typedef typename MatrixType::PlainObject ResultType;
1289 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1291 EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1295 ResultType res(other.rows(),other.cols());
1296 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1297 res.
row(OtherRows-1) = other.
row(OtherRows-1);
1303 template<
typename TransformType,
typename MatrixType >
1304 struct transform_right_product_impl< TransformType, MatrixType, 2 >
1307 Dim = TransformType::Dim,
1308 HDim = TransformType::HDim,
1309 OtherRows = MatrixType::RowsAtCompileTime,
1310 OtherCols = MatrixType::ColsAtCompileTime
1313 typedef typename MatrixType::PlainObject ResultType;
1315 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1317 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1321 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1332 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1333 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1336 typedef typename TransformType::MatrixType MatrixType;
1338 static ResultType run(
const Other& other,
const TransformType& tr)
1339 {
return ResultType(other * tr.matrix()); }
1343 template<
typename Other,
int Options,
int Dim,
int HDim>
1344 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, HDim,HDim>
1347 typedef typename TransformType::MatrixType MatrixType;
1349 static ResultType run(
const Other& other,
const TransformType& tr)
1352 res.
matrix().
noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1353 res.matrix().col(Dim) += other.col(Dim);
1359 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1360 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1363 typedef typename TransformType::MatrixType MatrixType;
1364 typedef TransformType ResultType;
1365 static ResultType run(
const Other& other,
const TransformType& tr)
1368 res.affine().noalias() = other * tr.matrix();
1369 res.matrix().row(Dim) = tr.matrix().row(Dim);
1375 template<
typename Other,
int Options,
int Dim,
int HDim>
1376 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, Dim,HDim>
1379 typedef typename TransformType::MatrixType MatrixType;
1380 typedef TransformType ResultType;
1381 static ResultType run(
const Other& other,
const TransformType& tr)
1384 res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1385 res.translation() += other.col(Dim);
1391 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1392 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1395 typedef typename TransformType::MatrixType MatrixType;
1396 typedef TransformType ResultType;
1397 static ResultType run(
const Other& other,
const TransformType& tr)
1400 if(Mode!=
int(AffineCompact))
1401 res.matrix().row(Dim) = tr.matrix().row(Dim);
1402 res.matrix().template topRows<Dim>().noalias()
1403 = other * tr.matrix().template topRows<Dim>();
1412 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1413 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >
1415 enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
1419 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1422 res.
linear() = lhs.linear() * rhs.linear();
1423 res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1429 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1430 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >
1435 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1437 return ResultType( lhs.matrix() * rhs.matrix() );
1441 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1442 struct transform_transform_product_impl<Transform<Scalar,Dim,AffineCompact,LhsOptions>,Transform<Scalar,Dim,Projective,RhsOptions>,true >
1447 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1450 res.
matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1451 res.matrix().
row(Dim) = rhs.matrix().row(Dim);
1456 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1457 struct transform_transform_product_impl<Transform<Scalar,Dim,Projective,LhsOptions>,Transform<Scalar,Dim,AffineCompact,RhsOptions>,true >
1462 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1464 ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1465 res.
matrix().
col(Dim) += lhs.matrix().col(Dim);
1474 #endif // EIGEN_TRANSFORM_H Definition: Constants.h:398
RowXpr row(Index i)
Definition: DenseBase.h:750
const MatrixVType & matrixV() const
Definition: JacobiSVD.h:649
Transform< float, 2, Projective > Projective2f
Definition: Transform.h:686
Transform< float, 2, Isometry > Isometry2f
Definition: Transform.h:659
Transform< float, 2, AffineCompact > AffineCompact2f
Definition: Transform.h:677
Definition: Constants.h:270
Represents a diagonal matrix with its storage.
Definition: DiagonalMatrix.h:135
NoAlias< Derived, Eigen::MatrixBase > noalias()
Definition: NoAlias.h:127
Definition: Constants.h:394
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
Definition: Constants.h:331
Definition: Constants.h:266
ColXpr col(Index i)
Definition: DenseBase.h:733
Transform< double, 2, Affine > Affine2d
Definition: Transform.h:672
Definition: Constants.h:391
Transform< double, 3, AffineCompact > AffineCompact3d
Definition: Transform.h:683
Definition: EigenBase.h:26
Represents a translation transformation.
Definition: ForwardDeclarations.h:236
Transform< double, 3, Affine > Affine3d
Definition: Transform.h:674
TransformTraits
Definition: Constants.h:389
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:670
const DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:278
Transform< float, 3, Projective > Projective3f
Definition: Transform.h:688
Derived & derived()
Definition: EigenBase.h:34
Definition: Constants.h:396
Expression of the multiple replication of a matrix or vector.
Definition: Replicate.h:62
Transform< double, 2, Isometry > Isometry2d
Definition: Transform.h:663
const MatrixUType & matrixU() const
Definition: JacobiSVD.h:633
Common base class for compact rotation representations.
Definition: ForwardDeclarations.h:231
Transform< double, 3, Projective > Projective3d
Definition: Transform.h:692
const Scalar * data() const
Definition: PlainObjectBase.h:212
Transform< float, 3, AffineCompact > AffineCompact3f
Definition: Transform.h:679
Transform< double, 2, AffineCompact > AffineCompact2d
Definition: Transform.h:681
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:98
Definition: Eigen_Colamd.h:50
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:102
Transform< float, 3, Isometry > Isometry3f
Definition: Transform.h:661
Transform< float, 2, Affine > Affine2f
Definition: Transform.h:668
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: ForwardDeclarations.h:224
Derived & setIdentity()
Definition: CwiseNullaryOp.h:772
RotationMatrixType toRotationMatrix() const
Definition: RotationBase.h:45
Transform< double, 2, Projective > Projective2d
Definition: Transform.h:690
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Definition: Constants.h:327
const SingularValuesType & singularValues() const
Definition: JacobiSVD.h:661
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Transform< double, 3, Isometry > Isometry3d
Definition: Transform.h:665
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:515