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;
175 template<
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
189 typedef DenseIndex Index;
201 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
205 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
218 enum { TransformTimeDiagonalMode = ((Mode==int(
Isometry))?
Affine:
int(Mode)) };
232 check_template_params();
239 check_template_params();
240 m_matrix = other.m_matrix;
243 inline explicit Transform(
const TranslationType& t)
245 check_template_params();
248 inline explicit Transform(
const UniformScaling<Scalar>& s)
250 check_template_params();
253 template<
typename Derived>
256 check_template_params();
261 { m_matrix = other.m_matrix;
return *
this; }
263 typedef internal::transform_take_affine_part<Transform> take_affine_part;
266 template<
typename OtherDerived>
269 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
270 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
272 check_template_params();
273 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
277 template<
typename OtherDerived>
280 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
281 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
283 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
287 template<
int OtherOptions>
290 check_template_params();
292 m_matrix = other.matrix();
295 template<
int OtherMode,
int OtherOptions>
298 check_template_params();
302 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
307 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
313 if(ModeIsAffineCompact == OtherModeIsAffineCompact)
318 m_matrix.template block<Dim,Dim+1>(0,0) = other.matrix().template block<Dim,Dim+1>(0,0);
321 else if(OtherModeIsAffineCompact)
324 internal::transform_construct_from_matrix<OtherMatrixType,Mode,Options,Dim,HDim>::run(
this, other.matrix());
331 linear() = other.linear();
332 translation() = other.translation();
336 template<
typename OtherDerived>
337 Transform(
const ReturnByValue<OtherDerived>& other)
339 check_template_params();
343 template<
typename OtherDerived>
344 Transform& operator=(
const ReturnByValue<OtherDerived>& other)
350 #ifdef EIGEN_QT_SUPPORT 352 inline Transform& operator=(
const QMatrix& other);
353 inline QMatrix toQMatrix(
void)
const;
354 inline Transform(
const QTransform& other);
355 inline Transform& operator=(
const QTransform& other);
356 inline QTransform toQTransform(
void)
const;
361 inline Scalar operator() (Index row, Index col)
const {
return m_matrix(row,col); }
364 inline Scalar& operator() (Index row, Index col) {
return m_matrix(row,col); }
367 inline const MatrixType&
matrix()
const {
return m_matrix; }
369 inline MatrixType&
matrix() {
return m_matrix; }
372 inline ConstLinearPart
linear()
const {
return ConstLinearPart(m_matrix,0,0); }
374 inline LinearPart
linear() {
return LinearPart(m_matrix,0,0); }
377 inline ConstAffinePart
affine()
const {
return take_affine_part::run(m_matrix); }
379 inline AffinePart
affine() {
return take_affine_part::run(m_matrix); }
382 inline ConstTranslationPart
translation()
const {
return ConstTranslationPart(m_matrix,0,Dim); }
384 inline TranslationPart
translation() {
return TranslationPart(m_matrix,0,Dim); }
398 template<
typename OtherDerived>
399 EIGEN_STRONG_INLINE
const typename internal::transform_right_product_impl<Transform, OtherDerived>::ResultType
401 {
return internal::transform_right_product_impl<Transform, OtherDerived>::run(*
this,other.
derived()); }
410 template<
typename OtherDerived>
friend 411 inline const typename internal::transform_left_product_impl<OtherDerived,Mode,Options,_Dim,_Dim+1>::ResultType
413 {
return internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim,HDim>::run(a.
derived(),b); }
421 template<
typename DiagonalDerived>
422 inline const TransformTimeDiagonalReturnType
423 operator * (
const DiagonalBase<DiagonalDerived> &b)
const 425 TransformTimeDiagonalReturnType res(*
this);
436 template<
typename DiagonalDerived>
437 friend inline TransformTimeDiagonalReturnType
438 operator * (
const DiagonalBase<DiagonalDerived> &a,
const Transform &b)
440 TransformTimeDiagonalReturnType res;
441 res.
linear().noalias() = a*b.linear();
444 res.
matrix().
row(Dim) = b.matrix().row(Dim);
448 template<
typename OtherDerived>
454 return internal::transform_transform_product_impl<Transform,Transform>::run(*
this,other);
457 #ifdef __INTEL_COMPILER 466 template<
int OtherMode,
int OtherOptions>
struct icc_11_workaround
468 typedef internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> > ProductType;
469 typedef typename ProductType::ResultType ResultType;
474 template<
int OtherMode,
int OtherOptions>
475 inline typename icc_11_workaround<OtherMode,OtherOptions>::ResultType
478 typedef typename icc_11_workaround<OtherMode,OtherOptions>::ProductType ProductType;
479 return ProductType::run(*
this,other);
483 template<
int OtherMode,
int OtherOptions>
484 inline typename internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::ResultType
487 return internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::run(*
this,other);
500 return Transform(MatrixType::Identity());
503 template<
typename OtherDerived>
506 template<
typename OtherDerived>
509 inline Transform& scale(
const Scalar& s);
510 inline Transform& prescale(
const Scalar& s);
512 template<
typename OtherDerived>
515 template<
typename OtherDerived>
518 template<
typename RotationType>
519 inline Transform& rotate(
const RotationType& rotation);
521 template<
typename RotationType>
522 inline Transform& prerotate(
const RotationType& rotation);
524 Transform& shear(
const Scalar& sx,
const Scalar& sy);
525 Transform& preshear(
const Scalar& sx,
const Scalar& sy);
527 inline Transform& operator=(
const TranslationType& t);
528 inline Transform& operator*=(
const TranslationType& t) {
return translate(t.vector()); }
529 inline Transform operator*(
const TranslationType& t)
const;
531 inline Transform& operator=(
const UniformScaling<Scalar>& t);
532 inline Transform& operator*=(
const UniformScaling<Scalar>& s) {
return scale(s.factor()); }
536 res.scale(s.factor());
542 template<
typename Derived>
544 template<
typename Derived>
546 template<
typename Derived>
549 const LinearMatrixType rotation()
const;
550 template<
typename RotationMatrixType,
typename ScalingMatrixType>
551 void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling)
const;
552 template<
typename ScalingMatrixType,
typename RotationMatrixType>
553 void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation)
const;
555 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
562 const Scalar*
data()
const {
return m_matrix.
data(); }
571 template<
typename NewScalarType>
572 inline typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type
cast()
const 573 {
return typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type(*
this); }
576 template<
typename OtherScalarType>
579 check_template_params();
580 m_matrix = other.matrix().template cast<Scalar>();
588 {
return m_matrix.
isApprox(other.m_matrix, prec); }
596 matrix().template block<1,Dim>(Dim,0).setZero();
597 matrix().coeffRef(Dim,Dim) = Scalar(1);
606 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
612 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
619 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
625 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
628 #ifdef EIGEN_TRANSFORM_PLUGIN 629 #include EIGEN_TRANSFORM_PLUGIN 633 #ifndef EIGEN_PARSED_BY_DOXYGEN 634 static EIGEN_STRONG_INLINE
void check_template_params()
636 EIGEN_STATIC_ASSERT((Options & (
DontAlign|
RowMajor)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)
682 #ifdef EIGEN_QT_SUPPORT 687 template<
typename Scalar,
int Dim,
int Mode,
int Options>
690 check_template_params();
698 template<
typename Scalar,
int Dim,
int Mode,
int Options>
701 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
702 m_matrix << other.m11(), other.m21(), other.dx(),
703 other.m12(), other.m22(), other.dy(),
714 template<
typename Scalar,
int Dim,
int Mode,
int Options>
717 check_template_params();
718 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
719 return QMatrix(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
720 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
721 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
728 template<
typename Scalar,
int Dim,
int Mode,
int Options>
731 check_template_params();
739 template<
typename Scalar,
int Dim,
int Mode,
int Options>
742 check_template_params();
743 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
745 m_matrix << other.m11(), other.m21(), other.dx(),
746 other.m12(), other.m22(), other.dy();
748 m_matrix << other.m11(), other.m21(), other.dx(),
749 other.m12(), other.m22(), other.dy(),
750 other.m13(), other.m23(), other.m33();
758 template<
typename Scalar,
int Dim,
int Mode,
int Options>
761 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
763 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
764 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
765 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
767 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0),
768 m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1),
769 m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2));
781 template<
typename Scalar,
int Dim,
int Mode,
int Options>
782 template<
typename OtherDerived>
786 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
787 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
788 linearExt().noalias() = (linearExt() * other.
asDiagonal());
796 template<
typename Scalar,
int Dim,
int Mode,
int Options>
799 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
808 template<
typename Scalar,
int Dim,
int Mode,
int Options>
809 template<
typename OtherDerived>
813 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
814 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
815 m_matrix.template block<Dim,HDim>(0,0).noalias() = (other.
asDiagonal() * m_matrix.template block<Dim,HDim>(0,0));
823 template<
typename Scalar,
int Dim,
int Mode,
int Options>
826 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
827 m_matrix.template topRows<Dim>() *= s;
835 template<
typename Scalar,
int Dim,
int Mode,
int Options>
836 template<
typename OtherDerived>
840 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
841 translationExt() += linearExt() * other;
849 template<
typename Scalar,
int Dim,
int Mode,
int Options>
850 template<
typename OtherDerived>
854 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
856 affine() += other * m_matrix.
row(Dim);
858 translation() += other;
879 template<
typename Scalar,
int Dim,
int Mode,
int Options>
880 template<
typename RotationType>
884 linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
895 template<
typename Scalar,
int Dim,
int Mode,
int Options>
896 template<
typename RotationType>
900 m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
901 * m_matrix.template block<Dim,HDim>(0,0);
910 template<
typename Scalar,
int Dim,
int Mode,
int Options>
914 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
915 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
916 VectorType tmp = linear().col(0)*sy + linear().col(1);
917 linear() << linear().col(0) + linear().col(1)*sx, tmp;
926 template<
typename Scalar,
int Dim,
int Mode,
int Options>
930 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
931 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
932 m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
940 template<
typename Scalar,
int Dim,
int Mode,
int Options>
944 translation() = t.vector();
949 template<
typename Scalar,
int Dim,
int Mode,
int Options>
953 res.translate(t.vector());
957 template<
typename Scalar,
int Dim,
int Mode,
int Options>
961 linear().diagonal().fill(s.factor());
966 template<
typename Scalar,
int Dim,
int Mode,
int Options>
967 template<
typename Derived>
970 linear() = internal::toRotationMatrix<Scalar,Dim>(r);
971 translation().setZero();
976 template<
typename Scalar,
int Dim,
int Mode,
int Options>
977 template<
typename Derived>
981 res.rotate(r.derived());
996 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1000 LinearMatrixType result;
1001 computeRotationScaling(&result, (LinearMatrixType*)0);
1017 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1018 template<
typename RotationMatrixType,
typename ScalingMatrixType>
1023 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1025 sv.coeffRef(0) *= x;
1026 if(scaling) scaling->lazyAssign(svd.
matrixV() * sv.asDiagonal() * svd.
matrixV().adjoint());
1029 LinearMatrixType m(svd.
matrixU());
1031 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1046 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1047 template<
typename ScalingMatrixType,
typename RotationMatrixType>
1052 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1054 sv.coeffRef(0) *= x;
1055 if(scaling) scaling->lazyAssign(svd.
matrixU() * sv.asDiagonal() * svd.
matrixU().adjoint());
1058 LinearMatrixType m(svd.
matrixU());
1060 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1067 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1068 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
1073 linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1075 translation() = position;
1083 template<
typename TransformType,
int Mode=TransformType::Mode>
1084 struct projective_transform_inverse
1086 static inline void run(
const TransformType&, TransformType&)
1090 template<
typename TransformType>
1091 struct projective_transform_inverse<TransformType, Projective>
1093 static inline void run(
const TransformType& m, TransformType& res)
1095 res.matrix() = m.matrix().inverse();
1122 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1129 internal::projective_transform_inverse<Transform>::run(*
this, res);
1135 res.matrix().template topLeftCorner<Dim,Dim>() = linear().transpose();
1139 res.matrix().template topLeftCorner<Dim,Dim>() = linear().inverse();
1143 eigen_assert(
false &&
"Invalid transform traits in Transform::Inverse");
1146 res.matrix().template topRightCorner<Dim,1>()
1147 = - res.matrix().template topLeftCorner<Dim,Dim>() * translation();
1159 template<
typename TransformType>
struct transform_take_affine_part {
1160 typedef typename TransformType::MatrixType MatrixType;
1161 typedef typename TransformType::AffinePart AffinePart;
1162 typedef typename TransformType::ConstAffinePart ConstAffinePart;
1163 static inline AffinePart run(MatrixType& m)
1164 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1165 static inline ConstAffinePart run(
const MatrixType& m)
1166 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1169 template<
typename Scalar,
int Dim,
int Options>
1170 struct transform_take_affine_part<Transform<Scalar,Dim,AffineCompact, Options> > {
1172 static inline MatrixType& run(MatrixType& m) {
return m; }
1173 static inline const MatrixType& run(
const MatrixType& m) {
return m; }
1180 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1181 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1185 transform->linear() = other;
1186 transform->translation().setZero();
1187 transform->makeAffine();
1191 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1192 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1196 transform->affine() = other;
1197 transform->makeAffine();
1201 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1202 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1205 { transform->matrix() = other; }
1208 template<
typename Other,
int Options,
int Dim,
int HDim>
1209 struct transform_construct_from_matrix<Other, AffineCompact,Options,Dim,HDim, HDim,HDim>
1212 { transform->matrix() = other.template block<Dim,HDim>(0,0); }
1219 template<
int LhsMode,
int RhsMode>
1220 struct transform_product_result
1227 (LhsMode == (int)AffineCompact || RhsMode == (
int)
AffineCompact ) ? AffineCompact :
1232 template<
typename TransformType,
typename MatrixType >
1233 struct transform_right_product_impl< TransformType, MatrixType, 0 >
1235 typedef typename MatrixType::PlainObject ResultType;
1237 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1239 return T.matrix() * other;
1243 template<
typename TransformType,
typename MatrixType >
1244 struct transform_right_product_impl< TransformType, MatrixType, 1 >
1247 Dim = TransformType::Dim,
1248 HDim = TransformType::HDim,
1249 OtherRows = MatrixType::RowsAtCompileTime,
1250 OtherCols = MatrixType::ColsAtCompileTime
1253 typedef typename MatrixType::PlainObject ResultType;
1255 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1257 EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1261 ResultType res(other.rows(),other.cols());
1262 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1263 res.
row(OtherRows-1) = other.
row(OtherRows-1);
1269 template<
typename TransformType,
typename MatrixType >
1270 struct transform_right_product_impl< TransformType, MatrixType, 2 >
1273 Dim = TransformType::Dim,
1274 HDim = TransformType::HDim,
1275 OtherRows = MatrixType::RowsAtCompileTime,
1276 OtherCols = MatrixType::ColsAtCompileTime
1279 typedef typename MatrixType::PlainObject ResultType;
1281 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1283 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1287 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1298 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1299 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1302 typedef typename TransformType::MatrixType MatrixType;
1304 static ResultType run(
const Other& other,
const TransformType& tr)
1305 {
return ResultType(other * tr.matrix()); }
1309 template<
typename Other,
int Options,
int Dim,
int HDim>
1310 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, HDim,HDim>
1313 typedef typename TransformType::MatrixType MatrixType;
1315 static ResultType run(
const Other& other,
const TransformType& tr)
1318 res.
matrix().
noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1319 res.matrix().col(Dim) += other.col(Dim);
1325 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1326 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1329 typedef typename TransformType::MatrixType MatrixType;
1330 typedef TransformType ResultType;
1331 static ResultType run(
const Other& other,
const TransformType& tr)
1334 res.affine().noalias() = other * tr.matrix();
1335 res.matrix().row(Dim) = tr.matrix().row(Dim);
1341 template<
typename Other,
int Options,
int Dim,
int HDim>
1342 struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, Dim,HDim>
1345 typedef typename TransformType::MatrixType MatrixType;
1346 typedef TransformType ResultType;
1347 static ResultType run(
const Other& other,
const TransformType& tr)
1350 res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1351 res.translation() += other.col(Dim);
1357 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1358 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1361 typedef typename TransformType::MatrixType MatrixType;
1362 typedef TransformType ResultType;
1363 static ResultType run(
const Other& other,
const TransformType& tr)
1366 if(Mode!=
int(AffineCompact))
1367 res.matrix().row(Dim) = tr.matrix().row(Dim);
1368 res.matrix().template topRows<Dim>().noalias()
1369 = other * tr.matrix().template topRows<Dim>();
1378 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1379 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >
1381 enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
1385 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1388 res.
linear() = lhs.linear() * rhs.linear();
1389 res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1395 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1396 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >
1401 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1403 return ResultType( lhs.matrix() * rhs.matrix() );
1407 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1408 struct transform_transform_product_impl<Transform<Scalar,Dim,AffineCompact,LhsOptions>,Transform<Scalar,Dim,Projective,RhsOptions>,true >
1413 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1416 res.
matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1417 res.matrix().
row(Dim) = rhs.matrix().row(Dim);
1422 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1423 struct transform_transform_product_impl<Transform<Scalar,Dim,Projective,LhsOptions>,Transform<Scalar,Dim,AffineCompact,RhsOptions>,true >
1428 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1430 ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1431 res.
matrix().
col(Dim) += lhs.matrix().col(Dim);
1440 #endif // EIGEN_TRANSFORM_H Definition: Constants.h:398
RowXpr row(Index i)
Definition: DenseBase.h:750
const MatrixVType & matrixV() const
Definition: JacobiSVD.h:629
Definition: Constants.h:266
Transform< float, 2, Projective > Projective2f
Definition: Transform.h:670
Transform< float, 2, Isometry > Isometry2f
Definition: Transform.h:643
Transform< float, 2, AffineCompact > AffineCompact2f
Definition: Transform.h:661
Represents a diagonal matrix with its storage.
Definition: DiagonalMatrix.h:135
NoAlias< Derived, Eigen::MatrixBase > noalias()
Definition: NoAlias.h:127
Definition: Constants.h:394
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
Definition: Constants.h:331
ColXpr col(Index i)
Definition: DenseBase.h:733
Transform< double, 2, Affine > Affine2d
Definition: Transform.h:656
Definition: Constants.h:391
Transform< double, 3, AffineCompact > AffineCompact3d
Definition: Transform.h:667
Definition: EigenBase.h:26
Represents a translation transformation.
Definition: ForwardDeclarations.h:236
Transform< double, 3, Affine > Affine3d
Definition: Transform.h:658
TransformTraits
Definition: Constants.h:389
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:654
const DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:278
Transform< float, 3, Projective > Projective3f
Definition: Transform.h:672
Derived & derived()
Definition: EigenBase.h:34
Definition: Constants.h:396
Expression of the multiple replication of a matrix or vector.
Definition: Replicate.h:62
Transform< double, 2, Isometry > Isometry2d
Definition: Transform.h:647
const MatrixUType & matrixU() const
Definition: JacobiSVD.h:613
Definition: Constants.h:270
Common base class for compact rotation representations.
Definition: ForwardDeclarations.h:231
Transform< double, 3, Projective > Projective3d
Definition: Transform.h:676
const Scalar * data() const
Definition: PlainObjectBase.h:212
Transform< float, 3, AffineCompact > AffineCompact3f
Definition: Transform.h:663
Transform< double, 2, AffineCompact > AffineCompact2d
Definition: Transform.h:665
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:98
Definition: Eigen_Colamd.h:54
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:102
Transform< float, 3, Isometry > Isometry3f
Definition: Transform.h:645
Transform< float, 2, Affine > Affine2f
Definition: Transform.h:652
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: ForwardDeclarations.h:224
Derived & setIdentity()
Definition: CwiseNullaryOp.h:772
RotationMatrixType toRotationMatrix() const
Definition: RotationBase.h:45
Transform< double, 2, Projective > Projective2d
Definition: Transform.h:674
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Definition: Constants.h:327
const SingularValuesType & singularValues() const
Definition: JacobiSVD.h:641
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Transform< double, 3, Isometry > Isometry3d
Definition: Transform.h:649
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:515