Transform.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5 // Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
6 // Copyright (C) 2010 Hauke Heibel <hauke.heibel@gmail.com>
7 //
8 // This Source Code Form is subject to the terms of the Mozilla
9 // Public License v. 2.0. If a copy of the MPL was not distributed
10 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 
12 #ifndef EIGEN_TRANSFORM_H
13 #define EIGEN_TRANSFORM_H
14 
15 #include "./InternalHeaderCheck.h"
16 
17 namespace Eigen {
18 
19 namespace internal {
20 
21 template<typename Transform>
22 struct transform_traits
23 {
24  enum
25  {
26  Dim = Transform::Dim,
27  HDim = Transform::HDim,
28  Mode = Transform::Mode,
29  IsProjective = (int(Mode)==int(Projective))
30  };
31 };
32 
33 template< typename TransformType,
34  typename MatrixType,
35  int Case = transform_traits<TransformType>::IsProjective ? 0
36  : int(MatrixType::RowsAtCompileTime) == int(transform_traits<TransformType>::HDim) ? 1
37  : 2,
38  int RhsCols = MatrixType::ColsAtCompileTime>
39 struct transform_right_product_impl;
40 
41 template< typename Other,
42  int Mode,
43  int Options,
44  int Dim,
45  int HDim,
46  int OtherRows=Other::RowsAtCompileTime,
47  int OtherCols=Other::ColsAtCompileTime>
48 struct transform_left_product_impl;
49 
50 template< typename Lhs,
51  typename Rhs,
52  bool AnyProjective =
53  transform_traits<Lhs>::IsProjective ||
54  transform_traits<Rhs>::IsProjective>
55 struct transform_transform_product_impl;
56 
57 template< typename Other,
58  int Mode,
59  int Options,
60  int Dim,
61  int HDim,
62  int OtherRows=Other::RowsAtCompileTime,
63  int OtherCols=Other::ColsAtCompileTime>
64 struct transform_construct_from_matrix;
65 
66 template<typename TransformType> struct transform_take_affine_part;
67 
68 template<typename Scalar_, int Dim_, int Mode_, int Options_>
69 struct traits<Transform<Scalar_,Dim_,Mode_,Options_> >
70 {
71  typedef Scalar_ Scalar;
72  typedef Eigen::Index StorageIndex;
73  typedef Dense StorageKind;
74  enum {
75  Dim1 = Dim_==Dynamic ? Dim_ : Dim_ + 1,
76  RowsAtCompileTime = Mode_==Projective ? Dim1 : Dim_,
77  ColsAtCompileTime = Dim1,
78  MaxRowsAtCompileTime = RowsAtCompileTime,
79  MaxColsAtCompileTime = ColsAtCompileTime,
80  Flags = 0
81  };
82 };
83 
84 template<int Mode> struct transform_make_affine;
85 
86 } // end namespace internal
87 
205 template<typename Scalar_, int Dim_, int Mode_, int Options_>
207 {
208 public:
210  enum {
211  Mode = Mode_,
212  Options = Options_,
213  Dim = Dim_,
214  HDim = Dim_+1,
215  Rows = int(Mode)==(AffineCompact) ? Dim : HDim
216  };
218  typedef Scalar_ Scalar;
220  typedef Eigen::Index Index;
228  typedef Block<MatrixType,Dim,Dim,int(Mode)==(AffineCompact) && (int(Options)&RowMajor)==0> LinearPart;
230  typedef const Block<ConstMatrixType,Dim,Dim,int(Mode)==(AffineCompact) && (int(Options)&RowMajor)==0> ConstLinearPart;
232  typedef std::conditional_t<int(Mode)==int(AffineCompact),
233  MatrixType&,
236  typedef std::conditional_t<int(Mode)==int(AffineCompact),
237  const MatrixType&,
242  typedef Block<MatrixType,Dim,1,!(internal::traits<MatrixType>::Flags & RowMajorBit)> TranslationPart;
244  typedef const Block<ConstMatrixType,Dim,1,!(internal::traits<MatrixType>::Flags & RowMajorBit)> ConstTranslationPart;
247 
248  // this intermediate enum is needed to avoid an ICE with gcc 3.4 and 4.0
249  enum { TransformTimeDiagonalMode = ((Mode==int(Isometry))?Affine:int(Mode)) };
252 
253 protected:
254 
256 
257 public:
258 
262  {
263  check_template_params();
264  internal::transform_make_affine<(int(Mode)==Affine || int(Mode)==Isometry) ? Affine : AffineCompact>::run(m_matrix);
265  }
266 
267  EIGEN_DEVICE_FUNC inline explicit Transform(const TranslationType& t)
268  {
269  check_template_params();
270  *this = t;
271  }
273  {
274  check_template_params();
275  *this = s;
276  }
277  template<typename Derived>
279  {
280  check_template_params();
281  *this = r;
282  }
283 
284  typedef internal::transform_take_affine_part<Transform> take_affine_part;
285 
287  template<typename OtherDerived>
289  {
290  EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
291  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
292 
293  check_template_params();
294  internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(this, other.derived());
295  }
296 
298  template<typename OtherDerived>
300  {
301  EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
302  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
303 
304  internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(this, other.derived());
305  return *this;
306  }
307 
308  template<int OtherOptions>
310  {
311  check_template_params();
312  // only the options change, we can directly copy the matrices
313  m_matrix = other.matrix();
314  }
315 
316  template<int OtherMode,int OtherOptions>
318  {
319  check_template_params();
320  // prevent conversions as:
321  // Affine | AffineCompact | Isometry = Projective
323  YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
324 
325  // prevent conversions as:
326  // Isometry = Affine | AffineCompact
327  EIGEN_STATIC_ASSERT(internal::check_implication(OtherMode==int(Affine)||OtherMode==int(AffineCompact), Mode!=int(Isometry)),
328  YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
329 
330  enum { ModeIsAffineCompact = Mode == int(AffineCompact),
331  OtherModeIsAffineCompact = OtherMode == int(AffineCompact)
332  };
333 
334  if(EIGEN_CONST_CONDITIONAL(ModeIsAffineCompact == OtherModeIsAffineCompact))
335  {
336  // We need the block expression because the code is compiled for all
337  // combinations of transformations and will trigger a compile time error
338  // if one tries to assign the matrices directly
339  m_matrix.template block<Dim,Dim+1>(0,0) = other.matrix().template block<Dim,Dim+1>(0,0);
340  makeAffine();
341  }
342  else if(EIGEN_CONST_CONDITIONAL(OtherModeIsAffineCompact))
343  {
344  typedef typename Transform<Scalar,Dim,OtherMode,OtherOptions>::MatrixType OtherMatrixType;
345  internal::transform_construct_from_matrix<OtherMatrixType,Mode,Options,Dim,HDim>::run(this, other.matrix());
346  }
347  else
348  {
349  // here we know that Mode == AffineCompact and OtherMode != AffineCompact.
350  // if OtherMode were Projective, the static assert above would already have caught it.
351  // So the only possibility is that OtherMode == Affine
352  linear() = other.linear();
353  translation() = other.translation();
354  }
355  }
356 
357  template<typename OtherDerived>
359  {
360  check_template_params();
361  other.evalTo(*this);
362  }
363 
364  template<typename OtherDerived>
366  {
367  other.evalTo(*this);
368  return *this;
369  }
370 
371  #ifdef EIGEN_QT_SUPPORT
372  #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
373  inline Transform(const QMatrix& other);
374  inline Transform& operator=(const QMatrix& other);
375  inline QMatrix toQMatrix(void) const;
376  #endif
377  inline Transform(const QTransform& other);
378  inline Transform& operator=(const QTransform& other);
379  inline QTransform toQTransform(void) const;
380  #endif
381 
384 
391 
393  EIGEN_DEVICE_FUNC inline const MatrixType& matrix() const { return m_matrix; }
396 
401 
403  EIGEN_DEVICE_FUNC inline ConstAffinePart affine() const { return take_affine_part::run(m_matrix); }
405  EIGEN_DEVICE_FUNC inline AffinePart affine() { return take_affine_part::run(m_matrix); }
406 
411 
436  // note: this function is defined here because some compilers cannot find the respective declaration
437  template<typename OtherDerived>
438  EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename internal::transform_right_product_impl<Transform, OtherDerived>::ResultType
440  { return internal::transform_right_product_impl<Transform, OtherDerived>::run(*this,other.derived()); }
441 
449  template<typename OtherDerived> friend
450  EIGEN_DEVICE_FUNC inline const typename internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim_,Dim_+1>::ResultType
452  { return internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim,HDim>::run(a.derived(),b); }
453 
460  template<typename DiagonalDerived>
463  {
465  res.linearExt() *= b;
466  return res;
467  }
468 
475  template<typename DiagonalDerived>
478  {
480  res.linear().noalias() = a*b.linear();
481  res.translation().noalias() = a*b.translation();
482  if (EIGEN_CONST_CONDITIONAL(Mode!=int(AffineCompact)))
483  res.matrix().row(Dim) = b.matrix().row(Dim);
484  return res;
485  }
486 
487  template<typename OtherDerived>
488  EIGEN_DEVICE_FUNC inline Transform& operator*=(const EigenBase<OtherDerived>& other) { return *this = *this * other; }
489 
491  EIGEN_DEVICE_FUNC inline const Transform operator * (const Transform& other) const
492  {
493  return internal::transform_transform_product_impl<Transform,Transform>::run(*this,other);
494  }
495 
496  #if EIGEN_COMP_ICC
497 private:
498  // this intermediate structure permits to workaround a bug in ICC 11:
499  // error: template instantiation resulted in unexpected function type of "Eigen::Transform<double, 3, 32, 0>
500  // (const Eigen::Transform<double, 3, 2, 0> &) const"
501  // (the meaning of a name may have changed since the template declaration -- the type of the template is:
502  // "Eigen::internal::transform_transform_product_impl<Eigen::Transform<double, 3, 32, 0>,
503  // Eigen::Transform<double, 3, Mode, Options>, <expression>>::ResultType (const Eigen::Transform<double, 3, Mode, Options> &) const")
504  //
505  template<int OtherMode,int OtherOptions> struct icc_11_workaround
506  {
507  typedef internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> > ProductType;
508  typedef typename ProductType::ResultType ResultType;
509  };
510 
511 public:
513  template<int OtherMode,int OtherOptions>
514  inline typename icc_11_workaround<OtherMode,OtherOptions>::ResultType
515  operator * (const Transform<Scalar,Dim,OtherMode,OtherOptions>& other) const
516  {
517  typedef typename icc_11_workaround<OtherMode,OtherOptions>::ProductType ProductType;
518  return ProductType::run(*this,other);
519  }
520  #else
522  template<int OtherMode,int OtherOptions>
523  EIGEN_DEVICE_FUNC inline typename internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::ResultType
525  {
526  return internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::run(*this,other);
527  }
528  #endif
529 
532 
538  {
540  }
541 
542  template<typename OtherDerived>
544  inline Transform& scale(const MatrixBase<OtherDerived> &other);
545 
546  template<typename OtherDerived>
549 
550  EIGEN_DEVICE_FUNC inline Transform& scale(const Scalar& s);
551  EIGEN_DEVICE_FUNC inline Transform& prescale(const Scalar& s);
552 
553  template<typename OtherDerived>
556 
557  template<typename OtherDerived>
560 
561  template<typename RotationType>
563  inline Transform& rotate(const RotationType& rotation);
564 
565  template<typename RotationType>
567  inline Transform& prerotate(const RotationType& rotation);
568 
569  EIGEN_DEVICE_FUNC Transform& shear(const Scalar& sx, const Scalar& sy);
570  EIGEN_DEVICE_FUNC Transform& preshear(const Scalar& sx, const Scalar& sy);
571 
573 
575  inline Transform& operator*=(const TranslationType& t) { return translate(t.vector()); }
576 
577  EIGEN_DEVICE_FUNC inline Transform operator*(const TranslationType& t) const;
578 
580  inline Transform& operator=(const UniformScaling<Scalar>& t);
581 
583  inline Transform& operator*=(const UniformScaling<Scalar>& s) { return scale(s.factor()); }
584 
587  {
589  res.scale(s.factor());
590  return res;
591  }
592 
594  inline Transform& operator*=(const DiagonalMatrix<Scalar,Dim>& s) { linearExt() *= s; return *this; }
595 
596  template<typename Derived>
598  template<typename Derived>
600  template<typename Derived>
602 
603  typedef std::conditional_t<int(Mode)==Isometry,ConstLinearPart,const LinearMatrixType> RotationReturnType;
605 
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;
612 
613  template<typename PositionDerived, typename OrientationType, typename ScaleDerived>
616  const OrientationType& orientation, const MatrixBase<ScaleDerived> &scale);
617 
619  inline Transform inverse(TransformTraits traits = (TransformTraits)Mode) const;
620 
622  EIGEN_DEVICE_FUNC const Scalar* data() const { return m_matrix.data(); }
625 
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); }
634 
636  template<typename OtherScalarType>
638  {
639  check_template_params();
640  m_matrix = other.matrix().template cast<Scalar>();
641  }
642 
648  { return m_matrix.isApprox(other.m_matrix, prec); }
649 
653  {
654  internal::transform_make_affine<int(Mode)>::run(m_matrix);
655  }
656 
661  EIGEN_DEVICE_FUNC inline Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,Dim> linearExt()
662  { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
667  EIGEN_DEVICE_FUNC inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,Dim> linearExt() const
668  { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
669 
674  EIGEN_DEVICE_FUNC inline Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt()
675  { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
680  EIGEN_DEVICE_FUNC inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt() const
681  { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
682 
683 
684  #ifdef EIGEN_TRANSFORM_PLUGIN
685  #include EIGEN_TRANSFORM_PLUGIN
686  #endif
687 
688 protected:
689  #ifndef EIGEN_PARSED_BY_DOXYGEN
690  EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void check_template_params()
691  {
692  EIGEN_STATIC_ASSERT((Options & (DontAlign|RowMajor)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)
693  }
694  #endif
695 
696 };
697 
706 
715 
724 
733 
734 
738 #ifdef EIGEN_QT_SUPPORT
739 
740 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
745 template<typename Scalar, int Dim, int Mode,int Options>
747 {
748  check_template_params();
749  *this = other;
750 }
751 
756 template<typename Scalar, int Dim, int Mode,int Options>
757 Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(const QMatrix& other)
758 {
759  EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
760  if (EIGEN_CONST_CONDITIONAL(Mode == int(AffineCompact)))
761  m_matrix << other.m11(), other.m21(), other.dx(),
762  other.m12(), other.m22(), other.dy();
763  else
764  m_matrix << other.m11(), other.m21(), other.dx(),
765  other.m12(), other.m22(), other.dy(),
766  0, 0, 1;
767  return *this;
768 }
769 
776 template<typename Scalar, int Dim, int Mode, int Options>
777 QMatrix Transform<Scalar,Dim,Mode,Options>::toQMatrix(void) const
778 {
779  check_template_params();
780  EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
781  return QMatrix(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
782  m_matrix.coeff(0,1), m_matrix.coeff(1,1),
783  m_matrix.coeff(0,2), m_matrix.coeff(1,2));
784 }
785 #endif
786 
791 template<typename Scalar, int Dim, int Mode,int Options>
793 {
794  check_template_params();
795  *this = other;
796 }
797 
802 template<typename Scalar, int Dim, int Mode, int Options>
804 {
805  check_template_params();
806  EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
807  if (EIGEN_CONST_CONDITIONAL(Mode == int(AffineCompact)))
808  m_matrix << other.m11(), other.m21(), other.dx(),
809  other.m12(), other.m22(), other.dy();
810  else
811  m_matrix << other.m11(), other.m21(), other.dx(),
812  other.m12(), other.m22(), other.dy(),
813  other.m13(), other.m23(), other.m33();
814  return *this;
815 }
816 
821 template<typename Scalar, int Dim, int Mode, int Options>
823 {
824  EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
825  if (EIGEN_CONST_CONDITIONAL(Mode == int(AffineCompact)))
826  return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
827  m_matrix.coeff(0,1), m_matrix.coeff(1,1),
828  m_matrix.coeff(0,2), m_matrix.coeff(1,2));
829  else
830  return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0),
831  m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1),
832  m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2));
833 }
834 #endif
835 
836 
844 template<typename Scalar, int Dim, int Mode, int Options>
845 template<typename OtherDerived>
848 {
849  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
850  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
851  linearExt().noalias() = (linearExt() * other.asDiagonal());
852  return *this;
853 }
854 
859 template<typename Scalar, int Dim, int Mode, int Options>
861 {
862  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
863  linearExt() *= s;
864  return *this;
865 }
866 
871 template<typename Scalar, int Dim, int Mode, int Options>
872 template<typename OtherDerived>
875 {
876  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
877  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
878  affine().noalias() = (other.asDiagonal() * affine());
879  return *this;
880 }
881 
886 template<typename Scalar, int Dim, int Mode, int Options>
888 {
889  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
890  m_matrix.template topRows<Dim>() *= s;
891  return *this;
892 }
893 
898 template<typename Scalar, int Dim, int Mode, int Options>
899 template<typename OtherDerived>
902 {
903  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
904  translationExt() += linearExt() * other;
905  return *this;
906 }
907 
912 template<typename Scalar, int Dim, int Mode, int Options>
913 template<typename OtherDerived>
916 {
917  EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
918  if(EIGEN_CONST_CONDITIONAL(int(Mode)==int(Projective)))
919  affine() += other * m_matrix.row(Dim);
920  else
921  translation() += other;
922  return *this;
923 }
924 
942 template<typename Scalar, int Dim, int Mode, int Options>
943 template<typename RotationType>
945 Transform<Scalar,Dim,Mode,Options>::rotate(const RotationType& rotation)
946 {
947  linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
948  return *this;
949 }
950 
958 template<typename Scalar, int Dim, int Mode, int Options>
959 template<typename RotationType>
962 {
963  m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
964  * m_matrix.template block<Dim,HDim>(0,0);
965  return *this;
966 }
967 
973 template<typename Scalar, int Dim, int Mode, int Options>
976 {
977  EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
978  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
979  VectorType tmp = linear().col(0)*sy + linear().col(1);
980  linear() << linear().col(0) + linear().col(1)*sx, tmp;
981  return *this;
982 }
983 
989 template<typename Scalar, int Dim, int Mode, int Options>
992 {
993  EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
994  EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
995  m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
996  return *this;
997 }
998 
999 
1003 template<typename Scalar, int Dim, int Mode, int Options>
1005 {
1006  linear().setIdentity();
1007  translation() = t.vector();
1008  makeAffine();
1009  return *this;
1010 }
1011 
1012 template<typename Scalar, int Dim, int Mode, int Options>
1014 {
1015  Transform res = *this;
1016  res.translate(t.vector());
1017  return res;
1018 }
1019 
1020 template<typename Scalar, int Dim, int Mode, int Options>
1022 {
1023  m_matrix.setZero();
1024  linear().diagonal().fill(s.factor());
1025  makeAffine();
1026  return *this;
1027 }
1028 
1029 template<typename Scalar, int Dim, int Mode, int Options>
1030 template<typename Derived>
1032 {
1033  linear() = internal::toRotationMatrix<Scalar,Dim>(r);
1034  translation().setZero();
1035  makeAffine();
1036  return *this;
1037 }
1038 
1039 template<typename Scalar, int Dim, int Mode, int Options>
1040 template<typename Derived>
1042 {
1043  Transform res = *this;
1044  res.rotate(r.derived());
1045  return res;
1046 }
1047 
1048 
1052 namespace internal {
1053 template<int Mode> struct transform_rotation_impl {
1054  template<typename TransformType>
1055  EIGEN_DEVICE_FUNC static inline
1056  const typename TransformType::LinearMatrixType run(const TransformType& t)
1057  {
1058  typedef typename TransformType::LinearMatrixType LinearMatrixType;
1059  LinearMatrixType result;
1060  t.computeRotationScaling(&result, (LinearMatrixType*)0);
1061  return result;
1062  }
1063 };
1064 template<> struct transform_rotation_impl<Isometry> {
1065  template<typename TransformType>
1066  EIGEN_DEVICE_FUNC static inline
1067  typename TransformType::ConstLinearPart run(const TransformType& t)
1068  {
1069  return t.linear();
1070  }
1071 };
1072 }
1083 template<typename Scalar, int Dim, int Mode, int Options>
1087 {
1088  return internal::transform_rotation_impl<Mode>::run(*this);
1089 }
1090 
1091 
1103 template<typename Scalar, int Dim, int Mode, int Options>
1104 template<typename RotationMatrixType, typename ScalingMatrixType>
1105 EIGEN_DEVICE_FUNC void Transform<Scalar,Dim,Mode,Options>::computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const
1106 {
1107  // Note that JacobiSVD is faster than BDCSVD for small matrices.
1109 
1110  Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant() < Scalar(0) ? Scalar(-1) : Scalar(1); // so x has absolute value 1
1111  VectorType sv(svd.singularValues());
1112  sv.coeffRef(Dim-1) *= x;
1113  if(scaling) *scaling = svd.matrixV() * sv.asDiagonal() * svd.matrixV().adjoint();
1114  if(rotation)
1115  {
1116  LinearMatrixType m(svd.matrixU());
1117  m.col(Dim-1) *= x;
1118  *rotation = m * svd.matrixV().adjoint();
1119  }
1120 }
1121 
1133 template<typename Scalar, int Dim, int Mode, int Options>
1134 template<typename ScalingMatrixType, typename RotationMatrixType>
1135 EIGEN_DEVICE_FUNC void Transform<Scalar,Dim,Mode,Options>::computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const
1136 {
1137  // Note that JacobiSVD is faster than BDCSVD for small matrices.
1139 
1140  Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant() < Scalar(0) ? Scalar(-1) : Scalar(1); // so x has absolute value 1
1141  VectorType sv(svd.singularValues());
1142  sv.coeffRef(Dim-1) *= x;
1143  if(scaling) *scaling = svd.matrixU() * sv.asDiagonal() * svd.matrixU().adjoint();
1144  if(rotation)
1145  {
1146  LinearMatrixType m(svd.matrixU());
1147  m.col(Dim-1) *= x;
1148  *rotation = m * svd.matrixV().adjoint();
1149  }
1150 }
1151 
1155 template<typename Scalar, int Dim, int Mode, int Options>
1156 template<typename PositionDerived, typename OrientationType, typename ScaleDerived>
1159  const OrientationType& orientation, const MatrixBase<ScaleDerived> &scale)
1160 {
1161  linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1162  linear() *= scale.asDiagonal();
1163  translation() = position;
1164  makeAffine();
1165  return *this;
1166 }
1167 
1168 namespace internal {
1169 
1170 template<int Mode>
1171 struct transform_make_affine
1172 {
1173  template<typename MatrixType>
1174  EIGEN_DEVICE_FUNC static void run(MatrixType &mat)
1175  {
1176  static const int Dim = MatrixType::ColsAtCompileTime-1;
1177  mat.template block<1,Dim>(Dim,0).setZero();
1178  mat.coeffRef(Dim,Dim) = typename MatrixType::Scalar(1);
1179  }
1180 };
1181 
1182 template<>
1183 struct transform_make_affine<AffineCompact>
1184 {
1185  template<typename MatrixType> EIGEN_DEVICE_FUNC static void run(MatrixType &) { }
1186 };
1187 
1188 // selector needed to avoid taking the inverse of a 3x4 matrix
1189 template<typename TransformType, int Mode=TransformType::Mode>
1190 struct projective_transform_inverse
1191 {
1192  EIGEN_DEVICE_FUNC static inline void run(const TransformType&, TransformType&)
1193  {}
1194 };
1195 
1196 template<typename TransformType>
1197 struct projective_transform_inverse<TransformType, Projective>
1198 {
1199  EIGEN_DEVICE_FUNC static inline void run(const TransformType& m, TransformType& res)
1200  {
1201  res.matrix() = m.matrix().inverse();
1202  }
1203 };
1204 
1205 } // end namespace internal
1206 
1207 
1228 template<typename Scalar, int Dim, int Mode, int Options>
1229 EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>
1231 {
1232  Transform res;
1233  if (hint == Projective)
1234  {
1235  internal::projective_transform_inverse<Transform>::run(*this, res);
1236  }
1237  else
1238  {
1239  if (hint == Isometry)
1240  {
1241  res.matrix().template topLeftCorner<Dim,Dim>() = linear().transpose();
1242  }
1243  else if(hint&Affine)
1244  {
1245  res.matrix().template topLeftCorner<Dim,Dim>() = linear().inverse();
1246  }
1247  else
1248  {
1249  eigen_assert(false && "Invalid transform traits in Transform::Inverse");
1250  }
1251  // translation and remaining parts
1252  res.matrix().template topRightCorner<Dim,1>()
1253  = - res.matrix().template topLeftCorner<Dim,Dim>() * translation();
1254  res.makeAffine(); // we do need this, because in the beginning res is uninitialized
1255  }
1256  return res;
1257 }
1258 
1259 namespace internal {
1260 
1261 
1265 template<typename TransformType> struct transform_take_affine_part {
1266  typedef typename TransformType::MatrixType MatrixType;
1267  typedef typename TransformType::AffinePart AffinePart;
1268  typedef typename TransformType::ConstAffinePart ConstAffinePart;
1269  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE AffinePart run(MatrixType& m)
1270  { return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1271  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ConstAffinePart run(const MatrixType& m)
1272  { return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1273 };
1274 
1275 template<typename Scalar, int Dim, int Options>
1276 struct transform_take_affine_part<Transform<Scalar,Dim,AffineCompact, Options> > {
1278  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE MatrixType& run(MatrixType& m) { return m; }
1279  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const MatrixType& run(const MatrixType& m) { return m; }
1280 };
1281 
1282 
1286 template<typename Other, int Mode, int Options, int Dim, int HDim>
1287 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1288 {
1289  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform, const Other& other)
1290  {
1291  transform->linear() = other;
1292  transform->translation().setZero();
1293  transform->makeAffine();
1294  }
1295 };
1296 
1297 template<typename Other, int Mode, int Options, int Dim, int HDim>
1298 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1299 {
1300  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform, const Other& other)
1301  {
1302  transform->affine() = other;
1303  transform->makeAffine();
1304  }
1305 };
1306 
1307 template<typename Other, int Mode, int Options, int Dim, int HDim>
1308 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1309 {
1310  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform, const Other& other)
1311  { transform->matrix() = other; }
1312 };
1313 
1314 template<typename Other, int Options, int Dim, int HDim>
1315 struct transform_construct_from_matrix<Other, AffineCompact,Options,Dim,HDim, HDim,HDim>
1316 {
1317  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE void run(Transform<typename Other::Scalar,Dim,AffineCompact,Options> *transform, const Other& other)
1318  { transform->matrix() = other.template block<Dim,HDim>(0,0); }
1319 };
1320 
1321 
1325 template<int LhsMode,int RhsMode>
1326 struct transform_product_result
1327 {
1328  enum
1329  {
1330  Mode =
1331  (LhsMode == (int)Projective || RhsMode == (int)Projective ) ? Projective :
1332  (LhsMode == (int)Affine || RhsMode == (int)Affine ) ? Affine :
1333  (LhsMode == (int)AffineCompact || RhsMode == (int)AffineCompact ) ? AffineCompact :
1334  (LhsMode == (int)Isometry || RhsMode == (int)Isometry ) ? Isometry : Projective
1335  };
1336 };
1337 
1338 template< typename TransformType, typename MatrixType, int RhsCols>
1339 struct transform_right_product_impl< TransformType, MatrixType, 0, RhsCols>
1340 {
1341  typedef typename MatrixType::PlainObject ResultType;
1342 
1343  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)
1344  {
1345  return T.matrix() * other;
1346  }
1347 };
1348 
1349 template< typename TransformType, typename MatrixType, int RhsCols>
1350 struct transform_right_product_impl< TransformType, MatrixType, 1, RhsCols>
1351 {
1352  enum {
1353  Dim = TransformType::Dim,
1354  HDim = TransformType::HDim,
1355  OtherRows = MatrixType::RowsAtCompileTime,
1356  OtherCols = MatrixType::ColsAtCompileTime
1357  };
1358 
1359  typedef typename MatrixType::PlainObject ResultType;
1360 
1361  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)
1362  {
1363  EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1364 
1365  typedef Block<ResultType, Dim, OtherCols, int(MatrixType::RowsAtCompileTime)==Dim> TopLeftLhs;
1366 
1367  ResultType res(other.rows(),other.cols());
1368  TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1369  res.row(OtherRows-1) = other.row(OtherRows-1);
1370 
1371  return res;
1372  }
1373 };
1374 
1375 template< typename TransformType, typename MatrixType, int RhsCols>
1376 struct transform_right_product_impl< TransformType, MatrixType, 2, RhsCols>
1377 {
1378  enum {
1379  Dim = TransformType::Dim,
1380  HDim = TransformType::HDim,
1381  OtherRows = MatrixType::RowsAtCompileTime,
1382  OtherCols = MatrixType::ColsAtCompileTime
1383  };
1384 
1385  typedef typename MatrixType::PlainObject ResultType;
1386 
1387  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)
1388  {
1389  EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1390 
1391  typedef Block<ResultType, Dim, OtherCols, true> TopLeftLhs;
1392  ResultType res(Replicate<typename TransformType::ConstTranslationPart, 1, OtherCols>(T.translation(),1,other.cols()));
1393  TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1394 
1395  return res;
1396  }
1397 };
1398 
1399 template< typename TransformType, typename MatrixType >
1400 struct transform_right_product_impl< TransformType, MatrixType, 2, 1> // rhs is a vector of size Dim
1401 {
1402  typedef typename TransformType::MatrixType TransformMatrix;
1403  enum {
1404  Dim = TransformType::Dim,
1405  HDim = TransformType::HDim,
1406  OtherRows = MatrixType::RowsAtCompileTime,
1407  WorkingRows = plain_enum_min(TransformMatrix::RowsAtCompileTime, HDim)
1408  };
1409 
1410  typedef typename MatrixType::PlainObject ResultType;
1411 
1412  static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)
1413  {
1414  EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1415 
1416  Matrix<typename ResultType::Scalar, Dim+1, 1> rhs;
1417  rhs.template head<Dim>() = other; rhs[Dim] = typename ResultType::Scalar(1);
1418  Matrix<typename ResultType::Scalar, WorkingRows, 1> res(T.matrix() * rhs);
1419  return res.template head<Dim>();
1420  }
1421 };
1422 
1423 
1427 // generic HDim x HDim matrix * T => Projective
1428 template<typename Other,int Mode, int Options, int Dim, int HDim>
1429 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1430 {
1431  typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1432  typedef typename TransformType::MatrixType MatrixType;
1433  typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1434  static ResultType run(const Other& other,const TransformType& tr)
1435  { return ResultType(other * tr.matrix()); }
1436 };
1437 
1438 // generic HDim x HDim matrix * AffineCompact => Projective
1439 template<typename Other, int Options, int Dim, int HDim>
1440 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, HDim,HDim>
1441 {
1442  typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1443  typedef typename TransformType::MatrixType MatrixType;
1444  typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1445  static ResultType run(const Other& other,const TransformType& tr)
1446  {
1447  ResultType res;
1448  res.matrix().noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1449  res.matrix().col(Dim) += other.col(Dim);
1450  return res;
1451  }
1452 };
1453 
1454 // affine matrix * T
1455 template<typename Other,int Mode, int Options, int Dim, int HDim>
1456 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1457 {
1458  typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1459  typedef typename TransformType::MatrixType MatrixType;
1460  typedef TransformType ResultType;
1461  static ResultType run(const Other& other,const TransformType& tr)
1462  {
1463  ResultType res;
1464  res.affine().noalias() = other * tr.matrix();
1465  res.matrix().row(Dim) = tr.matrix().row(Dim);
1466  return res;
1467  }
1468 };
1469 
1470 // affine matrix * AffineCompact
1471 template<typename Other, int Options, int Dim, int HDim>
1472 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, Dim,HDim>
1473 {
1474  typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1475  typedef typename TransformType::MatrixType MatrixType;
1476  typedef TransformType ResultType;
1477  static ResultType run(const Other& other,const TransformType& tr)
1478  {
1479  ResultType res;
1480  res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1481  res.translation() += other.col(Dim);
1482  return res;
1483  }
1484 };
1485 
1486 // linear matrix * T
1487 template<typename Other,int Mode, int Options, int Dim, int HDim>
1488 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1489 {
1490  typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1491  typedef typename TransformType::MatrixType MatrixType;
1492  typedef TransformType ResultType;
1493  static ResultType run(const Other& other, const TransformType& tr)
1494  {
1495  TransformType res;
1496  if(Mode!=int(AffineCompact))
1497  res.matrix().row(Dim) = tr.matrix().row(Dim);
1498  res.matrix().template topRows<Dim>().noalias()
1499  = other * tr.matrix().template topRows<Dim>();
1500  return res;
1501  }
1502 };
1503 
1504 
1508 template<typename Scalar, int Dim, int LhsMode, int LhsOptions, int RhsMode, int RhsOptions>
1509 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >
1510 {
1511  enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
1512  typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1513  typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1514  typedef Transform<Scalar,Dim,ResultMode,LhsOptions> ResultType;
1515  static ResultType run(const Lhs& lhs, const Rhs& rhs)
1516  {
1517  ResultType res;
1518  res.linear() = lhs.linear() * rhs.linear();
1519  res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1520  res.makeAffine();
1521  return res;
1522  }
1523 };
1524 
1525 template<typename Scalar, int Dim, int LhsMode, int LhsOptions, int RhsMode, int RhsOptions>
1526 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >
1527 {
1528  typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1529  typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1530  typedef Transform<Scalar,Dim,Projective> ResultType;
1531  static ResultType run(const Lhs& lhs, const Rhs& rhs)
1532  {
1533  return ResultType( lhs.matrix() * rhs.matrix() );
1534  }
1535 };
1536 
1537 template<typename Scalar, int Dim, int LhsOptions, int RhsOptions>
1538 struct transform_transform_product_impl<Transform<Scalar,Dim,AffineCompact,LhsOptions>,Transform<Scalar,Dim,Projective,RhsOptions>,true >
1539 {
1540  typedef Transform<Scalar,Dim,AffineCompact,LhsOptions> Lhs;
1541  typedef Transform<Scalar,Dim,Projective,RhsOptions> Rhs;
1542  typedef Transform<Scalar,Dim,Projective> ResultType;
1543  static ResultType run(const Lhs& lhs, const Rhs& rhs)
1544  {
1545  ResultType res;
1546  res.matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1547  res.matrix().row(Dim) = rhs.matrix().row(Dim);
1548  return res;
1549  }
1550 };
1551 
1552 template<typename Scalar, int Dim, int LhsOptions, int RhsOptions>
1553 struct transform_transform_product_impl<Transform<Scalar,Dim,Projective,LhsOptions>,Transform<Scalar,Dim,AffineCompact,RhsOptions>,true >
1554 {
1555  typedef Transform<Scalar,Dim,Projective,LhsOptions> Lhs;
1556  typedef Transform<Scalar,Dim,AffineCompact,RhsOptions> Rhs;
1557  typedef Transform<Scalar,Dim,Projective> ResultType;
1558  static ResultType run(const Lhs& lhs, const Rhs& rhs)
1559  {
1560  ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1561  res.matrix().col(Dim) += lhs.matrix().col(Dim);
1562  return res;
1563  }
1564 };
1565 
1566 } // end namespace internal
1567 
1568 } // end namespace Eigen
1569 
1570 #endif // EIGEN_TRANSFORM_H
Matrix3f m
Array< int, 3, 1 > b
RowXpr row(Index i)
This is the const version of row(). *‍/.
ColXpr col(Index i)
This is the const version of col().
cout<< "Here is the matrix m:"<< endl<< m<< endl;JacobiSVD< MatrixXf, ComputeThinU|ComputeThinV > svd(m)
#define EIGEN_CONST_CONDITIONAL(cond)
Definition: Macros.h:1048
#define EIGEN_NOEXCEPT
Definition: Macros.h:1260
#define EIGEN_CONSTEXPR
Definition: Macros.h:747
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:883
#define eigen_assert(x)
Definition: Macros.h:902
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
#define EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(TYPE, SIZE)
Definition: StaticAssert.h:51
Matrix< float, 1, Dynamic > MatrixType
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:107
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:61
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:105
Base class for diagonal matrices and expressions.
Represents a diagonal matrix with its storage.
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: JacobiSVD.h:514
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:52
const DiagonalWrapper< const Derived > asDiagonal() const
Derived & setIdentity()
static const IdentityReturnType Identity()
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
Base::PlainObject PlainObject
Definition: Matrix.h:194
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
constexpr const Scalar & coeff(Index rowId, Index colId) const
const Scalar * data() const
Derived & setZero(Index size)
constexpr Scalar & coeffRef(Index rowId, Index colId)
void evalTo(Dest &dst) const
Definition: ReturnByValue.h:63
Common base class for compact rotation representations.
Definition: RotationBase.h:32
const Derived & derived() const
Definition: RotationBase.h:43
RotationMatrixType toRotationMatrix() const
Definition: RotationBase.h:47
Represents an homogeneous transformation in a N dimensional space.
Definition: Transform.h:207
Scalar * data()
Definition: Transform.h:624
ConstAffinePart affine() const
Definition: Transform.h:403
std::conditional_t< int(Mode)==int(AffineCompact), const MatrixType &, const Block< const MatrixType, Dim, HDim > > ConstAffinePart
Definition: Transform.h:238
Transform & pretranslate(const MatrixBase< OtherDerived > &other)
ConstLinearPart linear() const
Definition: Transform.h:398
static const Transform Identity()
Returns an identity transformation.
Definition: Transform.h:537
Transform & preshear(const Scalar &sx, const Scalar &sy)
Definition: Transform.h:991
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: Transform.h:383
void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const
Definition: Transform.h:1135
const Block< MatrixType, int(Mode)==int(Projective)?HDim:Dim, Dim > linearExt() const
Definition: Transform.h:667
Transform & operator*=(const TranslationType &t)
Definition: Transform.h:575
internal::make_proper_matrix_type< Scalar, Rows, HDim, Options >::type MatrixType
Definition: Transform.h:222
Scalar operator()(Index row, Index col) const
Definition: Transform.h:387
Scalar_ Scalar
Definition: Transform.h:216
Transform & scale(const MatrixBase< OtherDerived > &other)
internal::cast_return_type< Transform, Transform< NewScalarType, Dim, Mode, Options > >::type cast() const
Definition: Transform.h:632
TransformTimeDiagonalReturnType operator*(const UniformScaling< Scalar > &s) const
Definition: Transform.h:586
MatrixType m_matrix
Definition: Transform.h:255
MatrixType & matrix()
Definition: Transform.h:395
Transform & operator*=(const DiagonalMatrix< Scalar, Dim > &s)
Definition: Transform.h:594
ConstTranslationPart translation() const
Definition: Transform.h:408
const MatrixType & matrix() const
Definition: Transform.h:393
internal::transform_take_affine_part< Transform > take_affine_part
Definition: Transform.h:284
bool isApprox(const Transform &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Transform.h:647
AffinePart affine()
Definition: Transform.h:405
Transform & operator=(const RotationBase< Derived, Dim > &r)
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: Transform.h:382
void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const
Definition: Transform.h:1105
void setIdentity()
Definition: Transform.h:531
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar_, Dim_==Dynamic ? Dynamic :(Dim_+1) *(Dim_+1)) enum
Definition: Transform.h:209
Matrix< Scalar, Dim, 1 > VectorType
Definition: Transform.h:240
Transform & rotate(const RotationType &rotation)
Block< MatrixType, int(Mode)==int(Projective)?HDim:Dim, Dim > linearExt()
Definition: Transform.h:661
Transform< Scalar, Dim, TransformTimeDiagonalMode > TransformTimeDiagonalReturnType
Definition: Transform.h:251
LinearPart linear()
Definition: Transform.h:400
const internal::transform_right_product_impl< Transform, OtherDerived >::ResultType operator*(const EigenBase< OtherDerived > &other) const
Definition: Transform.h:439
Transform & translate(const MatrixBase< OtherDerived > &other)
Transform operator*(const RotationBase< Derived, Dim > &r) const
Block< MatrixType, Dim, 1,!(internal::traits< MatrixType >::Flags &RowMajorBit)> TranslationPart
Definition: Transform.h:242
Transform(const Transform< Scalar, Dim, OtherMode, OtherOptions > &other)
Definition: Transform.h:317
Transform(const TranslationType &t)
Definition: Transform.h:267
const Block< ConstMatrixType, Dim, Dim, int(Mode)==(AffineCompact) &&(int(Options)&RowMajor)==0 > ConstLinearPart
Definition: Transform.h:230
const Block< MatrixType, int(Mode)==int(Projective)?HDim:Dim, 1 > translationExt() const
Definition: Transform.h:680
std::conditional_t< int(Mode)==int(AffineCompact), MatrixType &, Block< MatrixType, Dim, HDim > > AffinePart
Definition: Transform.h:234
Transform & operator=(const EigenBase< OtherDerived > &other)
Definition: Transform.h:299
Transform(const Transform< OtherScalarType, Dim, Mode, Options > &other)
Definition: Transform.h:637
Transform(const RotationBase< Derived, Dim > &r)
Definition: Transform.h:278
Transform(const EigenBase< OtherDerived > &other)
Definition: Transform.h:288
Transform inverse(TransformTraits traits=(TransformTraits) Mode) const
Definition: Transform.h:1230
Transform & operator=(const ReturnByValue< OtherDerived > &other)
Definition: Transform.h:365
Eigen::Index StorageIndex
Definition: Transform.h:219
Transform & operator*=(const RotationBase< Derived, Dim > &r)
Definition: Transform.h:599
Block< MatrixType, int(Mode)==int(Projective)?HDim:Dim, 1 > translationExt()
Definition: Transform.h:674
Transform & prerotate(const RotationType &rotation)
const Scalar * data() const
Definition: Transform.h:622
@ TransformTimeDiagonalMode
Definition: Transform.h:249
Transform & operator*=(const EigenBase< OtherDerived > &other)
Definition: Transform.h:488
Transform(const Transform< Scalar, Dim, Mode, OtherOptions > &other)
Definition: Transform.h:309
Block< MatrixType, Dim, Dim, int(Mode)==(AffineCompact) &&(int(Options)&RowMajor)==0 > LinearPart
Definition: Transform.h:228
RotationReturnType rotation() const
Definition: Transform.h:1086
const MatrixType ConstMatrixType
Definition: Transform.h:224
Transform & prescale(const MatrixBase< OtherDerived > &other)
void makeAffine()
Definition: Transform.h:652
Transform & fromPositionOrientationScale(const MatrixBase< PositionDerived > &position, const OrientationType &orientation, const MatrixBase< ScaleDerived > &scale)
const Block< ConstMatrixType, Dim, 1,!(internal::traits< MatrixType >::Flags &RowMajorBit)> ConstTranslationPart
Definition: Transform.h:244
Matrix< Scalar, Dim, Dim, Options > LinearMatrixType
Definition: Transform.h:226
Eigen::Index Index
Definition: Transform.h:220
Transform & operator*=(const UniformScaling< Scalar > &s)
Definition: Transform.h:583
Transform & shear(const Scalar &sx, const Scalar &sy)
Definition: Transform.h:975
QTransform toQTransform(void) const
Definition: Transform.h:822
Translation< Scalar, Dim > TranslationType
Definition: Transform.h:246
std::conditional_t< int(Mode)==Isometry, ConstLinearPart, const LinearMatrixType > RotationReturnType
Definition: Transform.h:603
TranslationPart translation()
Definition: Transform.h:410
Transform(const UniformScaling< Scalar > &s)
Definition: Transform.h:272
Transform(const ReturnByValue< OtherDerived > &other)
Definition: Transform.h:358
Represents a translation transformation.
Definition: Translation.h:33
const VectorType & vector() const
Definition: Translation.h:89
Represents a generic uniform scaling transformation.
Definition: Scaling.h:52
const Scalar & factor() const
Definition: Scaling.h:68
Transform< float, 3, Projective > Projective3f
Definition: Transform.h:728
Transform< float, 2, Projective > Projective2f
Definition: Transform.h:726
Transform< float, 3, AffineCompact > AffineCompact3f
Definition: Transform.h:719
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:710
Transform< double, 3, Projective > Projective3d
Definition: Transform.h:732
Transform< double, 2, Isometry > Isometry2d
Definition: Transform.h:703
Transform< double, 3, Isometry > Isometry3d
Definition: Transform.h:705
Transform< double, 2, AffineCompact > AffineCompact2d
Definition: Transform.h:721
Transform< float, 2, Isometry > Isometry2f
Definition: Transform.h:699
Transform< double, 3, Affine > Affine3d
Definition: Transform.h:714
Transform< double, 3, AffineCompact > AffineCompact3d
Definition: Transform.h:723
Transform< double, 2, Affine > Affine2d
Definition: Transform.h:712
Transform< double, 2, Projective > Projective2d
Definition: Transform.h:730
Transform< float, 3, Isometry > Isometry3f
Definition: Transform.h:701
Transform< float, 2, AffineCompact > AffineCompact2f
Definition: Transform.h:717
Transform< float, 2, Affine > Affine2f
Definition: Transform.h:708
TransformTraits
Definition: Constants.h:459
@ DontAlign
Definition: Constants.h:327
@ RowMajor
Definition: Constants.h:323
@ Affine
Definition: Constants.h:464
@ Projective
Definition: Constants.h:468
@ AffineCompact
Definition: Constants.h:466
@ Isometry
Definition: Constants.h:461
const unsigned int RowMajorBit
Definition: Constants.h:68
constexpr int plain_enum_min(A a, B b)
Definition: Meta.h:516
constexpr bool check_implication(bool a, bool b)
Definition: Meta.h:579
: InteropHeaders
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:82
const int Dynamic
Definition: Constants.h:24
Derived & derived()
Definition: EigenBase.h:48
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231