12#ifndef EIGEN_TRANSFORM_H
13#define EIGEN_TRANSFORM_H
19template<
typename Transform>
20struct transform_traits
25 HDim = Transform::HDim,
26 Mode = Transform::Mode,
31template<
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>
37struct transform_right_product_impl;
39template<
typename Other,
44 int OtherRows=Other::RowsAtCompileTime,
45 int OtherCols=Other::ColsAtCompileTime>
46struct transform_left_product_impl;
48template<
typename Lhs,
51 transform_traits<Lhs>::IsProjective ||
52 transform_traits<Rhs>::IsProjective>
53struct transform_transform_product_impl;
55template<
typename Other,
60 int OtherRows=Other::RowsAtCompileTime,
61 int OtherCols=Other::ColsAtCompileTime>
62struct transform_construct_from_matrix;
64template<
typename TransformType>
struct transform_take_affine_part;
66template<
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
67struct 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,
82template<
int Mode>
struct transform_make_affine;
203template<
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
220 typedef typename internal::make_proper_matrix_type<Scalar,Rows,HDim,Options>::type
MatrixType;
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();
267 check_template_params();
270 EIGEN_DEVICE_FUNC
inline explicit Transform(
const UniformScaling<Scalar>& s)
272 check_template_params();
275 template<
typename Derived>
276 EIGEN_DEVICE_FUNC
inline explicit Transform(
const RotationBase<Derived, Dim>& r)
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>
369 #ifdef EIGEN_QT_SUPPORT
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(); }
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>
461 res.linearExt() *= b;
471 template<
typename DiagonalDerived>
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);
538 template<
typename OtherDerived>
542 template<
typename OtherDerived>
549 template<
typename OtherDerived>
553 template<
typename OtherDerived>
557 template<
typename RotationType>
561 template<
typename RotationType>
585 res.scale(s.factor());
590 inline Transform& operator*=(
const DiagonalMatrix<Scalar,Dim>& s) { linearExt() *= s;
return *
this; }
592 template<
typename Derived>
594 template<
typename Derived>
595 EIGEN_DEVICE_FUNC
inline Transform& operator*=(
const RotationBase<Derived,Dim>& r) {
return rotate(r.toRotationMatrix()); }
596 template<
typename Derived>
597 EIGEN_DEVICE_FUNC
inline Transform operator*(
const RotationBase<Derived,Dim>& r)
const;
600 EIGEN_DEVICE_FUNC RotationReturnType
rotation()
const;
602 template<
typename RotationMatrixType,
typename ScalingMatrixType>
605 template<
typename ScalingMatrixType,
typename RotationMatrixType>
609 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
618 EIGEN_DEVICE_FUNC
const Scalar*
data()
const {
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();
643 EIGEN_DEVICE_FUNC
bool isApprox(
const Transform& other,
const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision())
const
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); }
663 EIGEN_DEVICE_FUNC
inline const Block<
MatrixType,int(Mode)==int(
Projective)?HDim:Dim,Dim> linearExt()
const
664 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
670 EIGEN_DEVICE_FUNC
inline Block<
MatrixType,int(Mode)==int(
Projective)?HDim:Dim,1> translationExt()
671 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
676 EIGEN_DEVICE_FUNC
inline const Block<
MatrixType,int(Mode)==int(
Projective)?HDim:Dim,1> translationExt()
const
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
739template<
typename Scalar,
int Dim,
int Mode,
int Options>
742 check_template_params();
750template<
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(),
770template<
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),
776 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
777 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
784template<
typename Scalar,
int Dim,
int Mode,
int Options>
787 check_template_params();
795template<
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();
814template<
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),
820 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
821 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
823 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0),
824 m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1),
825 m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2));
837template<
typename Scalar,
int Dim,
int Mode,
int Options>
838template<
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());
852template<
typename Scalar,
int Dim,
int Mode,
int Options>
855 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
864template<
typename Scalar,
int Dim,
int Mode,
int Options>
865template<
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)
879template<
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;
891template<
typename Scalar,
int Dim,
int Mode,
int Options>
892template<
typename OtherDerived>
896 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
897 translationExt() += linearExt() * other;
905template<
typename Scalar,
int Dim,
int Mode,
int Options>
906template<
typename OtherDerived>
910 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
911 if(EIGEN_CONST_CONDITIONAL(
int(Mode)==
int(
Projective)))
935template<
typename Scalar,
int Dim,
int Mode,
int Options>
936template<
typename RotationType>
938Transform<Scalar,Dim,Mode,Options>::rotate(
const RotationType&
rotation)
940 linearExt() *= internal::toRotationMatrix<Scalar,Dim>(
rotation);
951template<
typename Scalar,
int Dim,
int Mode,
int Options>
952template<
typename RotationType>
954Transform<Scalar,Dim,Mode,Options>::prerotate(
const RotationType&
rotation)
956 m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(
rotation)
957 * m_matrix.template block<Dim,HDim>(0,0);
966template<
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)
982template<
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)
989 shear.coeffRef(0, 1) = sy;
990 shear.coeffRef(1, 0) = sx;
991 m_matrix.template block<Dim, HDim>(0, 0) =
shear * m_matrix.template block<Dim, HDim>(0, 0);
999template<
typename Scalar,
int Dim,
int Mode,
int Options>
1003 translation() = t.vector();
1008template<
typename Scalar,
int Dim,
int Mode,
int Options>
1011 Transform res = *
this;
1012 res.translate(t.vector());
1016template<
typename Scalar,
int Dim,
int Mode,
int Options>
1020 linear().diagonal().fill(s.factor());
1025template<
typename Scalar,
int Dim,
int Mode,
int Options>
1026template<
typename Derived>
1029 linear() = internal::toRotationMatrix<Scalar,Dim>(r);
1030 translation().setZero();
1035template<
typename Scalar,
int Dim,
int Mode,
int Options>
1036template<
typename Derived>
1040 res.rotate(r.derived());
1049template<
int Mode>
struct transform_rotation_impl {
1050 template<
typename TransformType>
1051 EIGEN_DEVICE_FUNC
static inline
1052 const typename TransformType::LinearMatrixType run(
const TransformType& t)
1054 typedef typename TransformType::LinearMatrixType LinearMatrixType;
1055 LinearMatrixType result;
1056 t.computeRotationScaling(&result, (LinearMatrixType*)0);
1060template<>
struct transform_rotation_impl<
Isometry> {
1061 template<
typename TransformType>
1062 EIGEN_DEVICE_FUNC
static inline
1063 typename TransformType::ConstLinearPart run(
const TransformType& t)
1079template<
typename Scalar,
int Dim,
int Mode,
int Options>
1081typename Transform<Scalar,Dim,Mode,Options>::RotationReturnType
1084 return internal::transform_rotation_impl<Mode>::run(*
this);
1099template<
typename Scalar,
int Dim,
int Mode,
int Options>
1100template<
typename RotationMatrixType,
typename ScalingMatrixType>
1109 if(scaling) *scaling = svd.
matrixV() * sv.asDiagonal() * svd.
matrixV().adjoint();
1129template<
typename Scalar,
int Dim,
int Mode,
int Options>
1130template<
typename ScalingMatrixType,
typename RotationMatrixType>
1139 if(scaling) *scaling = svd.
matrixU() * sv.asDiagonal() * svd.
matrixU().adjoint();
1151template<
typename Scalar,
int Dim,
int Mode,
int Options>
1152template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
1157 linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1158 linear() *= scale.asDiagonal();
1167struct transform_make_affine
1169 template<
typename MatrixType>
1170 EIGEN_DEVICE_FUNC
static void run(
MatrixType &mat)
1172 static const int Dim = MatrixType::ColsAtCompileTime-1;
1173 mat.template block<1,Dim>(Dim,0).setZero();
1174 mat.coeffRef(Dim,Dim) =
typename MatrixType::Scalar(1);
1181 template<
typename MatrixType> EIGEN_DEVICE_FUNC
static void run(MatrixType &) { }
1185template<
typename TransformType,
int Mode=TransformType::Mode>
1186struct projective_transform_inverse
1188 EIGEN_DEVICE_FUNC
static inline void run(
const TransformType&, TransformType&)
1192template<
typename TransformType>
1193struct projective_transform_inverse<TransformType,
Projective>
1195 EIGEN_DEVICE_FUNC
static inline void run(
const TransformType& m, TransformType& res)
1197 res.matrix() = m.matrix().inverse();
1224template<
typename Scalar,
int Dim,
int Mode,
int Options>
1231 internal::projective_transform_inverse<Transform>::run(*
this, res);
1237 res.
matrix().template topLeftCorner<Dim,Dim>() =
linear().transpose();
1241 res.
matrix().template topLeftCorner<Dim,Dim>() =
linear().inverse();
1245 eigen_assert(
false &&
"Invalid transform traits in Transform::Inverse");
1248 res.
matrix().template topRightCorner<Dim,1>()
1261template<
typename TransformType>
struct transform_take_affine_part {
1262 typedef typename TransformType::MatrixType
MatrixType;
1263 typedef typename TransformType::AffinePart AffinePart;
1264 typedef typename TransformType::ConstAffinePart ConstAffinePart;
1266 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1267 static inline ConstAffinePart run(
const MatrixType& m)
1268 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1271template<
typename Scalar,
int Dim,
int Options>
1272struct transform_take_affine_part<Transform<Scalar,Dim,
AffineCompact, Options> > {
1274 static inline MatrixType& run(MatrixType& m) {
return m; }
1275 static inline const MatrixType& run(
const MatrixType& m) {
return m; }
1282template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1283struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1285 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1287 transform->linear() = other;
1288 transform->translation().setZero();
1289 transform->makeAffine();
1293template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1294struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1296 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1298 transform->affine() = other;
1299 transform->makeAffine();
1303template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1304struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1306 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1307 { transform->matrix() = other; }
1310template<
typename Other,
int Options,
int Dim,
int HDim>
1311struct transform_construct_from_matrix<Other,
AffineCompact,Options,Dim,HDim, HDim,HDim>
1313 static inline void run(Transform<typename Other::Scalar,Dim,AffineCompact,Options> *transform,
const Other& other)
1314 { transform->matrix() = other.template block<Dim,HDim>(0,0); }
1321template<
int LhsMode,
int RhsMode>
1322struct transform_product_result
1334template<
typename TransformType,
typename MatrixType,
int RhsCols>
1335struct transform_right_product_impl< TransformType, MatrixType, 0, RhsCols>
1337 typedef typename MatrixType::PlainObject ResultType;
1339 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1341 return T.matrix() * other;
1345template<
typename TransformType,
typename MatrixType,
int RhsCols>
1346struct transform_right_product_impl< TransformType, MatrixType, 1, RhsCols>
1349 Dim = TransformType::Dim,
1350 HDim = TransformType::HDim,
1351 OtherRows = MatrixType::RowsAtCompileTime,
1352 OtherCols = MatrixType::ColsAtCompileTime
1355 typedef typename MatrixType::PlainObject ResultType;
1357 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1359 EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1361 typedef Block<ResultType, Dim, OtherCols, int(MatrixType::RowsAtCompileTime)==Dim> TopLeftLhs;
1363 ResultType res(other.rows(),other.cols());
1364 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1365 res.row(OtherRows-1) = other.row(OtherRows-1);
1371template<
typename TransformType,
typename MatrixType,
int RhsCols>
1372struct transform_right_product_impl< TransformType, MatrixType, 2, RhsCols>
1375 Dim = TransformType::Dim,
1376 HDim = TransformType::HDim,
1377 OtherRows = MatrixType::RowsAtCompileTime,
1378 OtherCols = MatrixType::ColsAtCompileTime
1381 typedef typename MatrixType::PlainObject ResultType;
1383 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1385 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1387 typedef Block<ResultType, Dim, OtherCols, true> TopLeftLhs;
1388 ResultType res(Replicate<typename TransformType::ConstTranslationPart, 1, OtherCols>(T.translation(),1,other.cols()));
1389 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1395template<
typename TransformType,
typename MatrixType >
1396struct transform_right_product_impl< TransformType, MatrixType, 2, 1>
1398 typedef typename TransformType::MatrixType TransformMatrix;
1400 Dim = TransformType::Dim,
1401 HDim = TransformType::HDim,
1402 OtherRows = MatrixType::RowsAtCompileTime,
1403 WorkingRows = EIGEN_PLAIN_ENUM_MIN(TransformMatrix::RowsAtCompileTime,HDim)
1406 typedef typename MatrixType::PlainObject ResultType;
1408 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1410 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1412 Matrix<typename ResultType::Scalar, Dim+1, 1> rhs;
1413 rhs.template head<Dim>() = other; rhs[Dim] =
typename ResultType::Scalar(1);
1414 Matrix<typename ResultType::Scalar, WorkingRows, 1> res(T.matrix() * rhs);
1415 return res.template head<Dim>();
1424template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1425struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1427 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1428 typedef typename TransformType::MatrixType MatrixType;
1429 typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1430 static ResultType run(
const Other& other,
const TransformType& tr)
1431 {
return ResultType(other * tr.matrix()); }
1435template<
typename Other,
int Options,
int Dim,
int HDim>
1436struct transform_left_product_impl<Other,
AffineCompact,Options,Dim,HDim, HDim,HDim>
1438 typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1439 typedef typename TransformType::MatrixType MatrixType;
1440 typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1441 static ResultType run(
const Other& other,
const TransformType& tr)
1444 res.matrix().noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1445 res.matrix().col(Dim) += other.col(Dim);
1451template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1452struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1454 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1455 typedef typename TransformType::MatrixType MatrixType;
1456 typedef TransformType ResultType;
1457 static ResultType run(
const Other& other,
const TransformType& tr)
1460 res.affine().noalias() = other * tr.matrix();
1461 res.matrix().row(Dim) = tr.matrix().row(Dim);
1467template<
typename Other,
int Options,
int Dim,
int HDim>
1468struct transform_left_product_impl<Other,
AffineCompact,Options,Dim,HDim, Dim,HDim>
1470 typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1471 typedef typename TransformType::MatrixType MatrixType;
1472 typedef TransformType ResultType;
1473 static ResultType run(
const Other& other,
const TransformType& tr)
1476 res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1477 res.translation() += other.col(Dim);
1483template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1484struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1486 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1487 typedef typename TransformType::MatrixType MatrixType;
1488 typedef TransformType ResultType;
1489 static ResultType run(
const Other& other,
const TransformType& tr)
1492 if(Mode!=
int(AffineCompact))
1493 res.matrix().row(Dim) = tr.matrix().row(Dim);
1494 res.matrix().template topRows<Dim>().noalias()
1495 = other * tr.matrix().template topRows<Dim>();
1504template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1505struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >
1507 enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
1508 typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1509 typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1510 typedef Transform<Scalar,Dim,ResultMode,LhsOptions> ResultType;
1511 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1514 res.linear() = lhs.linear() * rhs.linear();
1515 res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1521template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1522struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >
1524 typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1525 typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1526 typedef Transform<Scalar,Dim,Projective> ResultType;
1527 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1529 return ResultType( lhs.matrix() * rhs.matrix() );
1533template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1534struct transform_transform_product_impl<Transform<Scalar,Dim,
AffineCompact,LhsOptions>,Transform<Scalar,Dim,
Projective,RhsOptions>,true >
1536 typedef Transform<Scalar,Dim,AffineCompact,LhsOptions> Lhs;
1537 typedef Transform<Scalar,Dim,Projective,RhsOptions> Rhs;
1538 typedef Transform<Scalar,Dim,Projective> ResultType;
1539 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1542 res.matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1543 res.matrix().row(Dim) = rhs.matrix().row(Dim);
1548template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1549struct transform_transform_product_impl<Transform<Scalar,Dim,
Projective,LhsOptions>,Transform<Scalar,Dim,
AffineCompact,RhsOptions>,true >
1551 typedef Transform<Scalar,Dim,Projective,LhsOptions> Lhs;
1552 typedef Transform<Scalar,Dim,AffineCompact,RhsOptions> Rhs;
1553 typedef Transform<Scalar,Dim,Projective> ResultType;
1554 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1556 ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1557 res.matrix().col(Dim) += lhs.matrix().col(Dim);
Expression of a fixed-size or dynamic-size block.
Definition Block.h:105
RowXpr row(Index i)
Definition DenseBase.h:1119
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition JacobiSVD.h:490
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
const DiagonalWrapper< const Derived > asDiagonal() const
Definition DiagonalMatrix.h:325
static const IdentityReturnType Identity()
Definition CwiseNullaryOp.h:799
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:180
Scalar & coeffRef(Index rowId, Index colId)
Definition PlainObjectBase.h:175
Derived & setZero(Index size)
Definition CwiseNullaryOp.h:562
Common base class for compact rotation representations.
Definition RotationBase.h:30
const SingularValuesType & singularValues() const
Definition SVDBase.h:129
const MatrixUType & matrixU() const
Definition SVDBase.h:101
const MatrixVType & matrixV() const
Definition SVDBase.h:117
Represents a translation transformation.
Definition Translation.h:31
TransformTraits
Definition Constants.h:455
@ DontAlign
Definition Constants.h:325
@ RowMajor
Definition Constants.h:321
@ ComputeFullV
Definition Constants.h:397
@ ComputeFullU
Definition Constants.h:393
@ Affine
Definition Constants.h:460
@ Projective
Definition Constants.h:464
@ AffineCompact
Definition Constants.h:462
@ Isometry
Definition Constants.h:457
const unsigned int RowMajorBit
Definition Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
Definition Constants.h:22
Definition EigenBase.h:30
Derived & derived()
Definition EigenBase.h:46