12 #ifndef EIGEN_TRANSFORM_H
13 #define EIGEN_TRANSFORM_H
19 template<
typename Transform>
20 struct transform_traits
25 HDim = Transform::HDim,
26 Mode = Transform::Mode,
31 template<
typename TransformType,
33 int Case = transform_traits<TransformType>::IsProjective ? 0
34 : int(MatrixType::RowsAtCompileTime) == int(transform_traits<TransformType>::HDim) ? 1
36 struct transform_right_product_impl;
38 template<
typename Other,
43 int OtherRows=Other::RowsAtCompileTime,
44 int OtherCols=Other::ColsAtCompileTime>
45 struct transform_left_product_impl;
47 template<
typename Lhs,
50 transform_traits<Lhs>::IsProjective ||
51 transform_traits<Rhs>::IsProjective>
52 struct transform_transform_product_impl;
54 template<
typename Other,
59 int OtherRows=Other::RowsAtCompileTime,
60 int OtherCols=Other::ColsAtCompileTime>
61 struct transform_construct_from_matrix;
63 template<
typename TransformType>
struct transform_take_affine_part;
65 template<
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
66 struct traits<Transform<_Scalar,_Dim,_Mode,_Options> >
68 typedef _Scalar Scalar;
69 typedef Eigen::Index StorageIndex;
70 typedef Dense StorageKind;
72 Dim1 = _Dim==Dynamic ? _Dim : _Dim + 1,
73 RowsAtCompileTime = _Mode==
Projective ? Dim1 : _Dim,
74 ColsAtCompileTime = Dim1,
75 MaxRowsAtCompileTime = RowsAtCompileTime,
76 MaxColsAtCompileTime = ColsAtCompileTime,
81 template<
int Mode>
struct transform_make_affine;
199 template<
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
213 typedef Eigen::Index StorageIndex;
226 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
230 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
243 enum { TransformTimeDiagonalMode = ((Mode==int(
Isometry))?
Affine:
int(Mode)) };
257 check_template_params();
258 internal::transform_make_affine<(int(Mode)==Affine) ? Affine : AffineCompact>::run(m_matrix);
263 check_template_params();
264 m_matrix = other.m_matrix;
267 inline explicit Transform(
const TranslationType& t)
269 check_template_params();
272 inline explicit Transform(
const UniformScaling<Scalar>& s)
274 check_template_params();
277 template<
typename Derived>
278 inline explicit Transform(
const RotationBase<Derived, Dim>& r)
280 check_template_params();
284 inline Transform& operator=(
const Transform& other)
285 { m_matrix = other.m_matrix;
return *
this; }
287 typedef internal::transform_take_affine_part<Transform> take_affine_part;
290 template<
typename OtherDerived>
293 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
294 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
296 check_template_params();
297 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
301 template<
typename OtherDerived>
304 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
305 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
307 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
311 template<
int OtherOptions>
314 check_template_params();
316 m_matrix = other.matrix();
319 template<
int OtherMode,
int OtherOptions>
320 inline Transform(
const Transform<Scalar,Dim,OtherMode,OtherOptions>& other)
322 check_template_params();
326 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
331 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
333 enum { ModeIsAffineCompact = Mode == int(AffineCompact),
334 OtherModeIsAffineCompact = OtherMode == int(AffineCompact)
337 if(ModeIsAffineCompact == OtherModeIsAffineCompact)
342 m_matrix.template block<Dim,Dim+1>(0,0) = other.matrix().template block<Dim,Dim+1>(0,0);
345 else if(OtherModeIsAffineCompact)
347 typedef typename Transform<Scalar,Dim,OtherMode,OtherOptions>::MatrixType OtherMatrixType;
348 internal::transform_construct_from_matrix<OtherMatrixType,Mode,Options,Dim,HDim>::run(
this, other.matrix());
355 linear() = other.linear();
356 translation() = other.translation();
360 template<
typename OtherDerived>
361 Transform(
const ReturnByValue<OtherDerived>& other)
363 check_template_params();
367 template<
typename OtherDerived>
368 Transform& operator=(
const ReturnByValue<OtherDerived>& other)
374 #ifdef EIGEN_QT_SUPPORT
375 inline Transform(
const QMatrix& other);
376 inline Transform& operator=(
const QMatrix& other);
377 inline QMatrix toQMatrix(
void)
const;
378 inline Transform(
const QTransform& other);
379 inline Transform& operator=(
const QTransform& other);
380 inline QTransform toQTransform(
void)
const;
383 Index rows()
const {
return int(Mode)==int(
Projective) ? m_matrix.cols() : (m_matrix.cols()-1); }
384 Index cols()
const {
return m_matrix.cols(); }
388 inline Scalar operator() (Index row, Index col)
const {
return m_matrix(row,col); }
391 inline Scalar& operator() (Index row, Index col) {
return m_matrix(row,col); }
394 inline const MatrixType&
matrix()
const {
return m_matrix; }
396 inline MatrixType&
matrix() {
return m_matrix; }
399 inline ConstLinearPart
linear()
const {
return ConstLinearPart(m_matrix,0,0); }
401 inline LinearPart
linear() {
return LinearPart(m_matrix,0,0); }
404 inline ConstAffinePart
affine()
const {
return take_affine_part::run(m_matrix); }
406 inline AffinePart
affine() {
return take_affine_part::run(m_matrix); }
438 template<
typename OtherDerived>
439 EIGEN_STRONG_INLINE
const typename OtherDerived::PlainObject
441 {
return internal::transform_right_product_impl<Transform, OtherDerived>::run(*
this,other.
derived()); }
450 template<
typename OtherDerived>
friend
451 inline const typename internal::transform_left_product_impl<OtherDerived,Mode,Options,_Dim,_Dim+1>::ResultType
453 {
return internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim,HDim>::run(a.
derived(),b); }
461 template<
typename DiagonalDerived>
462 inline const TransformTimeDiagonalReturnType
463 operator * (
const DiagonalBase<DiagonalDerived> &b)
const
465 TransformTimeDiagonalReturnType res(*
this);
476 template<
typename DiagonalDerived>
477 friend inline TransformTimeDiagonalReturnType
478 operator * (
const DiagonalBase<DiagonalDerived> &a,
const Transform &b)
480 TransformTimeDiagonalReturnType res;
481 res.
linear().noalias() = a*b.linear();
484 res.
matrix().
row(Dim) = b.matrix().row(Dim);
488 template<
typename OtherDerived>
494 return internal::transform_transform_product_impl<Transform,Transform>::run(*
this,other);
506 template<
int OtherMode,
int OtherOptions>
struct icc_11_workaround
508 typedef internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> > ProductType;
509 typedef typename ProductType::ResultType ResultType;
514 template<
int OtherMode,
int OtherOptions>
515 inline typename icc_11_workaround<OtherMode,OtherOptions>::ResultType
516 operator * (
const Transform<Scalar,Dim,OtherMode,OtherOptions>& other)
const
518 typedef typename icc_11_workaround<OtherMode,OtherOptions>::ProductType ProductType;
519 return ProductType::run(*
this,other);
523 template<
int OtherMode,
int OtherOptions>
524 inline typename internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::ResultType
527 return internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::run(*
this,other);
540 return Transform(MatrixType::Identity());
543 template<
typename OtherDerived>
546 template<
typename OtherDerived>
549 inline Transform& scale(
const Scalar& s);
550 inline Transform& prescale(
const Scalar& s);
552 template<
typename OtherDerived>
555 template<
typename OtherDerived>
558 template<
typename RotationType>
559 inline Transform& rotate(
const RotationType& rotation);
561 template<
typename RotationType>
562 inline Transform& prerotate(
const RotationType& rotation);
564 Transform& shear(
const Scalar& sx,
const Scalar& sy);
565 Transform& preshear(
const Scalar& sx,
const Scalar& sy);
567 inline Transform& operator=(
const TranslationType& t);
568 inline Transform& operator*=(
const TranslationType& t) {
return translate(t.vector()); }
569 inline Transform operator*(
const TranslationType& t)
const;
571 inline Transform& operator=(
const UniformScaling<Scalar>& t);
572 inline Transform& operator*=(
const UniformScaling<Scalar>& s) {
return scale(s.factor()); }
573 inline TransformTimeDiagonalReturnType operator*(
const UniformScaling<Scalar>& s)
const
575 TransformTimeDiagonalReturnType res = *
this;
576 res.scale(s.factor());
580 inline Transform& operator*=(
const DiagonalMatrix<Scalar,Dim>& s) { linear() *= s;
return *
this; }
582 template<
typename Derived>
583 inline Transform& operator=(
const RotationBase<Derived,Dim>& r);
584 template<
typename Derived>
585 inline Transform& operator*=(
const RotationBase<Derived,Dim>& r) {
return rotate(r.toRotationMatrix()); }
586 template<
typename Derived>
587 inline Transform operator*(
const RotationBase<Derived,Dim>& r)
const;
589 const LinearMatrixType rotation()
const;
590 template<
typename RotationMatrixType,
typename ScalingMatrixType>
591 void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling)
const;
592 template<
typename ScalingMatrixType,
typename RotationMatrixType>
593 void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation)
const;
595 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
596 Transform& fromPositionOrientationScale(
const MatrixBase<PositionDerived> &position,
597 const OrientationType& orientation,
const MatrixBase<ScaleDerived> &scale);
602 const Scalar*
data()
const {
return m_matrix.
data(); }
611 template<
typename NewScalarType>
612 inline typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type
cast()
const
613 {
return typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type(*
this); }
616 template<
typename OtherScalarType>
619 check_template_params();
620 m_matrix = other.matrix().template cast<Scalar>();
628 {
return m_matrix.
isApprox(other.m_matrix, prec); }
634 internal::transform_make_affine<int(Mode)>::run(m_matrix);
642 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
647 inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,Dim> linearExt()
const
648 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
654 inline Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt()
655 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
660 inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt()
const
661 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
664 #ifdef EIGEN_TRANSFORM_PLUGIN
665 #include EIGEN_TRANSFORM_PLUGIN
669 #ifndef EIGEN_PARSED_BY_DOXYGEN
670 static EIGEN_STRONG_INLINE
void check_template_params()
672 EIGEN_STATIC_ASSERT((Options & (
DontAlign|
RowMajor)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)
718 #ifdef EIGEN_QT_SUPPORT
723 template<
typename Scalar,
int Dim,
int Mode,
int Options>
726 check_template_params();
734 template<
typename Scalar,
int Dim,
int Mode,
int Options>
737 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
739 m_matrix << other.m11(), other.m21(), other.dx(),
740 other.m12(), other.m22(), other.dy();
742 m_matrix << other.m11(), other.m21(), other.dx(),
743 other.m12(), other.m22(), other.dy(),
754 template<
typename Scalar,
int Dim,
int Mode,
int Options>
757 check_template_params();
758 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
759 return QMatrix(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
760 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
761 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
768 template<
typename Scalar,
int Dim,
int Mode,
int Options>
771 check_template_params();
779 template<
typename Scalar,
int Dim,
int Mode,
int Options>
782 check_template_params();
783 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
785 m_matrix << other.m11(), other.m21(), other.dx(),
786 other.m12(), other.m22(), other.dy();
788 m_matrix << other.m11(), other.m21(), other.dx(),
789 other.m12(), other.m22(), other.dy(),
790 other.m13(), other.m23(), other.m33();
798 template<
typename Scalar,
int Dim,
int Mode,
int Options>
801 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
803 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
804 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
805 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
807 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0),
808 m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1),
809 m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2));
821 template<
typename Scalar,
int Dim,
int Mode,
int Options>
822 template<
typename OtherDerived>
826 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
827 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
828 linearExt().noalias() = (linearExt() * other.
asDiagonal());
836 template<
typename Scalar,
int Dim,
int Mode,
int Options>
839 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
848 template<
typename Scalar,
int Dim,
int Mode,
int Options>
849 template<
typename OtherDerived>
853 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
854 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
855 m_matrix.template block<Dim,HDim>(0,0).noalias() = (other.
asDiagonal() * m_matrix.template block<Dim,HDim>(0,0));
863 template<
typename Scalar,
int Dim,
int Mode,
int Options>
866 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
867 m_matrix.template topRows<Dim>() *= s;
875 template<
typename Scalar,
int Dim,
int Mode,
int Options>
876 template<
typename OtherDerived>
880 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
881 translationExt() += linearExt() * other;
889 template<
typename Scalar,
int Dim,
int Mode,
int Options>
890 template<
typename OtherDerived>
894 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
896 affine() += other * m_matrix.
row(Dim);
898 translation() += other;
919 template<
typename Scalar,
int Dim,
int Mode,
int Options>
920 template<
typename RotationType>
924 linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
935 template<
typename Scalar,
int Dim,
int Mode,
int Options>
936 template<
typename RotationType>
940 m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
941 * m_matrix.template block<Dim,HDim>(0,0);
950 template<
typename Scalar,
int Dim,
int Mode,
int Options>
954 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
955 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
956 VectorType tmp = linear().col(0)*sy + linear().col(1);
957 linear() << linear().col(0) + linear().col(1)*sx, tmp;
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 m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
980 template<
typename Scalar,
int Dim,
int Mode,
int Options>
984 translation() = t.vector();
989 template<
typename Scalar,
int Dim,
int Mode,
int Options>
992 Transform res = *
this;
993 res.translate(t.vector());
997 template<
typename Scalar,
int Dim,
int Mode,
int Options>
998 inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(
const UniformScaling<Scalar>& s)
1001 linear().diagonal().fill(s.factor());
1006 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1007 template<
typename Derived>
1008 inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(
const RotationBase<Derived,Dim>& r)
1010 linear() = internal::toRotationMatrix<Scalar,Dim>(r);
1011 translation().setZero();
1016 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1017 template<
typename Derived>
1020 Transform res = *
this;
1021 res.rotate(r.derived());
1036 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1037 const typename Transform<Scalar,Dim,Mode,Options>::LinearMatrixType
1040 LinearMatrixType result;
1041 computeRotationScaling(&result, (LinearMatrixType*)0);
1057 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1058 template<
typename RotationMatrixType,
typename ScalingMatrixType>
1063 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1065 sv.coeffRef(0) *= x;
1066 if(scaling) scaling->lazyAssign(svd.
matrixV() * sv.asDiagonal() * svd.
matrixV().adjoint());
1069 LinearMatrixType m(svd.
matrixU());
1071 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1086 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1087 template<
typename ScalingMatrixType,
typename RotationMatrixType>
1092 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1094 sv.coeffRef(0) *= x;
1095 if(scaling) scaling->lazyAssign(svd.
matrixU() * sv.asDiagonal() * svd.
matrixU().adjoint());
1098 LinearMatrixType m(svd.
matrixU());
1100 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1107 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1108 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
1113 linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1115 translation() = position;
1123 struct transform_make_affine
1125 template<
typename MatrixType>
1126 static void run(MatrixType &mat)
1128 static const int Dim = MatrixType::ColsAtCompileTime-1;
1129 mat.template block<1,Dim>(Dim,0).setZero();
1130 mat.coeffRef(Dim,Dim) =
typename MatrixType::Scalar(1);
1137 template<
typename MatrixType>
static void run(MatrixType &) { }
1141 template<
typename TransformType,
int Mode=TransformType::Mode>
1142 struct projective_transform_inverse
1144 static inline void run(
const TransformType&, TransformType&)
1148 template<
typename TransformType>
1149 struct projective_transform_inverse<TransformType,
Projective>
1151 static inline void run(
const TransformType& m, TransformType& res)
1153 res.matrix() = m.matrix().inverse();
1180 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1181 Transform<Scalar,Dim,Mode,Options>
1187 internal::projective_transform_inverse<Transform>::run(*
this, res);
1193 res.matrix().template topLeftCorner<Dim,Dim>() = linear().transpose();
1197 res.matrix().template topLeftCorner<Dim,Dim>() = linear().inverse();
1201 eigen_assert(
false &&
"Invalid transform traits in Transform::Inverse");
1204 res.matrix().template topRightCorner<Dim,1>()
1205 = - res.matrix().template topLeftCorner<Dim,Dim>() * translation();
1217 template<
typename TransformType>
struct transform_take_affine_part {
1218 typedef typename TransformType::MatrixType MatrixType;
1219 typedef typename TransformType::AffinePart AffinePart;
1220 typedef typename TransformType::ConstAffinePart ConstAffinePart;
1221 static inline AffinePart run(MatrixType& m)
1222 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1223 static inline ConstAffinePart run(
const MatrixType& m)
1224 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1227 template<
typename Scalar,
int Dim,
int Options>
1228 struct transform_take_affine_part<Transform<Scalar,Dim,
AffineCompact, Options> > {
1229 typedef typename Transform<Scalar,Dim,AffineCompact,Options>::MatrixType MatrixType;
1230 static inline MatrixType& run(MatrixType& m) {
return m; }
1231 static inline const MatrixType& run(
const MatrixType& m) {
return m; }
1238 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1239 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1241 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1243 transform->linear() = other;
1244 transform->translation().setZero();
1245 transform->makeAffine();
1249 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1250 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1252 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1254 transform->affine() = other;
1255 transform->makeAffine();
1259 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1260 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1262 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1263 { transform->matrix() = other; }
1266 template<
typename Other,
int Options,
int Dim,
int HDim>
1267 struct transform_construct_from_matrix<Other,
AffineCompact,Options,Dim,HDim, HDim,HDim>
1269 static inline void run(Transform<typename Other::Scalar,Dim,AffineCompact,Options> *transform,
const Other& other)
1270 { transform->matrix() = other.template block<Dim,HDim>(0,0); }
1277 template<
int LhsMode,
int RhsMode>
1278 struct transform_product_result
1290 template<
typename TransformType,
typename MatrixType >
1291 struct transform_right_product_impl< TransformType, MatrixType, 0 >
1293 typedef typename MatrixType::PlainObject ResultType;
1295 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1297 return T.matrix() * other;
1301 template<
typename TransformType,
typename MatrixType >
1302 struct transform_right_product_impl< TransformType, MatrixType, 1 >
1305 Dim = TransformType::Dim,
1306 HDim = TransformType::HDim,
1307 OtherRows = MatrixType::RowsAtCompileTime,
1308 OtherCols = MatrixType::ColsAtCompileTime
1311 typedef typename MatrixType::PlainObject ResultType;
1313 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1315 EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1317 typedef Block<ResultType, Dim, OtherCols, int(MatrixType::RowsAtCompileTime)==Dim> TopLeftLhs;
1319 ResultType res(other.rows(),other.cols());
1320 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1321 res.row(OtherRows-1) = other.row(OtherRows-1);
1327 template<
typename TransformType,
typename MatrixType >
1328 struct transform_right_product_impl< TransformType, MatrixType, 2 >
1331 Dim = TransformType::Dim,
1332 HDim = TransformType::HDim,
1333 OtherRows = MatrixType::RowsAtCompileTime,
1334 OtherCols = MatrixType::ColsAtCompileTime
1337 typedef typename MatrixType::PlainObject ResultType;
1339 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1341 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1343 typedef Block<ResultType, Dim, OtherCols, true> TopLeftLhs;
1344 ResultType res(Replicate<typename TransformType::ConstTranslationPart, 1, OtherCols>(T.translation(),1,other.cols()));
1345 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1356 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1357 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1359 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1360 typedef typename TransformType::MatrixType MatrixType;
1361 typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1362 static ResultType run(
const Other& other,
const TransformType& tr)
1363 {
return ResultType(other * tr.matrix()); }
1367 template<
typename Other,
int Options,
int Dim,
int HDim>
1368 struct transform_left_product_impl<Other,
AffineCompact,Options,Dim,HDim, HDim,HDim>
1370 typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1371 typedef typename TransformType::MatrixType MatrixType;
1372 typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1373 static ResultType run(
const Other& other,
const TransformType& tr)
1376 res.matrix().noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1377 res.matrix().col(Dim) += other.col(Dim);
1383 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1384 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1386 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1387 typedef typename TransformType::MatrixType MatrixType;
1388 typedef TransformType ResultType;
1389 static ResultType run(
const Other& other,
const TransformType& tr)
1392 res.affine().noalias() = other * tr.matrix();
1393 res.matrix().row(Dim) = tr.matrix().row(Dim);
1399 template<
typename Other,
int Options,
int Dim,
int HDim>
1400 struct transform_left_product_impl<Other,
AffineCompact,Options,Dim,HDim, Dim,HDim>
1402 typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1403 typedef typename TransformType::MatrixType MatrixType;
1404 typedef TransformType ResultType;
1405 static ResultType run(
const Other& other,
const TransformType& tr)
1408 res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1409 res.translation() += other.col(Dim);
1415 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1416 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1418 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1419 typedef typename TransformType::MatrixType MatrixType;
1420 typedef TransformType ResultType;
1421 static ResultType run(
const Other& other,
const TransformType& tr)
1425 res.matrix().row(Dim) = tr.matrix().row(Dim);
1426 res.matrix().template topRows<Dim>().noalias()
1427 = other * tr.matrix().template topRows<Dim>();
1436 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1437 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >
1439 enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
1440 typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1441 typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1442 typedef Transform<Scalar,Dim,ResultMode,LhsOptions> ResultType;
1443 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1446 res.linear() = lhs.linear() * rhs.linear();
1447 res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1453 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1454 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >
1456 typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1457 typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1458 typedef Transform<Scalar,Dim,Projective> ResultType;
1459 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1461 return ResultType( lhs.matrix() * rhs.matrix() );
1465 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1466 struct transform_transform_product_impl<Transform<Scalar,Dim,
AffineCompact,LhsOptions>,Transform<Scalar,Dim,
Projective,RhsOptions>,true >
1468 typedef Transform<Scalar,Dim,AffineCompact,LhsOptions> Lhs;
1469 typedef Transform<Scalar,Dim,Projective,RhsOptions> Rhs;
1470 typedef Transform<Scalar,Dim,Projective> ResultType;
1471 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1474 res.matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1475 res.matrix().row(Dim) = rhs.matrix().row(Dim);
1480 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1481 struct transform_transform_product_impl<Transform<Scalar,Dim,
Projective,LhsOptions>,Transform<Scalar,Dim,
AffineCompact,RhsOptions>,true >
1483 typedef Transform<Scalar,Dim,Projective,LhsOptions> Lhs;
1484 typedef Transform<Scalar,Dim,AffineCompact,RhsOptions> Rhs;
1485 typedef Transform<Scalar,Dim,Projective> ResultType;
1486 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1488 ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1489 res.matrix().col(Dim) += lhs.matrix().col(Dim);
1498 #endif // EIGEN_TRANSFORM_H
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:103
Definition: Constants.h:383
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:690
Transform< double, 2, AffineCompact > AffineCompact2d
Definition: Transform.h:701
const SingularValuesType & singularValues() const
Definition: SVDBase.h:111
Definition: Constants.h:447
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:107
RowXpr row(Index i)
Definition: DenseBase.h:797
Derived & setIdentity()
Definition: CwiseNullaryOp.h:779
Derived & derived()
Definition: EigenBase.h:44
const unsigned int RowMajorBit
Definition: Constants.h:61
Definition: Constants.h:454
Definition: EigenBase.h:28
Represents a translation transformation.
Definition: ForwardDeclarations.h:268
Transform< double, 2, Projective > Projective2d
Definition: Transform.h:710
Transform< float, 2, AffineCompact > AffineCompact2f
Definition: Transform.h:697
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:520
Definition: Constants.h:452
Definition: Constants.h:322
TransformTraits
Definition: Constants.h:445
Transform< double, 3, Affine > Affine3d
Definition: Transform.h:694
const MatrixVType & matrixV() const
Definition: SVDBase.h:99
Transform< double, 3, Isometry > Isometry3d
Definition: Transform.h:685
const MatrixUType & matrixU() const
Definition: SVDBase.h:83
Transform< float, 2, Projective > Projective2f
Definition: Transform.h:706
Transform< float, 3, Projective > Projective3f
Definition: Transform.h:708
Definition: Eigen_Colamd.h:54
Transform< float, 3, AffineCompact > AffineCompact3f
Definition: Transform.h:699
Transform< double, 3, AffineCompact > AffineCompact3d
Definition: Transform.h:703
Transform< float, 2, Affine > Affine2f
Definition: Transform.h:688
Definition: Constants.h:326
Transform< float, 3, Isometry > Isometry3f
Definition: Transform.h:681
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:104
Transform< double, 2, Affine > Affine2d
Definition: Transform.h:692
Transform< double, 2, Isometry > Isometry2d
Definition: Transform.h:683
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: ForwardDeclarations.h:255
Definition: Constants.h:387
const DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:278
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
const Scalar * data() const
Definition: PlainObjectBase.h:228
Definition: Constants.h:450
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Transform< float, 2, Isometry > Isometry2f
Definition: Transform.h:679
Transform< double, 3, Projective > Projective3d
Definition: Transform.h:712