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 EIGEN_DEVICE_FUNC
inline explicit Transform(
const TranslationType& t)
270 check_template_params();
273 EIGEN_DEVICE_FUNC
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 EIGEN_DEVICE_FUNC
Transform(
const ReturnByValue<OtherDerived>& other)
364 check_template_params();
368 template<
typename OtherDerived>
369 EIGEN_DEVICE_FUNC
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 EIGEN_DEVICE_FUNC Index rows()
const {
return int(Mode)==int(
Projective) ? m_matrix.cols() : (m_matrix.cols()-1); }
385 EIGEN_DEVICE_FUNC Index cols()
const {
return m_matrix.cols(); }
389 EIGEN_DEVICE_FUNC
inline Scalar operator() (Index row, Index col)
const {
return m_matrix(row,col); }
392 EIGEN_DEVICE_FUNC
inline Scalar& operator() (Index row, Index col) {
return m_matrix(row,col); }
395 EIGEN_DEVICE_FUNC
inline const MatrixType&
matrix()
const {
return m_matrix; }
397 EIGEN_DEVICE_FUNC
inline MatrixType&
matrix() {
return m_matrix; }
400 EIGEN_DEVICE_FUNC
inline ConstLinearPart
linear()
const {
return ConstLinearPart(m_matrix,0,0); }
402 EIGEN_DEVICE_FUNC
inline LinearPart
linear() {
return LinearPart(m_matrix,0,0); }
405 EIGEN_DEVICE_FUNC
inline ConstAffinePart
affine()
const {
return take_affine_part::run(m_matrix); }
407 EIGEN_DEVICE_FUNC
inline AffinePart
affine() {
return take_affine_part::run(m_matrix); }
439 template<
typename OtherDerived>
440 EIGEN_DEVICE_FUNC 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 EIGEN_DEVICE_FUNC
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 EIGEN_DEVICE_FUNC
inline const TransformTimeDiagonalReturnType
466 TransformTimeDiagonalReturnType res(*
this);
467 res.linearExt() *= b;
477 template<
typename DiagonalDerived>
478 EIGEN_DEVICE_FUNC
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 EIGEN_DEVICE_FUNC
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>
548 template<
typename OtherDerived>
552 EIGEN_DEVICE_FUNC
inline Transform& scale(
const Scalar& s);
553 EIGEN_DEVICE_FUNC
inline Transform& prescale(
const Scalar& s);
555 template<
typename OtherDerived>
559 template<
typename OtherDerived>
563 template<
typename RotationType>
565 inline Transform& rotate(
const RotationType& rotation);
567 template<
typename RotationType>
569 inline Transform& prerotate(
const RotationType& rotation);
571 EIGEN_DEVICE_FUNC
Transform& shear(
const Scalar& sx,
const Scalar& sy);
572 EIGEN_DEVICE_FUNC
Transform& preshear(
const Scalar& sx,
const Scalar& sy);
574 EIGEN_DEVICE_FUNC
inline Transform& operator=(
const TranslationType& t);
577 inline Transform& operator*=(
const TranslationType& t) {
return translate(t.vector()); }
582 inline Transform& operator=(
const UniformScaling<Scalar>& t);
585 inline Transform& operator*=(
const UniformScaling<Scalar>& s) {
return scale(s.factor()); }
588 inline TransformTimeDiagonalReturnType
operator*(
const UniformScaling<Scalar>& s)
const 590 TransformTimeDiagonalReturnType res = *
this;
591 res.scale(s.factor());
598 template<
typename Derived>
600 template<
typename Derived>
602 template<
typename Derived>
605 EIGEN_DEVICE_FUNC
const LinearMatrixType rotation()
const;
606 template<
typename RotationMatrixType,
typename ScalingMatrixType>
608 void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling)
const;
609 template<
typename ScalingMatrixType,
typename RotationMatrixType>
611 void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation)
const;
613 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
622 EIGEN_DEVICE_FUNC
const Scalar*
data()
const {
return m_matrix.
data(); }
624 EIGEN_DEVICE_FUNC Scalar*
data() {
return m_matrix.
data(); }
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); }
668 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
675 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
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)
738 #ifdef EIGEN_QT_SUPPORT 743 template<
typename Scalar,
int Dim,
int Mode,
int Options>
746 check_template_params();
754 template<
typename Scalar,
int Dim,
int Mode,
int Options>
757 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
759 m_matrix << other.m11(), other.m21(), other.dx(),
760 other.m12(), other.m22(), other.dy();
762 m_matrix << other.m11(), other.m21(), other.dx(),
763 other.m12(), other.m22(), other.dy(),
774 template<
typename Scalar,
int Dim,
int Mode,
int Options>
777 check_template_params();
778 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
779 return QMatrix(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0),
788 template<
typename Scalar,
int Dim,
int Mode,
int Options>
791 check_template_params();
799 template<
typename Scalar,
int Dim,
int Mode,
int Options>
802 check_template_params();
803 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
805 m_matrix << other.m11(), other.m21(), other.dx(),
806 other.m12(), other.m22(), other.dy();
808 m_matrix << other.m11(), other.m21(), other.dx(),
809 other.m12(), other.m22(), other.dy(),
810 other.m13(), other.m23(), other.m33();
818 template<
typename Scalar,
int Dim,
int Mode,
int Options>
821 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
823 return QTransform(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0),
827 return QTransform(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0), m_matrix.
coeff(2,0),
841 template<
typename Scalar,
int Dim,
int Mode,
int Options>
842 template<
typename OtherDerived>
846 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
847 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
848 linearExt().noalias() = (linearExt() * other.
asDiagonal());
856 template<
typename Scalar,
int Dim,
int Mode,
int Options>
859 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
868 template<
typename Scalar,
int Dim,
int Mode,
int Options>
869 template<
typename OtherDerived>
873 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
874 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
875 affine().noalias() = (other.
asDiagonal() * affine());
883 template<
typename Scalar,
int Dim,
int Mode,
int Options>
886 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
887 m_matrix.template topRows<Dim>() *= s;
895 template<
typename Scalar,
int Dim,
int Mode,
int Options>
896 template<
typename OtherDerived>
900 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
901 translationExt() += linearExt() * other;
909 template<
typename Scalar,
int Dim,
int Mode,
int Options>
910 template<
typename OtherDerived>
914 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
916 affine() += other * m_matrix.
row(Dim);
918 translation() += other;
939 template<
typename Scalar,
int Dim,
int Mode,
int Options>
940 template<
typename RotationType>
944 linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
955 template<
typename Scalar,
int Dim,
int Mode,
int Options>
956 template<
typename RotationType>
960 m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
961 * m_matrix.template block<Dim,HDim>(0,0);
970 template<
typename Scalar,
int Dim,
int Mode,
int Options>
974 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
975 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
976 VectorType tmp = linear().col(0)*sy + linear().col(1);
977 linear() << linear().col(0) + linear().col(1)*sx, tmp;
986 template<
typename Scalar,
int Dim,
int Mode,
int Options>
990 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
991 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
992 m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
1000 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1004 translation() = t.vector();
1009 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1013 res.translate(t.vector());
1017 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1021 linear().diagonal().fill(s.factor());
1026 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1027 template<
typename Derived>
1030 linear() = internal::toRotationMatrix<Scalar,Dim>(r);
1031 translation().setZero();
1036 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1037 template<
typename Derived>
1041 res.rotate(r.derived());
1056 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1060 LinearMatrixType result;
1061 computeRotationScaling(&result, (LinearMatrixType*)0);
1077 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1078 template<
typename RotationMatrixType,
typename ScalingMatrixType>
1083 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1085 sv.coeffRef(0) *= x;
1086 if(scaling) scaling->lazyAssign(svd.
matrixV() * sv.asDiagonal() * svd.
matrixV().adjoint());
1089 LinearMatrixType m(svd.
matrixU());
1091 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1106 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1107 template<
typename ScalingMatrixType,
typename RotationMatrixType>
1112 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1114 sv.coeffRef(0) *= x;
1115 if(scaling) scaling->lazyAssign(svd.
matrixU() * sv.asDiagonal() * svd.
matrixU().adjoint());
1118 LinearMatrixType m(svd.
matrixU());
1120 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1127 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1128 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
1133 linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1135 translation() = position;
1143 struct transform_make_affine
1145 template<
typename MatrixType>
1146 EIGEN_DEVICE_FUNC
static void run(MatrixType &mat)
1148 static const int Dim = MatrixType::ColsAtCompileTime-1;
1149 mat.template block<1,Dim>(Dim,0).setZero();
1155 struct transform_make_affine<AffineCompact>
1157 template<
typename MatrixType> EIGEN_DEVICE_FUNC
static void run(MatrixType &) { }
1161 template<
typename TransformType,
int Mode=TransformType::Mode>
1162 struct projective_transform_inverse
1164 EIGEN_DEVICE_FUNC
static inline void run(
const TransformType&, TransformType&)
1168 template<
typename TransformType>
1169 struct projective_transform_inverse<TransformType, Projective>
1171 EIGEN_DEVICE_FUNC
static inline void run(
const TransformType& m, TransformType& res)
1173 res.matrix() = m.matrix().inverse();
1200 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1207 internal::projective_transform_inverse<Transform>::run(*
this, res);
1213 res.matrix().template topLeftCorner<Dim,Dim>() = linear().transpose();
1217 res.matrix().template topLeftCorner<Dim,Dim>() = linear().inverse();
1221 eigen_assert(
false &&
"Invalid transform traits in Transform::Inverse");
1224 res.matrix().template topRightCorner<Dim,1>()
1225 = - res.matrix().template topLeftCorner<Dim,Dim>() * translation();
1237 template<
typename TransformType>
struct transform_take_affine_part {
1238 typedef typename TransformType::MatrixType MatrixType;
1239 typedef typename TransformType::AffinePart AffinePart;
1240 typedef typename TransformType::ConstAffinePart ConstAffinePart;
1241 static inline AffinePart run(MatrixType& m)
1242 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1243 static inline ConstAffinePart run(
const MatrixType& m)
1244 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1247 template<
typename Scalar,
int Dim,
int Options>
1248 struct transform_take_affine_part<Transform<Scalar,Dim,AffineCompact, Options> > {
1250 static inline MatrixType& run(MatrixType& m) {
return m; }
1251 static inline const MatrixType& run(
const MatrixType& m) {
return m; }
1258 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1259 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1263 transform->linear() = other;
1264 transform->translation().setZero();
1265 transform->makeAffine();
1269 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1270 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1274 transform->affine() = other;
1275 transform->makeAffine();
1279 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1280 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1283 { transform->matrix() = other; }
1286 template<
typename Other,
int Options,
int Dim,
int HDim>
1287 struct transform_construct_from_matrix<Other, AffineCompact,Options,Dim,HDim, HDim,HDim>
1290 { transform->matrix() = other.template block<Dim,HDim>(0,0); }
1297 template<
int LhsMode,
int RhsMode>
1298 struct transform_product_result
1305 (LhsMode == (int)AffineCompact || RhsMode == (
int)
AffineCompact ) ? AffineCompact :
1310 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1311 struct transform_right_product_impl< TransformType, MatrixType, 0, RhsCols>
1313 typedef typename MatrixType::PlainObject ResultType;
1315 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1317 return T.matrix() * other;
1321 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1322 struct transform_right_product_impl< TransformType, MatrixType, 1, RhsCols>
1325 Dim = TransformType::Dim,
1326 HDim = TransformType::HDim,
1327 OtherRows = MatrixType::RowsAtCompileTime,
1328 OtherCols = MatrixType::ColsAtCompileTime
1331 typedef typename MatrixType::PlainObject ResultType;
1333 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1335 EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1339 ResultType res(other.rows(),other.cols());
1340 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1341 res.
row(OtherRows-1) = other.
row(OtherRows-1);
1347 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1348 struct transform_right_product_impl< TransformType, MatrixType, 2, RhsCols>
1351 Dim = TransformType::Dim,
1352 HDim = TransformType::HDim,
1353 OtherRows = MatrixType::RowsAtCompileTime,
1354 OtherCols = MatrixType::ColsAtCompileTime
1357 typedef typename MatrixType::PlainObject ResultType;
1359 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1361 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1365 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1371 template<
typename TransformType,
typename MatrixType >
1372 struct transform_right_product_impl< TransformType, MatrixType, 2, 1>
1374 typedef typename TransformType::MatrixType TransformMatrix;
1376 Dim = TransformType::Dim,
1377 HDim = TransformType::HDim,
1378 OtherRows = MatrixType::RowsAtCompileTime,
1379 WorkingRows = EIGEN_PLAIN_ENUM_MIN(TransformMatrix::RowsAtCompileTime,HDim)
1382 typedef typename MatrixType::PlainObject ResultType;
1384 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1386 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1389 rhs.template head<Dim>() = other; rhs[Dim] =
typename ResultType::Scalar(1);
1391 return res.template head<Dim>();
1400 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1401 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1404 typedef typename TransformType::MatrixType MatrixType;
1406 static ResultType run(
const Other& other,
const TransformType& tr)
1407 {
return ResultType(other * tr.matrix()); }
1411 template<
typename Other,
int Options,
int Dim,
int HDim>
1412 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, HDim,HDim>
1415 typedef typename TransformType::MatrixType MatrixType;
1417 static ResultType run(
const Other& other,
const TransformType& tr)
1420 res.
matrix().
noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1421 res.matrix().col(Dim) += other.col(Dim);
1427 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1428 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1431 typedef typename TransformType::MatrixType MatrixType;
1432 typedef TransformType ResultType;
1433 static ResultType run(
const Other& other,
const TransformType& tr)
1436 res.affine().noalias() = other * tr.matrix();
1437 res.matrix().row(Dim) = tr.matrix().row(Dim);
1443 template<
typename Other,
int Options,
int Dim,
int HDim>
1444 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, Dim,HDim>
1447 typedef typename TransformType::MatrixType MatrixType;
1448 typedef TransformType ResultType;
1449 static ResultType run(
const Other& other,
const TransformType& tr)
1452 res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1453 res.translation() += other.col(Dim);
1459 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1460 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1463 typedef typename TransformType::MatrixType MatrixType;
1464 typedef TransformType ResultType;
1465 static ResultType run(
const Other& other,
const TransformType& tr)
1468 if(Mode!=
int(AffineCompact))
1469 res.matrix().row(Dim) = tr.matrix().row(Dim);
1470 res.matrix().template topRows<Dim>().noalias()
1471 = other * tr.matrix().template topRows<Dim>();
1480 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1481 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >
1483 enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
1487 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1490 res.
linear() = lhs.linear() * rhs.linear();
1491 res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1497 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1498 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >
1503 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1505 return ResultType( lhs.matrix() * rhs.matrix() );
1509 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1510 struct transform_transform_product_impl<Transform<Scalar,Dim,AffineCompact,LhsOptions>,Transform<Scalar,Dim,Projective,RhsOptions>,true >
1515 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1518 res.
matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1519 res.matrix().row(Dim) = rhs.matrix().row(Dim);
1524 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1525 struct transform_transform_product_impl<Transform<Scalar,Dim,Projective,LhsOptions>,Transform<Scalar,Dim,AffineCompact,RhsOptions>,true >
1530 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1532 ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1533 res.
matrix().
col(Dim) += lhs.matrix().col(Dim);
1542 #endif // EIGEN_TRANSFORM_H
Definition: Constants.h:383
ColXpr col(Index i)
Definition: DenseBase.h:839
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:66
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:710
Transform< double, 2, AffineCompact > AffineCompact2d
Definition: Transform.h:721
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:287
Definition: Constants.h:447
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:150
RowXpr row(Index i)
Definition: DenseBase.h:860
Derived & setIdentity()
Definition: CwiseNullaryOp.h:774
Derived & derived()
Definition: EigenBase.h:45
const unsigned int RowMajorBit
Definition: Constants.h:61
RotationMatrixType toRotationMatrix() const
Definition: RotationBase.h:45
Definition: Constants.h:454
Definition: EigenBase.h:29
Represents a translation transformation.
Definition: ForwardDeclarations.h:271
Transform< double, 2, Projective > Projective2d
Definition: Transform.h:730
Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:183
Transform< float, 2, AffineCompact > AffineCompact2f
Definition: Transform.h:717
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:515
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:714
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: Meta.h:33
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:705
const DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:277
Transform< float, 2, Projective > Projective2f
Definition: Transform.h:726
const Scalar * data() const
Definition: PlainObjectBase.h:255
Transform< float, 3, Projective > Projective3f
Definition: Transform.h:728
Definition: Eigen_Colamd.h:50
Transform< float, 3, AffineCompact > AffineCompact3f
Definition: Transform.h:719
Transform< double, 3, AffineCompact > AffineCompact3d
Definition: Transform.h:723
Transform< float, 2, Affine > Affine2f
Definition: Transform.h:708
const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:160
Transform< float, 3, Isometry > Isometry3f
Definition: Transform.h:701
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Transform< double, 2, Affine > Affine2d
Definition: Transform.h:712
Transform< double, 2, Isometry > Isometry2d
Definition: Transform.h:703
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:699
Transform< double, 3, Projective > Projective3d
Definition: Transform.h:732
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:103