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<
int Mode>
struct transform_make_affine;
177 template<
typename _Scalar,
int _Dim,
int _Mode,
int _Options>
191 typedef DenseIndex Index;
203 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
207 typedef typename internal::conditional<int(Mode)==int(
AffineCompact),
220 enum { TransformTimeDiagonalMode = ((Mode==int(
Isometry))?
Affine:
int(Mode)) };
234 check_template_params();
235 internal::transform_make_affine<(int(Mode)==Affine) ? Affine : AffineCompact>::run(m_matrix);
240 check_template_params();
241 m_matrix = other.m_matrix;
244 inline explicit Transform(
const TranslationType& t)
246 check_template_params();
249 inline explicit Transform(
const UniformScaling<Scalar>& s)
251 check_template_params();
254 template<
typename Derived>
255 inline explicit Transform(
const RotationBase<Derived, Dim>& r)
257 check_template_params();
261 inline Transform& operator=(
const Transform& other)
262 { m_matrix = other.m_matrix;
return *
this; }
264 typedef internal::transform_take_affine_part<Transform> take_affine_part;
267 template<
typename OtherDerived>
270 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
271 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
273 check_template_params();
274 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
278 template<
typename OtherDerived>
281 EIGEN_STATIC_ASSERT((internal::is_same<Scalar,typename OtherDerived::Scalar>::value),
282 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
284 internal::transform_construct_from_matrix<OtherDerived,Mode,Options,Dim,HDim>::run(
this, other.
derived());
288 template<
int OtherOptions>
291 check_template_params();
293 m_matrix = other.matrix();
296 template<
int OtherMode,
int OtherOptions>
297 inline Transform(
const Transform<Scalar,Dim,OtherMode,OtherOptions>& other)
299 check_template_params();
303 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
308 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
310 enum { ModeIsAffineCompact = Mode == int(AffineCompact),
311 OtherModeIsAffineCompact = OtherMode == int(AffineCompact)
314 if(ModeIsAffineCompact == OtherModeIsAffineCompact)
319 m_matrix.template block<Dim,Dim+1>(0,0) = other.matrix().template block<Dim,Dim+1>(0,0);
322 else if(OtherModeIsAffineCompact)
324 typedef typename Transform<Scalar,Dim,OtherMode,OtherOptions>::MatrixType OtherMatrixType;
325 internal::transform_construct_from_matrix<OtherMatrixType,Mode,Options,Dim,HDim>::run(
this, other.matrix());
332 linear() = other.linear();
333 translation() = other.translation();
337 template<
typename OtherDerived>
338 Transform(
const ReturnByValue<OtherDerived>& other)
340 check_template_params();
344 template<
typename OtherDerived>
345 Transform& operator=(
const ReturnByValue<OtherDerived>& other)
351 #ifdef EIGEN_QT_SUPPORT
352 inline Transform(
const QMatrix& other);
353 inline Transform& operator=(
const QMatrix& other);
354 inline QMatrix toQMatrix(
void)
const;
355 inline Transform(
const QTransform& other);
356 inline Transform& operator=(
const QTransform& other);
357 inline QTransform toQTransform(
void)
const;
362 inline Scalar operator() (Index row, Index col)
const {
return m_matrix(row,col); }
365 inline Scalar& operator() (Index row, Index col) {
return m_matrix(row,col); }
368 inline const MatrixType&
matrix()
const {
return m_matrix; }
370 inline MatrixType&
matrix() {
return m_matrix; }
373 inline ConstLinearPart
linear()
const {
return ConstLinearPart(m_matrix,0,0); }
375 inline LinearPart
linear() {
return LinearPart(m_matrix,0,0); }
378 inline ConstAffinePart
affine()
const {
return take_affine_part::run(m_matrix); }
380 inline AffinePart
affine() {
return take_affine_part::run(m_matrix); }
383 inline ConstTranslationPart
translation()
const {
return ConstTranslationPart(m_matrix,0,Dim); }
385 inline TranslationPart
translation() {
return TranslationPart(m_matrix,0,Dim); }
399 template<
typename OtherDerived>
400 EIGEN_STRONG_INLINE
const typename internal::transform_right_product_impl<Transform, OtherDerived>::ResultType
402 {
return internal::transform_right_product_impl<Transform, OtherDerived>::run(*
this,other.
derived()); }
411 template<
typename OtherDerived>
friend
412 inline const typename internal::transform_left_product_impl<OtherDerived,Mode,Options,_Dim,_Dim+1>::ResultType
414 {
return internal::transform_left_product_impl<OtherDerived,Mode,Options,Dim,HDim>::run(a.
derived(),b); }
422 template<
typename DiagonalDerived>
423 inline const TransformTimeDiagonalReturnType
424 operator * (
const DiagonalBase<DiagonalDerived> &b)
const
426 TransformTimeDiagonalReturnType res(*
this);
437 template<
typename DiagonalDerived>
438 friend inline TransformTimeDiagonalReturnType
439 operator * (
const DiagonalBase<DiagonalDerived> &a,
const Transform &b)
441 TransformTimeDiagonalReturnType res;
442 res.
linear().noalias() = a*b.linear();
445 res.
matrix().
row(Dim) = b.matrix().row(Dim);
449 template<
typename OtherDerived>
455 return internal::transform_transform_product_impl<Transform,Transform>::run(*
this,other);
458 #ifdef __INTEL_COMPILER
467 template<
int OtherMode,
int OtherOptions>
struct icc_11_workaround
469 typedef internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> > ProductType;
470 typedef typename ProductType::ResultType ResultType;
475 template<
int OtherMode,
int OtherOptions>
476 inline typename icc_11_workaround<OtherMode,OtherOptions>::ResultType
477 operator * (
const Transform<Scalar,Dim,OtherMode,OtherOptions>& other)
const
479 typedef typename icc_11_workaround<OtherMode,OtherOptions>::ProductType ProductType;
480 return ProductType::run(*
this,other);
484 template<
int OtherMode,
int OtherOptions>
485 inline typename internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::ResultType
488 return internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::run(*
this,other);
501 return Transform(MatrixType::Identity());
504 template<
typename OtherDerived>
507 template<
typename OtherDerived>
510 inline Transform& scale(
const Scalar& s);
511 inline Transform& prescale(
const Scalar& s);
513 template<
typename OtherDerived>
516 template<
typename OtherDerived>
519 template<
typename RotationType>
520 inline Transform& rotate(
const RotationType& rotation);
522 template<
typename RotationType>
523 inline Transform& prerotate(
const RotationType& rotation);
525 Transform& shear(
const Scalar& sx,
const Scalar& sy);
526 Transform& preshear(
const Scalar& sx,
const Scalar& sy);
528 inline Transform& operator=(
const TranslationType& t);
529 inline Transform& operator*=(
const TranslationType& t) {
return translate(t.vector()); }
530 inline Transform operator*(
const TranslationType& t)
const;
532 inline Transform& operator=(
const UniformScaling<Scalar>& t);
533 inline Transform& operator*=(
const UniformScaling<Scalar>& s) {
return scale(s.factor()); }
534 inline Transform<Scalar,Dim,(int(Mode)==int(Isometry)?int(Affine):int(Mode))> operator*(
const UniformScaling<Scalar>& s)
const
536 Transform<Scalar,Dim,(int(Mode)==int(Isometry)?int(Affine):int(Mode)),Options> res = *
this;
537 res.scale(s.factor());
541 inline Transform& operator*=(
const DiagonalMatrix<Scalar,Dim>& s) { linear() *= s;
return *
this; }
543 template<
typename Derived>
544 inline Transform& operator=(
const RotationBase<Derived,Dim>& r);
545 template<
typename Derived>
546 inline Transform& operator*=(
const RotationBase<Derived,Dim>& r) {
return rotate(r.toRotationMatrix()); }
547 template<
typename Derived>
548 inline Transform operator*(
const RotationBase<Derived,Dim>& r)
const;
550 const LinearMatrixType rotation()
const;
551 template<
typename RotationMatrixType,
typename ScalingMatrixType>
552 void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling)
const;
553 template<
typename ScalingMatrixType,
typename RotationMatrixType>
554 void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation)
const;
556 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
557 Transform& fromPositionOrientationScale(
const MatrixBase<PositionDerived> &position,
558 const OrientationType& orientation,
const MatrixBase<ScaleDerived> &scale);
563 const Scalar*
data()
const {
return m_matrix.
data(); }
572 template<
typename NewScalarType>
573 inline typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type
cast()
const
574 {
return typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode,Options> >::type(*
this); }
577 template<
typename OtherScalarType>
580 check_template_params();
581 m_matrix = other.matrix().template cast<Scalar>();
589 {
return m_matrix.
isApprox(other.m_matrix, prec); }
595 internal::transform_make_affine<int(Mode)>::run(m_matrix);
603 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
608 inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,Dim> linearExt()
const
609 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
615 inline Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt()
616 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
621 inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt()
const
622 {
return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
625 #ifdef EIGEN_TRANSFORM_PLUGIN
626 #include EIGEN_TRANSFORM_PLUGIN
630 #ifndef EIGEN_PARSED_BY_DOXYGEN
631 static EIGEN_STRONG_INLINE
void check_template_params()
633 EIGEN_STATIC_ASSERT((Options & (
DontAlign|
RowMajor)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)
679 #ifdef EIGEN_QT_SUPPORT
684 template<
typename Scalar,
int Dim,
int Mode,
int Options>
687 check_template_params();
695 template<
typename Scalar,
int Dim,
int Mode,
int Options>
698 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
699 m_matrix << other.m11(), other.m21(), other.dx(),
700 other.m12(), other.m22(), other.dy(),
711 template<
typename Scalar,
int Dim,
int Mode,
int Options>
714 check_template_params();
715 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
716 return QMatrix(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
717 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
718 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
725 template<
typename Scalar,
int Dim,
int Mode,
int Options>
728 check_template_params();
736 template<
typename Scalar,
int Dim,
int Mode,
int Options>
739 check_template_params();
740 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
742 m_matrix << other.m11(), other.m21(), other.dx(),
743 other.m12(), other.m22(), other.dy();
745 m_matrix << other.m11(), other.m21(), other.dx(),
746 other.m12(), other.m22(), other.dy(),
747 other.m13(), other.m23(), other.m33();
755 template<
typename Scalar,
int Dim,
int Mode,
int Options>
758 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
760 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
761 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
762 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
764 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0),
765 m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1),
766 m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2));
778 template<
typename Scalar,
int Dim,
int Mode,
int Options>
779 template<
typename OtherDerived>
783 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
784 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
785 linearExt().noalias() = (linearExt() * other.
asDiagonal());
793 template<
typename Scalar,
int Dim,
int Mode,
int Options>
796 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
805 template<
typename Scalar,
int Dim,
int Mode,
int Options>
806 template<
typename OtherDerived>
810 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
811 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
812 m_matrix.template block<Dim,HDim>(0,0).noalias() = (other.
asDiagonal() * m_matrix.template block<Dim,HDim>(0,0));
820 template<
typename Scalar,
int Dim,
int Mode,
int Options>
823 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
824 m_matrix.template topRows<Dim>() *= s;
832 template<
typename Scalar,
int Dim,
int Mode,
int Options>
833 template<
typename OtherDerived>
837 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
838 translationExt() += linearExt() * other;
846 template<
typename Scalar,
int Dim,
int Mode,
int Options>
847 template<
typename OtherDerived>
851 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,
int(Dim))
853 affine() += other * m_matrix.
row(Dim);
855 translation() += other;
876 template<
typename Scalar,
int Dim,
int Mode,
int Options>
877 template<
typename RotationType>
881 linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
892 template<
typename Scalar,
int Dim,
int Mode,
int Options>
893 template<
typename RotationType>
897 m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
898 * m_matrix.template block<Dim,HDim>(0,0);
907 template<
typename Scalar,
int Dim,
int Mode,
int Options>
911 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
912 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
913 VectorType tmp = linear().col(0)*sy + linear().col(1);
914 linear() << linear().col(0) + linear().col(1)*sx, tmp;
923 template<
typename Scalar,
int Dim,
int Mode,
int Options>
927 EIGEN_STATIC_ASSERT(
int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
928 EIGEN_STATIC_ASSERT(Mode!=
int(
Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
929 m_matrix.template block<Dim,HDim>(0,0) = LinearMatrixType(1, sx, sy, 1) * m_matrix.template block<Dim,HDim>(0,0);
937 template<
typename Scalar,
int Dim,
int Mode,
int Options>
941 translation() = t.vector();
946 template<
typename Scalar,
int Dim,
int Mode,
int Options>
949 Transform res = *
this;
950 res.translate(t.vector());
954 template<
typename Scalar,
int Dim,
int Mode,
int Options>
955 inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(
const UniformScaling<Scalar>& s)
958 linear().diagonal().fill(s.factor());
963 template<
typename Scalar,
int Dim,
int Mode,
int Options>
964 template<
typename Derived>
965 inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(
const RotationBase<Derived,Dim>& r)
967 linear() = internal::toRotationMatrix<Scalar,Dim>(r);
968 translation().setZero();
973 template<
typename Scalar,
int Dim,
int Mode,
int Options>
974 template<
typename Derived>
977 Transform res = *
this;
978 res.rotate(r.derived());
993 template<
typename Scalar,
int Dim,
int Mode,
int Options>
994 const typename Transform<Scalar,Dim,Mode,Options>::LinearMatrixType
997 LinearMatrixType result;
998 computeRotationScaling(&result, (LinearMatrixType*)0);
1014 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1015 template<
typename RotationMatrixType,
typename ScalingMatrixType>
1020 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1022 sv.coeffRef(0) *= x;
1023 if(scaling) scaling->lazyAssign(svd.
matrixV() * sv.asDiagonal() * svd.
matrixV().adjoint());
1026 LinearMatrixType m(svd.
matrixU());
1028 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1043 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1044 template<
typename ScalingMatrixType,
typename RotationMatrixType>
1049 Scalar x = (svd.
matrixU() * svd.
matrixV().adjoint()).determinant();
1051 sv.coeffRef(0) *= x;
1052 if(scaling) scaling->lazyAssign(svd.
matrixU() * sv.asDiagonal() * svd.
matrixU().adjoint());
1055 LinearMatrixType m(svd.
matrixU());
1057 rotation->lazyAssign(m * svd.
matrixV().adjoint());
1064 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1065 template<
typename PositionDerived,
typename OrientationType,
typename ScaleDerived>
1070 linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1072 translation() = position;
1080 struct transform_make_affine
1082 template<
typename MatrixType>
1083 static void run(MatrixType &mat)
1085 static const int Dim = MatrixType::ColsAtCompileTime-1;
1086 mat.template block<1,Dim>(Dim,0).setZero();
1087 mat.coeffRef(Dim,Dim) =
typename MatrixType::Scalar(1);
1094 template<
typename MatrixType>
static void run(MatrixType &) { }
1098 template<
typename TransformType,
int Mode=TransformType::Mode>
1099 struct projective_transform_inverse
1101 static inline void run(
const TransformType&, TransformType&)
1105 template<
typename TransformType>
1106 struct projective_transform_inverse<TransformType,
Projective>
1108 static inline void run(
const TransformType& m, TransformType& res)
1110 res.matrix() = m.matrix().inverse();
1137 template<
typename Scalar,
int Dim,
int Mode,
int Options>
1138 Transform<Scalar,Dim,Mode,Options>
1144 internal::projective_transform_inverse<Transform>::run(*
this, res);
1150 res.matrix().template topLeftCorner<Dim,Dim>() = linear().transpose();
1154 res.matrix().template topLeftCorner<Dim,Dim>() = linear().inverse();
1158 eigen_assert(
false &&
"Invalid transform traits in Transform::Inverse");
1161 res.matrix().template topRightCorner<Dim,1>()
1162 = - res.matrix().template topLeftCorner<Dim,Dim>() * translation();
1174 template<
typename TransformType>
struct transform_take_affine_part {
1175 typedef typename TransformType::MatrixType MatrixType;
1176 typedef typename TransformType::AffinePart AffinePart;
1177 typedef typename TransformType::ConstAffinePart ConstAffinePart;
1178 static inline AffinePart run(MatrixType& m)
1179 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1180 static inline ConstAffinePart run(
const MatrixType& m)
1181 {
return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1184 template<
typename Scalar,
int Dim,
int Options>
1185 struct transform_take_affine_part<Transform<Scalar,Dim,
AffineCompact, Options> > {
1186 typedef typename Transform<Scalar,Dim,AffineCompact,Options>::MatrixType MatrixType;
1187 static inline MatrixType& run(MatrixType& m) {
return m; }
1188 static inline const MatrixType& run(
const MatrixType& m) {
return m; }
1195 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1196 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1198 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1200 transform->linear() = other;
1201 transform->translation().setZero();
1202 transform->makeAffine();
1206 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1207 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1209 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1211 transform->affine() = other;
1212 transform->makeAffine();
1216 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1217 struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1219 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform,
const Other& other)
1220 { transform->matrix() = other; }
1223 template<
typename Other,
int Options,
int Dim,
int HDim>
1224 struct transform_construct_from_matrix<Other,
AffineCompact,Options,Dim,HDim, HDim,HDim>
1226 static inline void run(Transform<typename Other::Scalar,Dim,AffineCompact,Options> *transform,
const Other& other)
1227 { transform->matrix() = other.template block<Dim,HDim>(0,0); }
1234 template<
int LhsMode,
int RhsMode>
1235 struct transform_product_result
1247 template<
typename TransformType,
typename MatrixType >
1248 struct transform_right_product_impl< TransformType, MatrixType, 0 >
1250 typedef typename MatrixType::PlainObject ResultType;
1252 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1254 return T.matrix() * other;
1258 template<
typename TransformType,
typename MatrixType >
1259 struct transform_right_product_impl< TransformType, MatrixType, 1 >
1262 Dim = TransformType::Dim,
1263 HDim = TransformType::HDim,
1264 OtherRows = MatrixType::RowsAtCompileTime,
1265 OtherCols = MatrixType::ColsAtCompileTime
1268 typedef typename MatrixType::PlainObject ResultType;
1270 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1272 EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1274 typedef Block<ResultType, Dim, OtherCols, int(MatrixType::RowsAtCompileTime)==Dim> TopLeftLhs;
1276 ResultType res(other.rows(),other.cols());
1277 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1278 res.row(OtherRows-1) = other.row(OtherRows-1);
1284 template<
typename TransformType,
typename MatrixType >
1285 struct transform_right_product_impl< TransformType, MatrixType, 2 >
1288 Dim = TransformType::Dim,
1289 HDim = TransformType::HDim,
1290 OtherRows = MatrixType::RowsAtCompileTime,
1291 OtherCols = MatrixType::ColsAtCompileTime
1294 typedef typename MatrixType::PlainObject ResultType;
1296 static EIGEN_STRONG_INLINE ResultType run(
const TransformType& T,
const MatrixType& other)
1298 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1300 typedef Block<ResultType, Dim, OtherCols, true> TopLeftLhs;
1301 ResultType res(Replicate<typename TransformType::ConstTranslationPart, 1, OtherCols>(T.translation(),1,other.cols()));
1302 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1313 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1314 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1316 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1317 typedef typename TransformType::MatrixType MatrixType;
1318 typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1319 static ResultType run(
const Other& other,
const TransformType& tr)
1320 {
return ResultType(other * tr.matrix()); }
1324 template<
typename Other,
int Options,
int Dim,
int HDim>
1325 struct transform_left_product_impl<Other,
AffineCompact,Options,Dim,HDim, HDim,HDim>
1327 typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1328 typedef typename TransformType::MatrixType MatrixType;
1329 typedef Transform<typename Other::Scalar,Dim,Projective,Options> ResultType;
1330 static ResultType run(
const Other& other,
const TransformType& tr)
1333 res.matrix().noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1334 res.matrix().col(Dim) += other.col(Dim);
1340 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1341 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1343 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1344 typedef typename TransformType::MatrixType MatrixType;
1345 typedef TransformType ResultType;
1346 static ResultType run(
const Other& other,
const TransformType& tr)
1349 res.affine().noalias() = other * tr.matrix();
1350 res.matrix().row(Dim) = tr.matrix().row(Dim);
1356 template<
typename Other,
int Options,
int Dim,
int HDim>
1357 struct transform_left_product_impl<Other,
AffineCompact,Options,Dim,HDim, Dim,HDim>
1359 typedef Transform<typename Other::Scalar,Dim,AffineCompact,Options> TransformType;
1360 typedef typename TransformType::MatrixType MatrixType;
1361 typedef TransformType ResultType;
1362 static ResultType run(
const Other& other,
const TransformType& tr)
1365 res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1366 res.translation() += other.col(Dim);
1372 template<
typename Other,
int Mode,
int Options,
int Dim,
int HDim>
1373 struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1375 typedef Transform<typename Other::Scalar,Dim,Mode,Options> TransformType;
1376 typedef typename TransformType::MatrixType MatrixType;
1377 typedef TransformType ResultType;
1378 static ResultType run(
const Other& other,
const TransformType& tr)
1382 res.matrix().row(Dim) = tr.matrix().row(Dim);
1383 res.matrix().template topRows<Dim>().noalias()
1384 = other * tr.matrix().template topRows<Dim>();
1393 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1394 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,false >
1396 enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
1397 typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1398 typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1399 typedef Transform<Scalar,Dim,ResultMode,LhsOptions> ResultType;
1400 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1403 res.linear() = lhs.linear() * rhs.linear();
1404 res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1410 template<
typename Scalar,
int Dim,
int LhsMode,
int LhsOptions,
int RhsMode,
int RhsOptions>
1411 struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode,LhsOptions>,Transform<Scalar,Dim,RhsMode,RhsOptions>,true >
1413 typedef Transform<Scalar,Dim,LhsMode,LhsOptions> Lhs;
1414 typedef Transform<Scalar,Dim,RhsMode,RhsOptions> Rhs;
1415 typedef Transform<Scalar,Dim,Projective> ResultType;
1416 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1418 return ResultType( lhs.matrix() * rhs.matrix() );
1422 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1423 struct transform_transform_product_impl<Transform<Scalar,Dim,
AffineCompact,LhsOptions>,Transform<Scalar,Dim,
Projective,RhsOptions>,true >
1425 typedef Transform<Scalar,Dim,AffineCompact,LhsOptions> Lhs;
1426 typedef Transform<Scalar,Dim,Projective,RhsOptions> Rhs;
1427 typedef Transform<Scalar,Dim,Projective> ResultType;
1428 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1431 res.matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1432 res.matrix().row(Dim) = rhs.matrix().row(Dim);
1437 template<
typename Scalar,
int Dim,
int LhsOptions,
int RhsOptions>
1438 struct transform_transform_product_impl<Transform<Scalar,Dim,
Projective,LhsOptions>,Transform<Scalar,Dim,
AffineCompact,RhsOptions>,true >
1440 typedef Transform<Scalar,Dim,Projective,LhsOptions> Lhs;
1441 typedef Transform<Scalar,Dim,AffineCompact,RhsOptions> Rhs;
1442 typedef Transform<Scalar,Dim,Projective> ResultType;
1443 static ResultType run(
const Lhs& lhs,
const Rhs& rhs)
1445 ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1446 res.matrix().col(Dim) += lhs.matrix().col(Dim);
1455 #endif // EIGEN_TRANSFORM_H
Definition: Constants.h:398
RowXpr row(Index i)
Definition: DenseBase.h:750
const Scalar * data() const
Definition: PlainObjectBase.h:212
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:98
Definition: Constants.h:270
Transform< float, 2, Projective > Projective2f
Definition: Transform.h:667
Transform< float, 2, Isometry > Isometry2f
Definition: Transform.h:640
Transform< float, 2, AffineCompact > AffineCompact2f
Definition: Transform.h:658
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
Transform< double, 2, Affine > Affine2d
Definition: Transform.h:653
const SingularValuesType & singularValues() const
Definition: JacobiSVD.h:641
Definition: Constants.h:391
Transform< double, 3, AffineCompact > AffineCompact3d
Definition: Transform.h:664
Definition: EigenBase.h:26
Represents a translation transformation.
Definition: ForwardDeclarations.h:236
Transform< double, 3, Affine > Affine3d
Definition: Transform.h:655
TransformTraits
Definition: Constants.h:389
Transform< float, 3, Affine > Affine3f
Definition: Transform.h:651
Transform< float, 3, Projective > Projective3f
Definition: Transform.h:669
Derived & derived()
Definition: EigenBase.h:34
Definition: Constants.h:396
const MatrixUType & matrixU() const
Definition: JacobiSVD.h:613
Transform< double, 2, Isometry > Isometry2d
Definition: Transform.h:644
Transform< double, 3, Projective > Projective3d
Definition: Transform.h:673
Transform< float, 3, AffineCompact > AffineCompact3f
Definition: Transform.h:660
Transform< double, 2, AffineCompact > AffineCompact2d
Definition: Transform.h:662
Definition: Eigen_Colamd.h:54
const MatrixVType & matrixV() const
Definition: JacobiSVD.h:629
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:102
Transform< float, 3, Isometry > Isometry3f
Definition: Transform.h:642
Transform< float, 2, Affine > Affine2f
Definition: Transform.h:649
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: ForwardDeclarations.h:224
Derived & setIdentity()
Definition: CwiseNullaryOp.h:772
Transform< double, 2, Projective > Projective2d
Definition: Transform.h:671
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
Definition: Constants.h:327
const DiagonalWrapper< const Derived > asDiagonal() const
Definition: DiagonalMatrix.h:278
Base class for all dense matrices, vectors, and expressions.
Definition: MatrixBase.h:48
Definition: Constants.h:266
Transform< double, 3, Isometry > Isometry3d
Definition: Transform.h:646
Derived & setZero(Index size)
Definition: CwiseNullaryOp.h:515