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;
203 template<
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
230 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
234 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
247 enum { TransformTimeDiagonalMode = ((Mode==int(
Isometry))?
Affine:
int(Mode)) };
261 check_template_params();
262 internal::transform_make_affine<(int(Mode)==Affine || int(Mode)==Isometry) ? Affine : AffineCompact>::run(m_matrix);
265 EIGEN_DEVICE_FUNC
inline explicit Transform(
const TranslationType& t)
267 check_template_params();
272 check_template_params();
275 template<
typename Derived>
278 check_template_params();
282 typedef internal::transform_take_affine_part<Transform> take_affine_part;
285 template<
typename OtherDerived>
288 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
289 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
291 check_template_params();
292 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
296 template<
typename OtherDerived>
299 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
300 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
302 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
306 template<
int OtherOptions>
309 check_template_params();
311 m_matrix = other.
matrix();
314 template<
int OtherMode,
int OtherOptions>
317 check_template_params();
321 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
326 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
332 if(EIGEN_CONST_CONDITIONAL(ModeIsAffineCompact == OtherModeIsAffineCompact))
337 m_matrix.template block<Dim,Dim+1>(0,0) = other.
matrix().template block<Dim,Dim+1>(0,0);
340 else if(EIGEN_CONST_CONDITIONAL(OtherModeIsAffineCompact))
343 internal::transform_construct_from_matrix<OtherMatrixType,Mode,Options,Dim,HDim>::run(
this, other.
matrix());
350 linear() = other.
linear();
355 template<
typename OtherDerived>
356 EIGEN_DEVICE_FUNC
Transform(
const ReturnByValue<OtherDerived>& other)
358 check_template_params();
362 template<
typename OtherDerived>
363 EIGEN_DEVICE_FUNC
Transform& operator=(
const ReturnByValue<OtherDerived>& other)
369 #ifdef EIGEN_QT_SUPPORT 371 inline Transform& operator=(
const QMatrix& other);
372 inline QMatrix toQMatrix(
void)
const;
373 inline Transform(
const QTransform& other);
374 inline Transform& operator=(
const QTransform& other);
375 inline QTransform toQTransform(
void)
const;
378 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows()
const EIGEN_NOEXCEPT {
return int(Mode)==int(
Projective) ? m_matrix.cols() : (m_matrix.cols()-1); }
379 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols()
const EIGEN_NOEXCEPT {
return m_matrix.cols(); }
383 EIGEN_DEVICE_FUNC
inline Scalar operator() (Index row, Index col)
const {
return m_matrix(row,col); }
386 EIGEN_DEVICE_FUNC
inline Scalar& operator() (Index row, Index col) {
return m_matrix(row,col); }
389 EIGEN_DEVICE_FUNC
inline const MatrixType&
matrix()
const {
return m_matrix; }
391 EIGEN_DEVICE_FUNC
inline MatrixType&
matrix() {
return m_matrix; }
394 EIGEN_DEVICE_FUNC
inline ConstLinearPart
linear()
const {
return ConstLinearPart(m_matrix,0,0); }
396 EIGEN_DEVICE_FUNC
inline LinearPart
linear() {
return LinearPart(m_matrix,0,0); }
399 EIGEN_DEVICE_FUNC
inline ConstAffinePart
affine()
const {
return take_affine_part::run(m_matrix); }
401 EIGEN_DEVICE_FUNC
inline AffinePart
affine() {
return take_affine_part::run(m_matrix); }
433 template<
typename OtherDerived>
434 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const typename internal::transform_right_product_impl<Transform, OtherDerived>::ResultType
436 {
return internal::transform_right_product_impl<Transform, OtherDerived>::run(*
this,other.
derived()); }
445 template<
typename OtherDerived>
friend 446 EIGEN_DEVICE_FUNC
inline const typename internal::transform_left_product_impl<OtherDerived,Mode,Options,_Dim,_Dim+1>::ResultType
448 {
return internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim,HDim>::run(a.
derived(),b); }
456 template<
typename DiagonalDerived>
457 EIGEN_DEVICE_FUNC
inline const TransformTimeDiagonalReturnType
460 TransformTimeDiagonalReturnType res(*
this);
461 res.linearExt() *= b;
471 template<
typename DiagonalDerived>
472 EIGEN_DEVICE_FUNC
friend inline TransformTimeDiagonalReturnType
475 TransformTimeDiagonalReturnType res;
483 template<
typename OtherDerived>
489 return internal::transform_transform_product_impl<Transform,Transform>::run(*
this,other);
501 template<
int OtherMode,
int OtherOptions>
struct icc_11_workaround
503 typedef internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> > ProductType;
504 typedef typename ProductType::ResultType ResultType;
509 template<
int OtherMode,
int OtherOptions>
510 inline typename icc_11_workaround<OtherMode,OtherOptions>::ResultType
513 typedef typename icc_11_workaround<OtherMode,OtherOptions>::ProductType ProductType;
514 return ProductType::run(*
this,other);
518 template<
int OtherMode,
int OtherOptions>
519 EIGEN_DEVICE_FUNC
inline typename internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::ResultType
522 return internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::run(*
this,other);
535 return Transform(MatrixType::Identity());
538 template<
typename OtherDerived>
542 template<
typename OtherDerived>
546 EIGEN_DEVICE_FUNC
inline Transform& scale(
const Scalar& s);
547 EIGEN_DEVICE_FUNC
inline Transform& prescale(
const Scalar& s);
549 template<
typename OtherDerived>
553 template<
typename OtherDerived>
557 template<
typename RotationType>
559 inline Transform& rotate(
const RotationType& rotation);
561 template<
typename RotationType>
563 inline Transform& prerotate(
const RotationType& rotation);
565 EIGEN_DEVICE_FUNC
Transform& shear(
const Scalar& sx,
const Scalar& sy);
566 EIGEN_DEVICE_FUNC
Transform& preshear(
const Scalar& sx,
const Scalar& sy);
568 EIGEN_DEVICE_FUNC
inline Transform& operator=(
const TranslationType& t);
571 inline Transform& operator*=(
const TranslationType& t) {
return translate(t.vector()); }
584 TransformTimeDiagonalReturnType res = *
this;
585 res.scale(s.factor());
592 template<
typename Derived>
594 template<
typename Derived>
596 template<
typename Derived>
599 typedef typename internal::conditional<int(Mode)==Isometry,ConstLinearPart,const LinearMatrixType>::type RotationReturnType;
600 EIGEN_DEVICE_FUNC RotationReturnType rotation()
const;
602 template<
typename RotationMatrixType,
typename ScalingMatrixType>
604 void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling)
const;
605 template<
typename ScalingMatrixType,
typename RotationMatrixType>
607 void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation)
const;
609 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
618 EIGEN_DEVICE_FUNC
const Scalar*
data()
const {
return m_matrix.
data(); }
620 EIGEN_DEVICE_FUNC Scalar*
data() {
return m_matrix.
data(); }
627 template<
typename NewScalarType>
628 EIGEN_DEVICE_FUNC
inline typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type
cast()
const 629 {
return typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type(*
this); }
632 template<
typename OtherScalarType>
635 check_template_params();
636 m_matrix = other.
matrix().template cast<Scalar>();
644 {
return m_matrix.
isApprox(other.m_matrix, prec); }
650 internal::transform_make_affine<int(Mode)>::run(m_matrix);
658 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
664 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
671 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
677 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
680 #ifdef EIGEN_TRANSFORM_PLUGIN 681 #include EIGEN_TRANSFORM_PLUGIN 685 #ifndef EIGEN_PARSED_BY_DOXYGEN 686 EIGEN_DEVICE_FUNC
static EIGEN_STRONG_INLINE
void check_template_params()
688 EIGEN_STATIC_ASSERT((Options & (
DontAlign|
RowMajor)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)
734 #ifdef EIGEN_QT_SUPPORT 739 template<
typename Scalar,
int Dim,
int Mode,
int Options>
742 check_template_params();
750 template<
typename Scalar,
int Dim,
int Mode,
int Options>
753 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
755 m_matrix << other.m11(), other.m21(), other.dx(),
756 other.m12(), other.m22(), other.dy();
758 m_matrix << other.m11(), other.m21(), other.dx(),
759 other.m12(), other.m22(), other.dy(),
770 template<
typename Scalar,
int Dim,
int Mode,
int Options>
773 check_template_params();
774 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
775 return QMatrix(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0),
784 template<
typename Scalar,
int Dim,
int Mode,
int Options>
787 check_template_params();
795 template<
typename Scalar,
int Dim,
int Mode,
int Options>
798 check_template_params();
799 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
801 m_matrix << other.m11(), other.m21(), other.dx(),
802 other.m12(), other.m22(), other.dy();
804 m_matrix << other.m11(), other.m21(), other.dx(),
805 other.m12(), other.m22(), other.dy(),
806 other.m13(), other.m23(), other.m33();
814 template<
typename Scalar,
int Dim,
int Mode,
int Options>
817 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
819 return QTransform(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0),
823 return QTransform(m_matrix.
coeff(0,0), m_matrix.
coeff(1,0), m_matrix.
coeff(2,0),
837 template<
typename Scalar,
int Dim,
int Mode,
int Options>
838 template<
typename OtherDerived>
842 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
843 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
844 linearExt().noalias() = (linearExt() * other.
asDiagonal());
852 template<
typename Scalar,
int Dim,
int Mode,
int Options>
855 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
864 template<
typename Scalar,
int Dim,
int Mode,
int Options>
865 template<
typename OtherDerived>
869 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
870 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
871 affine().noalias() = (other.
asDiagonal() * affine());
879 template<
typename Scalar,
int Dim,
int Mode,
int Options>
882 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
883 m_matrix.template topRows<Dim>() *= s;
891 template<
typename Scalar,
int Dim,
int Mode,
int Options>
892 template<
typename OtherDerived>
896 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
897 translationExt() += linearExt() * other;
905 template<
typename Scalar,
int Dim,
int Mode,
int Options>
906 template<
typename OtherDerived>
910 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
911 if(EIGEN_CONST_CONDITIONAL(
int(Mode)==
int(
Projective)))
912 affine() += other * m_matrix.
row(Dim);
914 translation() += other;
935 template<
typename Scalar,
int Dim,
int Mode,
int Options>
936 template<
typename RotationType>
940 linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
951 template<
typename Scalar,
int Dim,
int Mode,
int Options>
952 template<
typename RotationType>
956 m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
957 * m_matrix.template block<Dim,HDim>(0,0);
966 template<
typename Scalar,
int Dim,
int Mode,
int Options>
970 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
971 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
972 VectorType tmp = linear().col(0)*sy + linear().col(1);
973 linear() << linear().col(0) + linear().col(1)*sx, tmp;
982 template<
typename Scalar,
int Dim,
int Mode,
int Options>
986 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
987 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
988 m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
996 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1000 translation() = t.vector();
1005 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1009 res.translate(t.vector());
1013 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1017 linear().diagonal().fill(s.factor());
1022 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1023 template<
typename Derived>
1026 linear() = internal::toRotationMatrix<Scalar,Dim>(r);
1027 translation().setZero();
1032 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1033 template<
typename Derived>
1037 res.rotate(r.derived());
1046 template<
int Mode>
struct transform_rotation_impl {
1047 template<
typename TransformType>
1048 EIGEN_DEVICE_FUNC
static inline 1049 const typename TransformType::LinearMatrixType run(
const TransformType& t)
1051 typedef typename TransformType::LinearMatrixType LinearMatrixType;
1052 LinearMatrixType result;
1053 t.computeRotationScaling(&result, (LinearMatrixType*)0);
1057 template<>
struct transform_rotation_impl<Isometry> {
1058 template<
typename TransformType>
1059 EIGEN_DEVICE_FUNC
static inline 1060 typename TransformType::ConstLinearPart run(
const TransformType& t)
1076 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1078 typename Transform<Scalar,Dim,Mode,Options>::RotationReturnType
1081 return internal::transform_rotation_impl<Mode>::run(*
this);
1096 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1097 template<
typename RotationMatrixType,
typename ScalingMatrixType>
1103 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant() < Scalar(0) ? Scalar(-1) : Scalar(1);
1105 sv.coeffRef(Dim-1) *= x;
1106 if(scaling) *scaling = svd.
matrixV() * sv.asDiagonal() * svd.
matrixV().adjoint();
1109 LinearMatrixType m(svd.
matrixU());
1111 *rotation = m * svd.
matrixV().adjoint();
1126 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1127 template<
typename ScalingMatrixType,
typename RotationMatrixType>
1133 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant() < Scalar(0) ? Scalar(-1) : Scalar(1);
1135 sv.coeffRef(Dim-1) *= x;
1136 if(scaling) *scaling = svd.
matrixU() * sv.asDiagonal() * svd.
matrixU().adjoint();
1139 LinearMatrixType m(svd.
matrixU());
1141 *rotation = m * svd.
matrixV().adjoint();
1148 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1149 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
1154 linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1156 translation() = position;
1164 struct transform_make_affine
1166 template<
typename MatrixType>
1167 EIGEN_DEVICE_FUNC
static void run(MatrixType &mat)
1169 static const int Dim = MatrixType::ColsAtCompileTime-1;
1170 mat.template block<1,Dim>(Dim,0).setZero();
1176 struct transform_make_affine<AffineCompact>
1178 template<
typename MatrixType> EIGEN_DEVICE_FUNC
static void run(MatrixType &) { }
1182 template<
typename TransformType,
int Mode=TransformType::Mode>
1183 struct projective_transform_inverse
1185 EIGEN_DEVICE_FUNC
static inline void run(
const TransformType&, TransformType&)
1189 template<
typename TransformType>
1190 struct projective_transform_inverse<TransformType, Projective>
1192 EIGEN_DEVICE_FUNC
static inline void run(
const TransformType& m, TransformType& res)
1194 res.matrix() = m.matrix().inverse();
1221 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1228 internal::projective_transform_inverse<Transform>::run(*
this, res);
1234 res.
matrix().template topLeftCorner<Dim,Dim>() = linear().
transpose();
1238 res.
matrix().template topLeftCorner<Dim,Dim>() = linear().
inverse();
1242 eigen_assert(
false &&
"Invalid transform traits in Transform::Inverse");
1245 res.
matrix().template topRightCorner<Dim,1>()
1246 = - res.
matrix().template topLeftCorner<Dim,Dim>() * translation();
1258 template<
typename TransformType>
struct transform_take_affine_part {
1259 typedef typename TransformType::MatrixType MatrixType;
1260 typedef typename TransformType::AffinePart AffinePart;
1261 typedef typename TransformType::ConstAffinePart ConstAffinePart;
1262 static inline AffinePart run(MatrixType& m)
1263 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1264 static inline ConstAffinePart run(
const MatrixType& m)
1265 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1268 template<
typename Scalar,
int Dim,
int Options>
1269 struct transform_take_affine_part<Transform<Scalar,Dim,AffineCompact, Options> > {
1271 static inline MatrixType& run(MatrixType& m) {
return m; }
1272 static inline const MatrixType& run(
const MatrixType& m) {
return m; }
1279 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1280 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1284 transform->
linear() = other;
1290 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1291 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1295 transform->
affine() = other;
1300 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1301 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1304 { transform->
matrix() = other; }
1307 template<
typename Other,
int Options,
int Dim,
int HDim>
1308 struct transform_construct_from_matrix<Other, AffineCompact,Options,Dim,HDim, HDim,HDim>
1311 { transform->
matrix() = other.template block<Dim,HDim>(0,0); }
1318 template<
int LhsMode,
int RhsMode>
1319 struct transform_product_result
1326 (LhsMode == (int)AffineCompact || RhsMode == (
int)
AffineCompact ) ? AffineCompact :
1331 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1332 struct transform_right_product_impl< TransformType, MatrixType, 0, RhsCols>
1334 typedef typename MatrixType::PlainObject ResultType;
1336 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1338 return T.matrix() * other;
1342 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1343 struct transform_right_product_impl< TransformType, MatrixType, 1, RhsCols>
1346 Dim = TransformType::Dim,
1347 HDim = TransformType::HDim,
1348 OtherRows = MatrixType::RowsAtCompileTime,
1349 OtherCols = MatrixType::ColsAtCompileTime
1352 typedef typename MatrixType::PlainObject ResultType;
1354 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1356 EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1360 ResultType res(other.rows(),other.cols());
1361 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1362 res.
row(OtherRows-1) = other.
row(OtherRows-1);
1368 template<
typename TransformType,
typename MatrixType,
int RhsCols>
1369 struct transform_right_product_impl< TransformType, MatrixType, 2, RhsCols>
1372 Dim = TransformType::Dim,
1373 HDim = TransformType::HDim,
1374 OtherRows = MatrixType::RowsAtCompileTime,
1375 OtherCols = MatrixType::ColsAtCompileTime
1378 typedef typename MatrixType::PlainObject ResultType;
1380 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1382 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1386 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1392 template<
typename TransformType,
typename MatrixType >
1393 struct transform_right_product_impl< TransformType, MatrixType, 2, 1>
1395 typedef typename TransformType::MatrixType TransformMatrix;
1397 Dim = TransformType::Dim,
1398 HDim = TransformType::HDim,
1399 OtherRows = MatrixType::RowsAtCompileTime,
1400 WorkingRows = EIGEN_PLAIN_ENUM_MIN(TransformMatrix::RowsAtCompileTime,HDim)
1403 typedef typename MatrixType::PlainObject ResultType;
1405 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1407 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1410 rhs.template head<Dim>() = other; rhs[Dim] =
typename ResultType::Scalar(1);
1412 return res.template head<Dim>();
1421 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1422 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1425 typedef typename TransformType::MatrixType MatrixType;
1427 static ResultType run(
const Other& other,
const TransformType& tr)
1428 {
return ResultType(other * tr.matrix()); }
1432 template<
typename Other,
int Options,
int Dim,
int HDim>
1433 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, HDim,HDim>
1436 typedef typename TransformType::MatrixType MatrixType;
1438 static ResultType run(
const Other& other,
const TransformType& tr)
1441 res.
matrix().
noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1442 res.matrix().col(Dim) += other.col(Dim);
1448 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1449 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1452 typedef typename TransformType::MatrixType MatrixType;
1453 typedef TransformType ResultType;
1454 static ResultType run(
const Other& other,
const TransformType& tr)
1457 res.affine().noalias() = other * tr.matrix();
1458 res.matrix().row(Dim) = tr.matrix().row(Dim);
1464 template<
typename Other,
int Options,
int Dim,
int HDim>
1465 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, Dim,HDim>
1468 typedef typename TransformType::MatrixType MatrixType;
1469 typedef TransformType ResultType;
1470 static ResultType run(
const Other& other,
const TransformType& tr)
1473 res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1474 res.translation() += other.col(Dim);
1480 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1481 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1484 typedef typename TransformType::MatrixType MatrixType;
1485 typedef TransformType ResultType;
1486 static ResultType run(
const Other& other,
const TransformType& tr)
1489 if(Mode!=
int(AffineCompact))
1490 res.matrix().row(Dim) = tr.matrix().row(Dim);
1491 res.matrix().template topRows<Dim>().noalias()
1492 = other * tr.matrix().template topRows<Dim>();
1501 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1502 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >
1504 enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
1508 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1511 res.
linear() = lhs.linear() * rhs.linear();
1512 res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1518 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1519 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >
1524 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1526 return ResultType( lhs.matrix() * rhs.matrix() );
1530 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1531 struct transform_transform_product_impl<Transform<Scalar,Dim,AffineCompact,LhsOptions>,Transform<Scalar,Dim,Projective,RhsOptions>,true >
1536 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1539 res.
matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1540 res.matrix().row(Dim) = rhs.matrix().row(Dim);
1545 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1546 struct transform_transform_product_impl<Transform<Scalar,Dim,Projective,LhsOptions>,Transform<Scalar,Dim,AffineCompact,RhsOptions>,true >
1551 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1553 ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1554 res.
matrix().
col(Dim) += lhs.matrix().col(Dim);
1563 #endif // EIGEN_TRANSFORM_H
Definition: Constants.h:393
ColXpr col(Index i)
Definition: DenseBase.h:1098
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:66
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:706
Transform< double, 2, AffineCompact > AffineCompact2d
Definition: Transform.h:717
Definition: Constants.h:325
const MatrixUType & matrixU() const
Definition: SVDBase.h:101
Represents a diagonal matrix with its storage.
Definition: DiagonalMatrix.h:140
Namespace containing all symbols from the Eigen library.
Definition: Core:141
Definition: Constants.h:457
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:232
RowXpr row(Index i)
Definition: DenseBase.h:1119
Derived & setIdentity()
Definition: CwiseNullaryOp.h:873
Derived & derived()
Definition: EigenBase.h:46
const unsigned int RowMajorBit
Definition: Constants.h:66
TransposeReturnType transpose()
Definition: Transpose.h:182
RotationMatrixType toRotationMatrix() const
Definition: RotationBase.h:45
Definition: Constants.h:464
Definition: EigenBase.h:29
Represents a translation transformation.
Definition: Translation.h:30
Transform< double, 2, Projective > Projective2d
Definition: Transform.h:726
Scalar & coeffRef(Index rowId, Index colId)
Definition: PlainObjectBase.h:175
Transform< float, 2, AffineCompact > AffineCompact2f
Definition: Transform.h:713
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:562
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_inverse_op< typename Derived::Scalar >, const Derived > inverse(const Eigen::ArrayBase< Derived > &x)
Definition: Constants.h:462
TransformTraits
Definition: Constants.h:455
Transform< double, 3, Affine > Affine3d
Definition: Transform.h:710
const Product< MatrixDerived, PermutationDerived, AliasFreeProduct > operator*(const MatrixBase< MatrixDerived > &matrix, const PermutationBase< PermutationDerived > &permutation)
Definition: PermutationMatrix.h:515
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:74
Expression of the multiple replication of a matrix or vector.
Definition: Replicate.h:61
Common base class for compact rotation representations.
Definition: RotationBase.h:29
Transform< double, 3, Isometry > Isometry3d
Definition: Transform.h:701
const DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:325
Transform< float, 2, Projective > Projective2f
Definition: Transform.h:722
const Scalar * data() const
Definition: PlainObjectBase.h:247
Transform< float, 3, Projective > Projective3f
Definition: Transform.h:724
Definition: Eigen_Colamd.h:50
Transform< float, 3, AffineCompact > AffineCompact3f
Definition: Transform.h:715
const Inverse< Derived > inverse() const
Definition: InverseImpl.h:348
Transform< double, 3, AffineCompact > AffineCompact3d
Definition: Transform.h:719
Transform< float, 2, Affine > Affine2f
Definition: Transform.h:704
const Scalar & coeff(Index rowId, Index colId) const
Definition: PlainObjectBase.h:152
Transform< float, 3, Isometry > Isometry3f
Definition: Transform.h:697
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:103
Transform< double, 2, Affine > Affine2d
Definition: Transform.h:708
Transform< double, 2, Isometry > Isometry2d
Definition: Transform.h:699
Definition: Constants.h:321
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: JacobiSVD.h:488
const SingularValuesType & singularValues() const
Definition: SVDBase.h:129
NoAlias< Derived, Eigen::MatrixBase > noalias()
Definition: NoAlias.h:102
const MatrixVType & matrixV() const
Definition: SVDBase.h:117
const int Dynamic
Definition: Constants.h:22
Definition: Constants.h:397
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
Definition: Constants.h:460
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Transform< float, 2, Isometry > Isometry2f
Definition: Transform.h:695
Transform< double, 3, Projective > Projective3d
Definition: Transform.h:728
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:103