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;
193 template<
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
207 typedef Eigen::Index StorageIndex;
220 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
224 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
237 enum { TransformTimeDiagonalMode = ((Mode==int(
Isometry))?
Affine:
int(Mode)) };
251 check_template_params();
252 internal::transform_make_affine<(int(Mode)==Affine) ? Affine : AffineCompact>::run(m_matrix);
257 check_template_params();
258 m_matrix = other.m_matrix;
261 inline explicit Transform(
const TranslationType& t)
263 check_template_params();
266 inline explicit Transform(
const UniformScaling<Scalar>& s)
268 check_template_params();
271 template<
typename Derived>
272 inline explicit Transform(
const RotationBase<Derived, Dim>& r)
274 check_template_params();
278 inline Transform& operator=(
const Transform& other)
279 { m_matrix = other.m_matrix;
return *
this; }
281 typedef internal::transform_take_affine_part<Transform> take_affine_part;
284 template<
typename OtherDerived>
287 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
288 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
290 check_template_params();
291 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
295 template<
typename OtherDerived>
298 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
299 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
301 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
305 template<
int OtherOptions>
308 check_template_params();
310 m_matrix = other.matrix();
313 template<
int OtherMode,
int OtherOptions>
314 inline Transform(
const Transform<Scalar,Dim,OtherMode,OtherOptions>& other)
316 check_template_params();
320 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
325 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
327 enum { ModeIsAffineCompact = Mode == int(AffineCompact),
328 OtherModeIsAffineCompact = OtherMode == int(AffineCompact)
331 if(ModeIsAffineCompact == OtherModeIsAffineCompact)
336 m_matrix.template block<Dim,Dim+1>(0,0) = other.matrix().template block<Dim,Dim+1>(0,0);
339 else if(OtherModeIsAffineCompact)
341 typedef typename Transform<Scalar,Dim,OtherMode,OtherOptions>::MatrixType OtherMatrixType;
342 internal::transform_construct_from_matrix<OtherMatrixType,Mode,Options,Dim,HDim>::run(
this, other.matrix());
349 linear() = other.linear();
350 translation() = other.translation();
354 template<
typename OtherDerived>
355 Transform(
const ReturnByValue<OtherDerived>& other)
357 check_template_params();
361 template<
typename OtherDerived>
362 Transform& operator=(
const ReturnByValue<OtherDerived>& other)
368 #ifdef EIGEN_QT_SUPPORT
369 inline Transform(
const QMatrix& other);
370 inline Transform& operator=(
const QMatrix& other);
371 inline QMatrix toQMatrix(
void)
const;
372 inline Transform(
const QTransform& other);
373 inline Transform& operator=(
const QTransform& other);
374 inline QTransform toQTransform(
void)
const;
377 Index rows()
const {
return int(Mode)==int(
Projective) ? m_matrix.cols() : (m_matrix.cols()-1); }
378 Index cols()
const {
return m_matrix.cols(); }
382 inline Scalar operator() (Index row, Index col)
const {
return m_matrix(row,col); }
385 inline Scalar& operator() (Index row, Index col) {
return m_matrix(row,col); }
388 inline const MatrixType&
matrix()
const {
return m_matrix; }
390 inline MatrixType&
matrix() {
return m_matrix; }
393 inline ConstLinearPart
linear()
const {
return ConstLinearPart(m_matrix,0,0); }
395 inline LinearPart
linear() {
return LinearPart(m_matrix,0,0); }
398 inline ConstAffinePart
affine()
const {
return take_affine_part::run(m_matrix); }
400 inline AffinePart
affine() {
return take_affine_part::run(m_matrix); }
419 template<
typename OtherDerived>
420 EIGEN_STRONG_INLINE
const typename internal::transform_right_product_impl<Transform, OtherDerived>::ResultType
422 {
return internal::transform_right_product_impl<Transform, OtherDerived>::run(*
this,other.
derived()); }
431 template<
typename OtherDerived>
friend
432 inline const typename internal::transform_left_product_impl<OtherDerived,Mode,Options,_Dim,_Dim+1>::ResultType
434 {
return internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim,HDim>::run(a.
derived(),b); }
442 template<
typename DiagonalDerived>
443 inline const TransformTimeDiagonalReturnType
444 operator * (
const DiagonalBase<DiagonalDerived> &b)
const
446 TransformTimeDiagonalReturnType res(*
this);
457 template<
typename DiagonalDerived>
458 friend inline TransformTimeDiagonalReturnType
459 operator * (
const DiagonalBase<DiagonalDerived> &a,
const Transform &b)
461 TransformTimeDiagonalReturnType res;
462 res.
linear().noalias() = a*b.linear();
465 res.
matrix().
row(Dim) = b.matrix().row(Dim);
469 template<
typename OtherDerived>
475 return internal::transform_transform_product_impl<Transform,Transform>::run(*
this,other);
487 template<
int OtherMode,
int OtherOptions>
struct icc_11_workaround
489 typedef internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> > ProductType;
490 typedef typename ProductType::ResultType ResultType;
495 template<
int OtherMode,
int OtherOptions>
496 inline typename icc_11_workaround<OtherMode,OtherOptions>::ResultType
497 operator * (
const Transform<Scalar,Dim,OtherMode,OtherOptions>& other)
const
499 typedef typename icc_11_workaround<OtherMode,OtherOptions>::ProductType ProductType;
500 return ProductType::run(*
this,other);
504 template<
int OtherMode,
int OtherOptions>
505 inline typename internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::ResultType
508 return internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::run(*
this,other);
521 return Transform(MatrixType::Identity());
524 template<
typename OtherDerived>
527 template<
typename OtherDerived>
530 inline Transform& scale(
const Scalar& s);
531 inline Transform& prescale(
const Scalar& s);
533 template<
typename OtherDerived>
536 template<
typename OtherDerived>
539 template<
typename RotationType>
540 inline Transform& rotate(
const RotationType& rotation);
542 template<
typename RotationType>
543 inline Transform& prerotate(
const RotationType& rotation);
545 Transform& shear(
const Scalar& sx,
const Scalar& sy);
546 Transform& preshear(
const Scalar& sx,
const Scalar& sy);
548 inline Transform& operator=(
const TranslationType& t);
549 inline Transform& operator*=(
const TranslationType& t) {
return translate(t.vector()); }
550 inline Transform operator*(
const TranslationType& t)
const;
552 inline Transform& operator=(
const UniformScaling<Scalar>& t);
553 inline Transform& operator*=(
const UniformScaling<Scalar>& s) {
return scale(s.factor()); }
554 inline TransformTimeDiagonalReturnType operator*(
const UniformScaling<Scalar>& s)
const
556 TransformTimeDiagonalReturnType res = *
this;
557 res.scale(s.factor());
561 inline Transform& operator*=(
const DiagonalMatrix<Scalar,Dim>& s) { linear() *= s;
return *
this; }
563 template<
typename Derived>
564 inline Transform& operator=(
const RotationBase<Derived,Dim>& r);
565 template<
typename Derived>
566 inline Transform& operator*=(
const RotationBase<Derived,Dim>& r) {
return rotate(r.toRotationMatrix()); }
567 template<
typename Derived>
568 inline Transform operator*(
const RotationBase<Derived,Dim>& r)
const;
570 const LinearMatrixType rotation()
const;
571 template<
typename RotationMatrixType,
typename ScalingMatrixType>
572 void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling)
const;
573 template<
typename ScalingMatrixType,
typename RotationMatrixType>
574 void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation)
const;
576 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
577 Transform& fromPositionOrientationScale(
const MatrixBase<PositionDerived> &position,
578 const OrientationType& orientation,
const MatrixBase<ScaleDerived> &scale);
583 const Scalar*
data()
const {
return m_matrix.
data(); }
592 template<
typename NewScalarType>
593 inline typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type
cast()
const
594 {
return typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type(*
this); }
597 template<
typename OtherScalarType>
600 check_template_params();
601 m_matrix = other.matrix().template cast<Scalar>();
609 {
return m_matrix.
isApprox(other.m_matrix, prec); }
615 internal::transform_make_affine<int(Mode)>::run(m_matrix);
623 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
628 inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,Dim> linearExt()
const
629 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
635 inline Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt()
636 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
641 inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt()
const
642 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
645 #ifdef EIGEN_TRANSFORM_PLUGIN
646 #include EIGEN_TRANSFORM_PLUGIN
650 #ifndef EIGEN_PARSED_BY_DOXYGEN
651 static EIGEN_STRONG_INLINE
void check_template_params()
653 EIGEN_STATIC_ASSERT((Options & (
DontAlign|
RowMajor)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)
699 #ifdef EIGEN_QT_SUPPORT
704 template<
typename Scalar,
int Dim,
int Mode,
int Options>
707 check_template_params();
715 template<
typename Scalar,
int Dim,
int Mode,
int Options>
718 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
720 m_matrix << other.m11(), other.m21(), other.dx(),
721 other.m12(), other.m22(), other.dy();
723 m_matrix << other.m11(), other.m21(), other.dx(),
724 other.m12(), other.m22(), other.dy(),
735 template<
typename Scalar,
int Dim,
int Mode,
int Options>
738 check_template_params();
739 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
740 return QMatrix(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
741 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
742 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
749 template<
typename Scalar,
int Dim,
int Mode,
int Options>
752 check_template_params();
760 template<
typename Scalar,
int Dim,
int Mode,
int Options>
763 check_template_params();
764 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
766 m_matrix << other.m11(), other.m21(), other.dx(),
767 other.m12(), other.m22(), other.dy();
769 m_matrix << other.m11(), other.m21(), other.dx(),
770 other.m12(), other.m22(), other.dy(),
771 other.m13(), other.m23(), other.m33();
779 template<
typename Scalar,
int Dim,
int Mode,
int Options>
782 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
784 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
785 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
786 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
788 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0),
789 m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1),
790 m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2));
802 template<
typename Scalar,
int Dim,
int Mode,
int Options>
803 template<
typename OtherDerived>
807 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
808 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
809 linearExt().noalias() = (linearExt() * other.
asDiagonal());
817 template<
typename Scalar,
int Dim,
int Mode,
int Options>
820 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
829 template<
typename Scalar,
int Dim,
int Mode,
int Options>
830 template<
typename OtherDerived>
834 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
835 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
836 m_matrix.template block<Dim,HDim>(0,0).noalias() = (other.
asDiagonal() * m_matrix.template block<Dim,HDim>(0,0));
844 template<
typename Scalar,
int Dim,
int Mode,
int Options>
847 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
848 m_matrix.template topRows<Dim>() *= s;
856 template<
typename Scalar,
int Dim,
int Mode,
int Options>
857 template<
typename OtherDerived>
861 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
862 translationExt() += linearExt() * other;
870 template<
typename Scalar,
int Dim,
int Mode,
int Options>
871 template<
typename OtherDerived>
875 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
877 affine() += other * m_matrix.
row(Dim);
879 translation() += other;
900 template<
typename Scalar,
int Dim,
int Mode,
int Options>
901 template<
typename RotationType>
905 linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
916 template<
typename Scalar,
int Dim,
int Mode,
int Options>
917 template<
typename RotationType>
921 m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
922 * m_matrix.template block<Dim,HDim>(0,0);
931 template<
typename Scalar,
int Dim,
int Mode,
int Options>
935 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
936 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
937 VectorType tmp = linear().col(0)*sy + linear().col(1);
938 linear() << linear().col(0) + linear().col(1)*sx, tmp;
947 template<
typename Scalar,
int Dim,
int Mode,
int Options>
951 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
952 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
953 m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
961 template<
typename Scalar,
int Dim,
int Mode,
int Options>
965 translation() = t.vector();
970 template<
typename Scalar,
int Dim,
int Mode,
int Options>
973 Transform res = *
this;
974 res.translate(t.vector());
978 template<
typename Scalar,
int Dim,
int Mode,
int Options>
979 inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(
const UniformScaling<Scalar>& s)
982 linear().diagonal().fill(s.factor());
987 template<
typename Scalar,
int Dim,
int Mode,
int Options>
988 template<
typename Derived>
989 inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(
const RotationBase<Derived,Dim>& r)
991 linear() = internal::toRotationMatrix<Scalar,Dim>(r);
992 translation().setZero();
997 template<
typename Scalar,
int Dim,
int Mode,
int Options>
998 template<
typename Derived>
1001 Transform res = *
this;
1002 res.rotate(r.derived());
1017 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1018 const typename Transform<Scalar,Dim,Mode,Options>::LinearMatrixType
1021 LinearMatrixType result;
1022 computeRotationScaling(&result, (LinearMatrixType*)0);
1038 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1039 template<
typename RotationMatrixType,
typename ScalingMatrixType>
1044 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1046 sv.coeffRef(0) *= x;
1047 if(scaling) scaling->lazyAssign(svd.
matrixV() * sv.asDiagonal() * svd.
matrixV().adjoint());
1050 LinearMatrixType m(svd.
matrixU());
1052 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1067 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1068 template<
typename ScalingMatrixType,
typename RotationMatrixType>
1073 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1075 sv.coeffRef(0) *= x;
1076 if(scaling) scaling->lazyAssign(svd.
matrixU() * sv.asDiagonal() * svd.
matrixU().adjoint());
1079 LinearMatrixType m(svd.
matrixU());
1081 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1088 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1089 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
1094 linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1096 translation() = position;
1104 struct transform_make_affine
1106 template<
typename MatrixType>
1107 static void run(MatrixType &mat)
1109 static const int Dim = MatrixType::ColsAtCompileTime-1;
1110 mat.template block<1,Dim>(Dim,0).setZero();
1111 mat.coeffRef(Dim,Dim) =
typename MatrixType::Scalar(1);
1118 template<
typename MatrixType>
static void run(MatrixType &) { }
1122 template<
typename TransformType,
int Mode=TransformType::Mode>
1123 struct projective_transform_inverse
1125 static inline void run(
const TransformType&, TransformType&)
1129 template<
typename TransformType>
1130 struct projective_transform_inverse<TransformType,
Projective>
1132 static inline void run(
const TransformType& m, TransformType& res)
1134 res.matrix() = m.matrix().inverse();
1161 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1162 Transform<Scalar,Dim,Mode,Options>
1168 internal::projective_transform_inverse<Transform>::run(*
this, res);
1174 res.matrix().template topLeftCorner<Dim,Dim>() = linear().transpose();
1178 res.matrix().template topLeftCorner<Dim,Dim>() = linear().inverse();
1182 eigen_assert(
false &&
"Invalid transform traits in Transform::Inverse");
1185 res.matrix().template topRightCorner<Dim,1>()
1186 = - res.matrix().template topLeftCorner<Dim,Dim>() * translation();
1198 template<
typename TransformType>
struct transform_take_affine_part {
1199 typedef typename TransformType::MatrixType MatrixType;
1200 typedef typename TransformType::AffinePart AffinePart;
1201 typedef typename TransformType::ConstAffinePart ConstAffinePart;
1202 static inline AffinePart run(MatrixType& m)
1203 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1204 static inline ConstAffinePart run(
const MatrixType& m)
1205 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1208 template<
typename Scalar,
int Dim,
int Options>
1209 struct transform_take_affine_part<Transform<Scalar,Dim,
AffineCompact, Options> > {
1210 typedef typename Transform<Scalar,Dim,AffineCompact,Options>::MatrixType MatrixType;
1211 static inline MatrixType& run(MatrixType& m) {
return m; }
1212 static inline const MatrixType& run(
const MatrixType& m) {
return m; }
1219 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1220 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1222 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1224 transform->linear() = other;
1225 transform->translation().setZero();
1226 transform->makeAffine();
1230 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1231 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1233 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1235 transform->affine() = other;
1236 transform->makeAffine();
1240 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1241 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1243 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1244 { transform->matrix() = other; }
1247 template<
typename Other,
int Options,
int Dim,
int HDim>
1248 struct transform_construct_from_matrix<Other,
AffineCompact,Options,Dim,HDim, HDim,HDim>
1250 static inline void run(Transform<typename Other::Scalar,Dim,AffineCompact,Options> *transform,
const Other& other)
1251 { transform->matrix() = other.template block<Dim,HDim>(0,0); }
1258 template<
int LhsMode,
int RhsMode>
1259 struct transform_product_result
1271 template<
typename TransformType,
typename MatrixType >
1272 struct transform_right_product_impl< TransformType, MatrixType, 0 >
1274 typedef typename MatrixType::PlainObject ResultType;
1276 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1278 return T.matrix() * other;
1282 template<
typename TransformType,
typename MatrixType >
1283 struct transform_right_product_impl< TransformType, MatrixType, 1 >
1286 Dim = TransformType::Dim,
1287 HDim = TransformType::HDim,
1288 OtherRows = MatrixType::RowsAtCompileTime,
1289 OtherCols = MatrixType::ColsAtCompileTime
1292 typedef typename MatrixType::PlainObject ResultType;
1294 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1296 EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1298 typedef Block<ResultType, Dim, OtherCols, int(MatrixType::RowsAtCompileTime)==Dim> TopLeftLhs;
1300 ResultType res(other.rows(),other.cols());
1301 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1302 res.row(OtherRows-1) = other.row(OtherRows-1);
1308 template<
typename TransformType,
typename MatrixType >
1309 struct transform_right_product_impl< TransformType, MatrixType, 2 >
1312 Dim = TransformType::Dim,
1313 HDim = TransformType::HDim,
1314 OtherRows = MatrixType::RowsAtCompileTime,
1315 OtherCols = MatrixType::ColsAtCompileTime
1318 typedef typename MatrixType::PlainObject ResultType;
1320 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1322 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1324 typedef Block<ResultType, Dim, OtherCols, true> TopLeftLhs;
1325 ResultType res(Replicate<typename TransformType::ConstTranslationPart, 1, OtherCols>(T.translation(),1,other.cols()));
1326 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1337 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1338 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1340 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1341 typedef typename TransformType::MatrixType MatrixType;
1342 typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1343 static ResultType run(
const Other& other,
const TransformType& tr)
1344 {
return ResultType(other * tr.matrix()); }
1348 template<
typename Other,
int Options,
int Dim,
int HDim>
1349 struct transform_left_product_impl<Other,
AffineCompact,Options,Dim,HDim, HDim,HDim>
1351 typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1352 typedef typename TransformType::MatrixType MatrixType;
1353 typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1354 static ResultType run(
const Other& other,
const TransformType& tr)
1357 res.matrix().noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1358 res.matrix().col(Dim) += other.col(Dim);
1364 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1365 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1367 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1368 typedef typename TransformType::MatrixType MatrixType;
1369 typedef TransformType ResultType;
1370 static ResultType run(
const Other& other,
const TransformType& tr)
1373 res.affine().noalias() = other * tr.matrix();
1374 res.matrix().row(Dim) = tr.matrix().row(Dim);
1380 template<
typename Other,
int Options,
int Dim,
int HDim>
1381 struct transform_left_product_impl<Other,
AffineCompact,Options,Dim,HDim, Dim,HDim>
1383 typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1384 typedef typename TransformType::MatrixType MatrixType;
1385 typedef TransformType ResultType;
1386 static ResultType run(
const Other& other,
const TransformType& tr)
1389 res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1390 res.translation() += other.col(Dim);
1396 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1397 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1399 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1400 typedef typename TransformType::MatrixType MatrixType;
1401 typedef TransformType ResultType;
1402 static ResultType run(
const Other& other,
const TransformType& tr)
1406 res.matrix().row(Dim) = tr.matrix().row(Dim);
1407 res.matrix().template topRows<Dim>().noalias()
1408 = other * tr.matrix().template topRows<Dim>();
1417 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1418 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >
1420 enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
1421 typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1422 typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1423 typedef Transform<Scalar,Dim,ResultMode,LhsOptions> ResultType;
1424 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1427 res.linear() = lhs.linear() * rhs.linear();
1428 res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1434 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1435 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >
1437 typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1438 typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1439 typedef Transform<Scalar,Dim,Projective> ResultType;
1440 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1442 return ResultType( lhs.matrix() * rhs.matrix() );
1446 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1447 struct transform_transform_product_impl<Transform<Scalar,Dim,
AffineCompact,LhsOptions>,Transform<Scalar,Dim,
Projective,RhsOptions>,true >
1449 typedef Transform<Scalar,Dim,AffineCompact,LhsOptions> Lhs;
1450 typedef Transform<Scalar,Dim,Projective,RhsOptions> Rhs;
1451 typedef Transform<Scalar,Dim,Projective> ResultType;
1452 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1455 res.matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1456 res.matrix().row(Dim) = rhs.matrix().row(Dim);
1461 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1462 struct transform_transform_product_impl<Transform<Scalar,Dim,
Projective,LhsOptions>,Transform<Scalar,Dim,
AffineCompact,RhsOptions>,true >
1464 typedef Transform<Scalar,Dim,Projective,LhsOptions> Lhs;
1465 typedef Transform<Scalar,Dim,AffineCompact,RhsOptions> Rhs;
1466 typedef Transform<Scalar,Dim,Projective> ResultType;
1467 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1469 ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1470 res.matrix().col(Dim) += lhs.matrix().col(Dim);
1479 #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:375
Definition: Constants.h:314
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:671
Transform< double, 2, AffineCompact > AffineCompact2d
Definition: Transform.h:682
const SingularValuesType & singularValues() const
Definition: SVDBase.h:111
Definition: Constants.h:439
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:53
Definition: Constants.h:318
Definition: Constants.h:446
Definition: EigenBase.h:28
Represents a translation transformation.
Definition: ForwardDeclarations.h:267
Transform< double, 2, Projective > Projective2d
Definition: Transform.h:691
Transform< float, 2, AffineCompact > AffineCompact2f
Definition: Transform.h:678
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:520
Definition: Constants.h:444
TransformTraits
Definition: Constants.h:437
Transform< double, 3, Affine > Affine3d
Definition: Transform.h:675
const MatrixVType & matrixV() const
Definition: SVDBase.h:99
Transform< double, 3, Isometry > Isometry3d
Definition: Transform.h:666
const MatrixUType & matrixU() const
Definition: SVDBase.h:83
Transform< float, 2, Projective > Projective2f
Definition: Transform.h:687
Transform< float, 3, Projective > Projective3f
Definition: Transform.h:689
Definition: Eigen_Colamd.h:54
Transform< float, 3, AffineCompact > AffineCompact3f
Definition: Transform.h:680
Transform< double, 3, AffineCompact > AffineCompact3d
Definition: Transform.h:684
Transform< float, 2, Affine > Affine2f
Definition: Transform.h:669
Transform< float, 3, Isometry > Isometry3f
Definition: Transform.h:662
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:104
Transform< double, 2, Affine > Affine2d
Definition: Transform.h:673
Transform< double, 2, Isometry > Isometry2d
Definition: Transform.h:664
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: ForwardDeclarations.h:254
Definition: Constants.h:379
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:442
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Transform< float, 2, Isometry > Isometry2f
Definition: Transform.h:660
Transform< double, 3, Projective > Projective3d
Definition: Transform.h:693