Medial Code Documentation
Loading...
Searching...
No Matches
Transform.h
1// This file is part of Eigen, a lightweight C++ template library
2// for linear algebra.
3//
4// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
5// Copyright (C) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
6// Copyright (C) 2010 Hauke Heibel <hauke.heibel@gmail.com>
7//
8// This Source Code Form is subject to the terms of the Mozilla
9// Public License v. 2.0. If a copy of the MPL was not distributed
10// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
11
12#ifndef EIGEN_TRANSFORM_H
13#define EIGEN_TRANSFORM_H
14
15namespace Eigen {
16
17namespace internal {
18
19template<typename Transform>
21{
22 enum
23 {
24 Dim = Transform::Dim,
25 HDim = Transform::HDim,
26 Mode = Transform::Mode,
27 IsProjective = (int(Mode)==int(Projective))
28 };
29};
30
31template< typename TransformType,
32 typename MatrixType,
34 : int(MatrixType::RowsAtCompileTime) == int(transform_traits<TransformType>::HDim) ? 1
35 : 2,
36 int RhsCols = MatrixType::ColsAtCompileTime>
38
39template< typename Other,
40 int Mode,
41 int Options,
42 int Dim,
43 int HDim,
44 int OtherRows=Other::RowsAtCompileTime,
45 int OtherCols=Other::ColsAtCompileTime>
47
48template< typename Lhs,
49 typename Rhs,
50 bool AnyProjective =
54
55template< typename Other,
56 int Mode,
57 int Options,
58 int Dim,
59 int HDim,
60 int OtherRows=Other::RowsAtCompileTime,
61 int OtherCols=Other::ColsAtCompileTime>
63
64template<typename TransformType> struct transform_take_affine_part;
65
66template<typename _Scalar, int _Dim, int _Mode, int _Options>
67struct traits<Transform<_Scalar,_Dim,_Mode,_Options> >
68{
69 typedef _Scalar Scalar;
70 typedef Eigen::Index StorageIndex;
71 typedef Dense StorageKind;
72 enum {
73 Dim1 = _Dim==Dynamic ? _Dim : _Dim + 1,
74 RowsAtCompileTime = _Mode==Projective ? Dim1 : _Dim,
75 ColsAtCompileTime = Dim1,
76 MaxRowsAtCompileTime = RowsAtCompileTime,
77 MaxColsAtCompileTime = ColsAtCompileTime,
78 Flags = 0
79 };
80};
81
82template<int Mode> struct transform_make_affine;
83
84} // end namespace internal
85
203template<typename _Scalar, int _Dim, int _Mode, int _Options>
205{
206public:
208 enum {
209 Mode = _Mode,
210 Options = _Options,
211 Dim = _Dim,
212 HDim = _Dim+1,
213 Rows = int(Mode)==(AffineCompact) ? Dim : HDim
214 };
216 typedef _Scalar Scalar;
217 typedef Eigen::Index StorageIndex;
226 typedef Block<MatrixType,Dim,Dim,int(Mode)==(AffineCompact) && (int(Options)&RowMajor)==0> LinearPart;
228 typedef const Block<ConstMatrixType,Dim,Dim,int(Mode)==(AffineCompact) && (int(Options)&RowMajor)==0> ConstLinearPart;
230 typedef typename internal::conditional<int(Mode)==int(AffineCompact),
231 MatrixType&,
234 typedef typename internal::conditional<int(Mode)==int(AffineCompact),
235 const MatrixType&,
245
246 // this intermediate enum is needed to avoid an ICE with gcc 3.4 and 4.0
247 enum { TransformTimeDiagonalMode = ((Mode==int(Isometry))?Affine:int(Mode)) };
250
251protected:
252
253 MatrixType m_matrix;
254
255public:
256
259 EIGEN_DEVICE_FUNC inline Transform()
260 {
261 check_template_params();
262 internal::transform_make_affine<(int(Mode)==Affine || int(Mode)==Isometry) ? Affine : AffineCompact>::run(m_matrix);
263 }
264
265 EIGEN_DEVICE_FUNC inline explicit Transform(const TranslationType& t)
266 {
267 check_template_params();
268 *this = t;
269 }
270 EIGEN_DEVICE_FUNC inline explicit Transform(const UniformScaling<Scalar>& s)
271 {
272 check_template_params();
273 *this = s;
274 }
275 template<typename Derived>
276 EIGEN_DEVICE_FUNC inline explicit Transform(const RotationBase<Derived, Dim>& r)
277 {
278 check_template_params();
279 *this = r;
280 }
281
282 typedef internal::transform_take_affine_part<Transform> take_affine_part;
283
285 template<typename OtherDerived>
286 EIGEN_DEVICE_FUNC inline explicit Transform(const EigenBase<OtherDerived>& other)
287 {
289 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
290
291 check_template_params();
293 }
294
296 template<typename OtherDerived>
297 EIGEN_DEVICE_FUNC inline Transform& operator=(const EigenBase<OtherDerived>& other)
298 {
300 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY);
301
303 return *this;
304 }
305
306 template<int OtherOptions>
307 EIGEN_DEVICE_FUNC inline Transform(const Transform<Scalar,Dim,Mode,OtherOptions>& other)
308 {
309 check_template_params();
310 // only the options change, we can directly copy the matrices
311 m_matrix = other.matrix();
312 }
313
314 template<int OtherMode,int OtherOptions>
315 EIGEN_DEVICE_FUNC inline Transform(const Transform<Scalar,Dim,OtherMode,OtherOptions>& other)
316 {
317 check_template_params();
318 // prevent conversions as:
319 // Affine | AffineCompact | Isometry = Projective
320 EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(OtherMode==int(Projective), Mode==int(Projective)),
321 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
322
323 // prevent conversions as:
324 // Isometry = Affine | AffineCompact
325 EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(OtherMode==int(Affine)||OtherMode==int(AffineCompact), Mode!=int(Isometry)),
326 YOU_PERFORMED_AN_INVALID_TRANSFORMATION_CONVERSION)
327
328 enum { ModeIsAffineCompact = Mode == int(AffineCompact),
329 OtherModeIsAffineCompact = OtherMode == int(AffineCompact)
330 };
331
332 if(EIGEN_CONST_CONDITIONAL(ModeIsAffineCompact == OtherModeIsAffineCompact))
333 {
334 // We need the block expression because the code is compiled for all
335 // combinations of transformations and will trigger a compile time error
336 // if one tries to assign the matrices directly
337 m_matrix.template block<Dim,Dim+1>(0,0) = other.matrix().template block<Dim,Dim+1>(0,0);
338 makeAffine();
339 }
340 else if(EIGEN_CONST_CONDITIONAL(OtherModeIsAffineCompact))
341 {
342 typedef typename Transform<Scalar,Dim,OtherMode,OtherOptions>::MatrixType OtherMatrixType;
343 internal::transform_construct_from_matrix<OtherMatrixType,Mode,Options,Dim,HDim>::run(this, other.matrix());
344 }
345 else
346 {
347 // here we know that Mode == AffineCompact and OtherMode != AffineCompact.
348 // if OtherMode were Projective, the static assert above would already have caught it.
349 // So the only possibility is that OtherMode == Affine
350 linear() = other.linear();
351 translation() = other.translation();
352 }
353 }
354
355 template<typename OtherDerived>
356 EIGEN_DEVICE_FUNC Transform(const ReturnByValue<OtherDerived>& other)
357 {
358 check_template_params();
359 other.evalTo(*this);
360 }
361
362 template<typename OtherDerived>
363 EIGEN_DEVICE_FUNC Transform& operator=(const ReturnByValue<OtherDerived>& other)
364 {
365 other.evalTo(*this);
366 return *this;
367 }
368
369 #ifdef EIGEN_QT_SUPPORT
370 inline Transform(const QMatrix& other);
371 inline Transform& operator=(const QMatrix& other);
372 inline QMatrix toQMatrix(void) const;
373 inline Transform(const QTransform& other);
374 inline Transform& operator=(const QTransform& other);
375 inline QTransform toQTransform(void) const;
376 #endif
377
378 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT { return int(Mode)==int(Projective) ? m_matrix.cols() : (m_matrix.cols()-1); }
379 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT { return m_matrix.cols(); }
380
383 EIGEN_DEVICE_FUNC inline Scalar operator() (Index row, Index col) const { return m_matrix(row,col); }
386 EIGEN_DEVICE_FUNC inline Scalar& operator() (Index row, Index col) { return m_matrix(row,col); }
387
389 EIGEN_DEVICE_FUNC inline const MatrixType& matrix() const { return m_matrix; }
391 EIGEN_DEVICE_FUNC inline MatrixType& matrix() { return m_matrix; }
392
394 EIGEN_DEVICE_FUNC inline ConstLinearPart linear() const { return ConstLinearPart(m_matrix,0,0); }
396 EIGEN_DEVICE_FUNC inline LinearPart linear() { return LinearPart(m_matrix,0,0); }
397
399 EIGEN_DEVICE_FUNC inline ConstAffinePart affine() const { return take_affine_part::run(m_matrix); }
401 EIGEN_DEVICE_FUNC inline AffinePart affine() { return take_affine_part::run(m_matrix); }
402
404 EIGEN_DEVICE_FUNC inline ConstTranslationPart translation() const { return ConstTranslationPart(m_matrix,0,Dim); }
406 EIGEN_DEVICE_FUNC inline TranslationPart translation() { return TranslationPart(m_matrix,0,Dim); }
407
432 // note: this function is defined here because some compilers cannot find the respective declaration
433 template<typename OtherDerived>
434 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const typename internal::transform_right_product_impl<Transform, OtherDerived>::ResultType
437
445 template<typename OtherDerived> friend
449
456 template<typename DiagonalDerived>
457 EIGEN_DEVICE_FUNC inline const TransformTimeDiagonalReturnType
459 {
461 res.linearExt() *= b;
462 return res;
463 }
464
471 template<typename DiagonalDerived>
472 EIGEN_DEVICE_FUNC friend inline TransformTimeDiagonalReturnType
474 {
476 res.linear().noalias() = a*b.linear();
477 res.translation().noalias() = a*b.translation();
478 if (EIGEN_CONST_CONDITIONAL(Mode!=int(AffineCompact)))
479 res.matrix().row(Dim) = b.matrix().row(Dim);
480 return res;
481 }
482
483 template<typename OtherDerived>
484 EIGEN_DEVICE_FUNC inline Transform& operator*=(const EigenBase<OtherDerived>& other) { return *this = *this * other; }
485
487 EIGEN_DEVICE_FUNC inline const Transform operator * (const Transform& other) const
488 {
490 }
491
492 #if EIGEN_COMP_ICC
493private:
494 // this intermediate structure permits to workaround a bug in ICC 11:
495 // error: template instantiation resulted in unexpected function type of "Eigen::Transform<double, 3, 32, 0>
496 // (const Eigen::Transform<double, 3, 2, 0> &) const"
497 // (the meaning of a name may have changed since the template declaration -- the type of the template is:
498 // "Eigen::internal::transform_transform_product_impl<Eigen::Transform<double, 3, 32, 0>,
499 // Eigen::Transform<double, 3, Mode, Options>, <expression>>::ResultType (const Eigen::Transform<double, 3, Mode, Options> &) const")
500 //
501 template<int OtherMode,int OtherOptions> struct icc_11_workaround
502 {
504 typedef typename ProductType::ResultType ResultType;
505 };
506
507public:
509 template<int OtherMode,int OtherOptions>
510 inline typename icc_11_workaround<OtherMode,OtherOptions>::ResultType
511 operator * (const Transform<Scalar,Dim,OtherMode,OtherOptions>& other) const
512 {
513 typedef typename icc_11_workaround<OtherMode,OtherOptions>::ProductType ProductType;
514 return ProductType::run(*this,other);
515 }
516 #else
518 template<int OtherMode,int OtherOptions>
519 EIGEN_DEVICE_FUNC inline typename internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode,OtherOptions> >::ResultType
524 #endif
525
527 EIGEN_DEVICE_FUNC void setIdentity() { m_matrix.setIdentity(); }
528
533 EIGEN_DEVICE_FUNC static const Transform Identity()
534 {
536 }
537
538 template<typename OtherDerived>
539 EIGEN_DEVICE_FUNC
540 inline Transform& scale(const MatrixBase<OtherDerived> &other);
541
542 template<typename OtherDerived>
543 EIGEN_DEVICE_FUNC
544 inline Transform& prescale(const MatrixBase<OtherDerived> &other);
545
546 EIGEN_DEVICE_FUNC inline Transform& scale(const Scalar& s);
547 EIGEN_DEVICE_FUNC inline Transform& prescale(const Scalar& s);
548
549 template<typename OtherDerived>
550 EIGEN_DEVICE_FUNC
551 inline Transform& translate(const MatrixBase<OtherDerived> &other);
552
553 template<typename OtherDerived>
554 EIGEN_DEVICE_FUNC
555 inline Transform& pretranslate(const MatrixBase<OtherDerived> &other);
556
557 template<typename RotationType>
558 EIGEN_DEVICE_FUNC
559 inline Transform& rotate(const RotationType& rotation);
560
561 template<typename RotationType>
562 EIGEN_DEVICE_FUNC
563 inline Transform& prerotate(const RotationType& rotation);
564
565 EIGEN_DEVICE_FUNC Transform& shear(const Scalar& sx, const Scalar& sy);
566 EIGEN_DEVICE_FUNC Transform& preshear(const Scalar& sx, const Scalar& sy);
567
568 EIGEN_DEVICE_FUNC inline Transform& operator=(const TranslationType& t);
569
570 EIGEN_DEVICE_FUNC
571 inline Transform& operator*=(const TranslationType& t) { return translate(t.vector()); }
572
573 EIGEN_DEVICE_FUNC inline Transform operator*(const TranslationType& t) const;
574
575 EIGEN_DEVICE_FUNC
576 inline Transform& operator=(const UniformScaling<Scalar>& t);
577
578 EIGEN_DEVICE_FUNC
579 inline Transform& operator*=(const UniformScaling<Scalar>& s) { return scale(s.factor()); }
580
581 EIGEN_DEVICE_FUNC
582 inline TransformTimeDiagonalReturnType operator*(const UniformScaling<Scalar>& s) const
583 {
585 res.scale(s.factor());
586 return res;
587 }
588
589 EIGEN_DEVICE_FUNC
590 inline Transform& operator*=(const DiagonalMatrix<Scalar,Dim>& s) { linearExt() *= s; return *this; }
591
592 template<typename Derived>
593 EIGEN_DEVICE_FUNC inline Transform& operator=(const RotationBase<Derived,Dim>& r);
594 template<typename Derived>
595 EIGEN_DEVICE_FUNC inline Transform& operator*=(const RotationBase<Derived,Dim>& r) { return rotate(r.toRotationMatrix()); }
596 template<typename Derived>
597 EIGEN_DEVICE_FUNC inline Transform operator*(const RotationBase<Derived,Dim>& r) const;
598
599 typedef typename internal::conditional<int(Mode)==Isometry,ConstLinearPart,const LinearMatrixType>::type RotationReturnType;
600 EIGEN_DEVICE_FUNC RotationReturnType rotation() const;
601
602 template<typename RotationMatrixType, typename ScalingMatrixType>
603 EIGEN_DEVICE_FUNC
604 void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const;
605 template<typename ScalingMatrixType, typename RotationMatrixType>
606 EIGEN_DEVICE_FUNC
607 void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const;
608
609 template<typename PositionDerived, typename OrientationType, typename ScaleDerived>
610 EIGEN_DEVICE_FUNC
611 Transform& fromPositionOrientationScale(const MatrixBase<PositionDerived> &position,
612 const OrientationType& orientation, const MatrixBase<ScaleDerived> &scale);
613
614 EIGEN_DEVICE_FUNC
615 inline Transform inverse(TransformTraits traits = (TransformTraits)Mode) const;
616
618 EIGEN_DEVICE_FUNC const Scalar* data() const { return m_matrix.data(); }
620 EIGEN_DEVICE_FUNC Scalar* data() { return m_matrix.data(); }
621
627 template<typename NewScalarType>
630
632 template<typename OtherScalarType>
633 EIGEN_DEVICE_FUNC inline explicit Transform(const Transform<OtherScalarType,Dim,Mode,Options>& other)
634 {
635 check_template_params();
636 m_matrix = other.matrix().template cast<Scalar>();
637 }
638
643 EIGEN_DEVICE_FUNC bool isApprox(const Transform& other, const typename NumTraits<Scalar>::Real& prec = NumTraits<Scalar>::dummy_precision()) const
644 { return m_matrix.isApprox(other.m_matrix, prec); }
645
648 EIGEN_DEVICE_FUNC void makeAffine()
649 {
650 internal::transform_make_affine<int(Mode)>::run(m_matrix);
651 }
652
657 EIGEN_DEVICE_FUNC inline Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,Dim> linearExt()
658 { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
663 EIGEN_DEVICE_FUNC inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,Dim> linearExt() const
664 { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,Dim>(0,0); }
665
670 EIGEN_DEVICE_FUNC inline Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt()
671 { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
676 EIGEN_DEVICE_FUNC inline const Block<MatrixType,int(Mode)==int(Projective)?HDim:Dim,1> translationExt() const
677 { return m_matrix.template block<int(Mode)==int(Projective)?HDim:Dim,1>(0,Dim); }
678
679
680 #ifdef EIGEN_TRANSFORM_PLUGIN
681 #include EIGEN_TRANSFORM_PLUGIN
682 #endif
683
684protected:
685 #ifndef EIGEN_PARSED_BY_DOXYGEN
686 EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void check_template_params()
687 {
688 EIGEN_STATIC_ASSERT((Options & (DontAlign|RowMajor)) == Options, INVALID_MATRIX_TEMPLATE_PARAMETERS)
689 }
690 #endif
691
692};
693
695typedef Transform<float,2,Isometry> Isometry2f;
697typedef Transform<float,3,Isometry> Isometry3f;
699typedef Transform<double,2,Isometry> Isometry2d;
701typedef Transform<double,3,Isometry> Isometry3d;
702
704typedef Transform<float,2,Affine> Affine2f;
706typedef Transform<float,3,Affine> Affine3f;
708typedef Transform<double,2,Affine> Affine2d;
710typedef Transform<double,3,Affine> Affine3d;
711
713typedef Transform<float,2,AffineCompact> AffineCompact2f;
715typedef Transform<float,3,AffineCompact> AffineCompact3f;
717typedef Transform<double,2,AffineCompact> AffineCompact2d;
719typedef Transform<double,3,AffineCompact> AffineCompact3d;
720
722typedef Transform<float,2,Projective> Projective2f;
724typedef Transform<float,3,Projective> Projective3f;
726typedef Transform<double,2,Projective> Projective2d;
728typedef Transform<double,3,Projective> Projective3d;
729
730/**************************
731*** Optional QT support ***
732**************************/
733
734#ifdef EIGEN_QT_SUPPORT
739template<typename Scalar, int Dim, int Mode,int Options>
740Transform<Scalar,Dim,Mode,Options>::Transform(const QMatrix& other)
741{
742 check_template_params();
743 *this = other;
744}
745
750template<typename Scalar, int Dim, int Mode,int Options>
751Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(const QMatrix& other)
752{
753 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
754 if (EIGEN_CONST_CONDITIONAL(Mode == int(AffineCompact)))
755 m_matrix << other.m11(), other.m21(), other.dx(),
756 other.m12(), other.m22(), other.dy();
757 else
758 m_matrix << other.m11(), other.m21(), other.dx(),
759 other.m12(), other.m22(), other.dy(),
760 0, 0, 1;
761 return *this;
762}
763
770template<typename Scalar, int Dim, int Mode, int Options>
771QMatrix Transform<Scalar,Dim,Mode,Options>::toQMatrix(void) const
772{
773 check_template_params();
774 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
775 return QMatrix(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
776 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
777 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
778}
779
784template<typename Scalar, int Dim, int Mode,int Options>
785Transform<Scalar,Dim,Mode,Options>::Transform(const QTransform& other)
786{
787 check_template_params();
788 *this = other;
789}
790
795template<typename Scalar, int Dim, int Mode, int Options>
796Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(const QTransform& other)
797{
798 check_template_params();
799 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
800 if (EIGEN_CONST_CONDITIONAL(Mode == int(AffineCompact)))
801 m_matrix << other.m11(), other.m21(), other.dx(),
802 other.m12(), other.m22(), other.dy();
803 else
804 m_matrix << other.m11(), other.m21(), other.dx(),
805 other.m12(), other.m22(), other.dy(),
806 other.m13(), other.m23(), other.m33();
807 return *this;
808}
809
814template<typename Scalar, int Dim, int Mode, int Options>
815QTransform Transform<Scalar,Dim,Mode,Options>::toQTransform(void) const
816{
817 EIGEN_STATIC_ASSERT(Dim==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
818 if (EIGEN_CONST_CONDITIONAL(Mode == int(AffineCompact)))
819 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0),
820 m_matrix.coeff(0,1), m_matrix.coeff(1,1),
821 m_matrix.coeff(0,2), m_matrix.coeff(1,2));
822 else
823 return QTransform(m_matrix.coeff(0,0), m_matrix.coeff(1,0), m_matrix.coeff(2,0),
824 m_matrix.coeff(0,1), m_matrix.coeff(1,1), m_matrix.coeff(2,1),
825 m_matrix.coeff(0,2), m_matrix.coeff(1,2), m_matrix.coeff(2,2));
826}
827#endif
828
829/*********************
830*** Procedural API ***
831*********************/
832
837template<typename Scalar, int Dim, int Mode, int Options>
838template<typename OtherDerived>
839EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&
841{
842 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
843 EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
844 linearExt().noalias() = (linearExt() * other.asDiagonal());
845 return *this;
846}
847
852template<typename Scalar, int Dim, int Mode, int Options>
854{
855 EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
856 linearExt() *= s;
857 return *this;
858}
859
864template<typename Scalar, int Dim, int Mode, int Options>
865template<typename OtherDerived>
866EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&
868{
869 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
870 EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
871 affine().noalias() = (other.asDiagonal() * affine());
872 return *this;
873}
874
879template<typename Scalar, int Dim, int Mode, int Options>
881{
882 EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
883 m_matrix.template topRows<Dim>() *= s;
884 return *this;
885}
886
891template<typename Scalar, int Dim, int Mode, int Options>
892template<typename OtherDerived>
893EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&
895{
896 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
897 translationExt() += linearExt() * other;
898 return *this;
899}
900
905template<typename Scalar, int Dim, int Mode, int Options>
906template<typename OtherDerived>
907EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&
909{
910 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,int(Dim))
911 if(EIGEN_CONST_CONDITIONAL(int(Mode)==int(Projective)))
912 affine() += other * m_matrix.row(Dim);
913 else
914 translation() += other;
915 return *this;
916}
917
935template<typename Scalar, int Dim, int Mode, int Options>
936template<typename RotationType>
937EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&
939{
940 linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
941 return *this;
942}
943
951template<typename Scalar, int Dim, int Mode, int Options>
952template<typename RotationType>
953EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&
955{
956 m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
957 * m_matrix.template block<Dim,HDim>(0,0);
958 return *this;
959}
960
966template<typename Scalar, int Dim, int Mode, int Options>
967EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&
969{
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 VectorType tmp = linear().col(0)*sy + linear().col(1);
973 linear() << linear().col(0) + linear().col(1)*sx, tmp;
974 return *this;
975}
976
982template<typename Scalar, int Dim, int Mode, int Options>
983EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&
985{
986 EIGEN_STATIC_ASSERT(int(Dim)==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
987 EIGEN_STATIC_ASSERT(Mode!=int(Isometry), THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS)
988 LinearMatrixType shear = LinearMatrixType::Identity(2, 2);
989 shear.coeffRef(0, 1) = sy;
990 shear.coeffRef(1, 0) = sx;
991 m_matrix.template block<Dim, HDim>(0, 0) = shear * m_matrix.template block<Dim, HDim>(0, 0);
992 return *this;
993}
994
995/******************************************************
996*** Scaling, Translation and Rotation compatibility ***
997******************************************************/
998
999template<typename Scalar, int Dim, int Mode, int Options>
1000EIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(const TranslationType& t)
1001{
1002 linear().setIdentity();
1003 translation() = t.vector();
1004 makeAffine();
1005 return *this;
1006}
1007
1008template<typename Scalar, int Dim, int Mode, int Options>
1009EIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options> Transform<Scalar,Dim,Mode,Options>::operator*(const TranslationType& t) const
1010{
1011 Transform res = *this;
1012 res.translate(t.vector());
1013 return res;
1014}
1015
1016template<typename Scalar, int Dim, int Mode, int Options>
1017EIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(const UniformScaling<Scalar>& s)
1018{
1019 m_matrix.setZero();
1020 linear().diagonal().fill(s.factor());
1021 makeAffine();
1022 return *this;
1023}
1024
1025template<typename Scalar, int Dim, int Mode, int Options>
1026template<typename Derived>
1027EIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options>& Transform<Scalar,Dim,Mode,Options>::operator=(const RotationBase<Derived,Dim>& r)
1028{
1029 linear() = internal::toRotationMatrix<Scalar,Dim>(r);
1030 translation().setZero();
1031 makeAffine();
1032 return *this;
1033}
1034
1035template<typename Scalar, int Dim, int Mode, int Options>
1036template<typename Derived>
1037EIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options> Transform<Scalar,Dim,Mode,Options>::operator*(const RotationBase<Derived,Dim>& r) const
1038{
1039 Transform res = *this;
1040 res.rotate(r.derived());
1041 return res;
1042}
1043
1044/************************
1045*** Special functions ***
1046************************/
1047
1048namespace internal {
1049template<int Mode> struct transform_rotation_impl {
1050 template<typename TransformType>
1051 EIGEN_DEVICE_FUNC static inline
1052 const typename TransformType::LinearMatrixType run(const TransformType& t)
1053 {
1054 typedef typename TransformType::LinearMatrixType LinearMatrixType;
1055 LinearMatrixType result;
1056 t.computeRotationScaling(&result, (LinearMatrixType*)0);
1057 return result;
1058 }
1059};
1061 template<typename TransformType>
1062 EIGEN_DEVICE_FUNC static inline
1063 typename TransformType::ConstLinearPart run(const TransformType& t)
1064 {
1065 return t.linear();
1066 }
1067};
1068}
1079template<typename Scalar, int Dim, int Mode, int Options>
1080EIGEN_DEVICE_FUNC
1086
1087
1099template<typename Scalar, int Dim, int Mode, int Options>
1100template<typename RotationMatrixType, typename ScalingMatrixType>
1101EIGEN_DEVICE_FUNC void Transform<Scalar,Dim,Mode,Options>::computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const
1102{
1103 // Note that JacobiSVD is faster than BDCSVD for small matrices.
1105
1106 Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant() < Scalar(0) ? Scalar(-1) : Scalar(1); // so x has absolute value 1
1107 VectorType sv(svd.singularValues());
1108 sv.coeffRef(Dim-1) *= x;
1109 if(scaling) *scaling = svd.matrixV() * sv.asDiagonal() * svd.matrixV().adjoint();
1110 if(rotation)
1111 {
1112 LinearMatrixType m(svd.matrixU());
1113 m.col(Dim-1) *= x;
1114 *rotation = m * svd.matrixV().adjoint();
1115 }
1116}
1117
1129template<typename Scalar, int Dim, int Mode, int Options>
1130template<typename ScalingMatrixType, typename RotationMatrixType>
1131EIGEN_DEVICE_FUNC void Transform<Scalar,Dim,Mode,Options>::computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const
1132{
1133 // Note that JacobiSVD is faster than BDCSVD for small matrices.
1135
1136 Scalar x = (svd.matrixU() * svd.matrixV().adjoint()).determinant() < Scalar(0) ? Scalar(-1) : Scalar(1); // so x has absolute value 1
1137 VectorType sv(svd.singularValues());
1138 sv.coeffRef(Dim-1) *= x;
1139 if(scaling) *scaling = svd.matrixU() * sv.asDiagonal() * svd.matrixU().adjoint();
1140 if(rotation)
1141 {
1142 LinearMatrixType m(svd.matrixU());
1143 m.col(Dim-1) *= x;
1144 *rotation = m * svd.matrixV().adjoint();
1145 }
1146}
1147
1151template<typename Scalar, int Dim, int Mode, int Options>
1152template<typename PositionDerived, typename OrientationType, typename ScaleDerived>
1153EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>&
1156{
1157 linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
1158 linear() *= scale.asDiagonal();
1159 translation() = position;
1160 makeAffine();
1161 return *this;
1162}
1163
1164namespace internal {
1165
1166template<int Mode>
1168{
1169 template<typename MatrixType>
1170 EIGEN_DEVICE_FUNC static void run(MatrixType &mat)
1171 {
1172 static const int Dim = MatrixType::ColsAtCompileTime-1;
1173 mat.template block<1,Dim>(Dim,0).setZero();
1174 mat.coeffRef(Dim,Dim) = typename MatrixType::Scalar(1);
1175 }
1176};
1177
1178template<>
1180{
1181 template<typename MatrixType> EIGEN_DEVICE_FUNC static void run(MatrixType &) { }
1182};
1183
1184// selector needed to avoid taking the inverse of a 3x4 matrix
1185template<typename TransformType, int Mode=TransformType::Mode>
1187{
1188 EIGEN_DEVICE_FUNC static inline void run(const TransformType&, TransformType&)
1189 {}
1190};
1191
1192template<typename TransformType>
1194{
1195 EIGEN_DEVICE_FUNC static inline void run(const TransformType& m, TransformType& res)
1196 {
1197 res.matrix() = m.matrix().inverse();
1198 }
1199};
1200
1201} // end namespace internal
1202
1203
1224template<typename Scalar, int Dim, int Mode, int Options>
1225EIGEN_DEVICE_FUNC Transform<Scalar,Dim,Mode,Options>
1227{
1228 Transform res;
1229 if (hint == Projective)
1230 {
1232 }
1233 else
1234 {
1235 if (hint == Isometry)
1236 {
1237 res.matrix().template topLeftCorner<Dim,Dim>() = linear().transpose();
1238 }
1239 else if(hint&Affine)
1240 {
1241 res.matrix().template topLeftCorner<Dim,Dim>() = linear().inverse();
1242 }
1243 else
1244 {
1245 eigen_assert(false && "Invalid transform traits in Transform::Inverse");
1246 }
1247 // translation and remaining parts
1248 res.matrix().template topRightCorner<Dim,1>()
1249 = - res.matrix().template topLeftCorner<Dim,Dim>() * translation();
1250 res.makeAffine(); // we do need this, because in the beginning res is uninitialized
1251 }
1252 return res;
1253}
1254
1255namespace internal {
1256
1257/*****************************************************
1258*** Specializations of take affine part ***
1259*****************************************************/
1260
1261template<typename TransformType> struct transform_take_affine_part {
1262 typedef typename TransformType::MatrixType MatrixType;
1263 typedef typename TransformType::AffinePart AffinePart;
1264 typedef typename TransformType::ConstAffinePart ConstAffinePart;
1265 static inline AffinePart run(MatrixType& m)
1266 { return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1267 static inline ConstAffinePart run(const MatrixType& m)
1268 { return m.template block<TransformType::Dim,TransformType::HDim>(0,0); }
1269};
1270
1271template<typename Scalar, int Dim, int Options>
1274 static inline MatrixType& run(MatrixType& m) { return m; }
1275 static inline const MatrixType& run(const MatrixType& m) { return m; }
1276};
1277
1278/*****************************************************
1279*** Specializations of construct from matrix ***
1280*****************************************************/
1281
1282template<typename Other, int Mode, int Options, int Dim, int HDim>
1283struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,Dim>
1284{
1285 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform, const Other& other)
1286 {
1287 transform->linear() = other;
1288 transform->translation().setZero();
1289 transform->makeAffine();
1290 }
1291};
1292
1293template<typename Other, int Mode, int Options, int Dim, int HDim>
1294struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, Dim,HDim>
1295{
1296 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform, const Other& other)
1297 {
1298 transform->affine() = other;
1299 transform->makeAffine();
1300 }
1301};
1302
1303template<typename Other, int Mode, int Options, int Dim, int HDim>
1304struct transform_construct_from_matrix<Other, Mode,Options,Dim,HDim, HDim,HDim>
1305{
1306 static inline void run(Transform<typename Other::Scalar,Dim,Mode,Options> *transform, const Other& other)
1307 { transform->matrix() = other; }
1308};
1309
1310template<typename Other, int Options, int Dim, int HDim>
1311struct transform_construct_from_matrix<Other, AffineCompact,Options,Dim,HDim, HDim,HDim>
1312{
1313 static inline void run(Transform<typename Other::Scalar,Dim,AffineCompact,Options> *transform, const Other& other)
1314 { transform->matrix() = other.template block<Dim,HDim>(0,0); }
1315};
1316
1317/**********************************************************
1318*** Specializations of operator* with rhs EigenBase ***
1319**********************************************************/
1320
1321template<int LhsMode,int RhsMode>
1323{
1324 enum
1325 {
1326 Mode =
1327 (LhsMode == (int)Projective || RhsMode == (int)Projective ) ? Projective :
1328 (LhsMode == (int)Affine || RhsMode == (int)Affine ) ? Affine :
1329 (LhsMode == (int)AffineCompact || RhsMode == (int)AffineCompact ) ? AffineCompact :
1330 (LhsMode == (int)Isometry || RhsMode == (int)Isometry ) ? Isometry : Projective
1331 };
1332};
1333
1334template< typename TransformType, typename MatrixType, int RhsCols>
1335struct transform_right_product_impl< TransformType, MatrixType, 0, RhsCols>
1336{
1337 typedef typename MatrixType::PlainObject ResultType;
1338
1339 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)
1340 {
1341 return T.matrix() * other;
1342 }
1343};
1344
1345template< typename TransformType, typename MatrixType, int RhsCols>
1346struct transform_right_product_impl< TransformType, MatrixType, 1, RhsCols>
1347{
1348 enum {
1349 Dim = TransformType::Dim,
1350 HDim = TransformType::HDim,
1351 OtherRows = MatrixType::RowsAtCompileTime,
1352 OtherCols = MatrixType::ColsAtCompileTime
1353 };
1354
1355 typedef typename MatrixType::PlainObject ResultType;
1356
1357 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)
1358 {
1359 EIGEN_STATIC_ASSERT(OtherRows==HDim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1360
1361 typedef Block<ResultType, Dim, OtherCols, int(MatrixType::RowsAtCompileTime)==Dim> TopLeftLhs;
1362
1363 ResultType res(other.rows(),other.cols());
1364 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() = T.affine() * other;
1365 res.row(OtherRows-1) = other.row(OtherRows-1);
1366
1367 return res;
1368 }
1369};
1370
1371template< typename TransformType, typename MatrixType, int RhsCols>
1372struct transform_right_product_impl< TransformType, MatrixType, 2, RhsCols>
1373{
1374 enum {
1375 Dim = TransformType::Dim,
1376 HDim = TransformType::HDim,
1377 OtherRows = MatrixType::RowsAtCompileTime,
1378 OtherCols = MatrixType::ColsAtCompileTime
1379 };
1380
1381 typedef typename MatrixType::PlainObject ResultType;
1382
1383 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)
1384 {
1385 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1386
1388 ResultType res(Replicate<typename TransformType::ConstTranslationPart, 1, OtherCols>(T.translation(),1,other.cols()));
1389 TopLeftLhs(res, 0, 0, Dim, other.cols()).noalias() += T.linear() * other;
1390
1391 return res;
1392 }
1393};
1394
1395template< typename TransformType, typename MatrixType >
1396struct transform_right_product_impl< TransformType, MatrixType, 2, 1> // rhs is a vector of size Dim
1397{
1398 typedef typename TransformType::MatrixType TransformMatrix;
1399 enum {
1400 Dim = TransformType::Dim,
1401 HDim = TransformType::HDim,
1402 OtherRows = MatrixType::RowsAtCompileTime,
1403 WorkingRows = EIGEN_PLAIN_ENUM_MIN(TransformMatrix::RowsAtCompileTime,HDim)
1404 };
1405
1406 typedef typename MatrixType::PlainObject ResultType;
1407
1408 static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ResultType run(const TransformType& T, const MatrixType& other)
1409 {
1410 EIGEN_STATIC_ASSERT(OtherRows==Dim, YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES);
1411
1413 rhs.template head<Dim>() = other; rhs[Dim] = typename ResultType::Scalar(1);
1415 return res.template head<Dim>();
1416 }
1417};
1418
1419/**********************************************************
1420*** Specializations of operator* with lhs EigenBase ***
1421**********************************************************/
1422
1423// generic HDim x HDim matrix * T => Projective
1424template<typename Other,int Mode, int Options, int Dim, int HDim>
1425struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, HDim,HDim>
1426{
1428 typedef typename TransformType::MatrixType MatrixType;
1430 static ResultType run(const Other& other,const TransformType& tr)
1431 { return ResultType(other * tr.matrix()); }
1432};
1433
1434// generic HDim x HDim matrix * AffineCompact => Projective
1435template<typename Other, int Options, int Dim, int HDim>
1436struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, HDim,HDim>
1437{
1439 typedef typename TransformType::MatrixType MatrixType;
1441 static ResultType run(const Other& other,const TransformType& tr)
1442 {
1443 ResultType res;
1444 res.matrix().noalias() = other.template block<HDim,Dim>(0,0) * tr.matrix();
1445 res.matrix().col(Dim) += other.col(Dim);
1446 return res;
1447 }
1448};
1449
1450// affine matrix * T
1451template<typename Other,int Mode, int Options, int Dim, int HDim>
1452struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,HDim>
1453{
1455 typedef typename TransformType::MatrixType MatrixType;
1456 typedef TransformType ResultType;
1457 static ResultType run(const Other& other,const TransformType& tr)
1458 {
1459 ResultType res;
1460 res.affine().noalias() = other * tr.matrix();
1461 res.matrix().row(Dim) = tr.matrix().row(Dim);
1462 return res;
1463 }
1464};
1465
1466// affine matrix * AffineCompact
1467template<typename Other, int Options, int Dim, int HDim>
1468struct transform_left_product_impl<Other,AffineCompact,Options,Dim,HDim, Dim,HDim>
1469{
1471 typedef typename TransformType::MatrixType MatrixType;
1472 typedef TransformType ResultType;
1473 static ResultType run(const Other& other,const TransformType& tr)
1474 {
1475 ResultType res;
1476 res.matrix().noalias() = other.template block<Dim,Dim>(0,0) * tr.matrix();
1477 res.translation() += other.col(Dim);
1478 return res;
1479 }
1480};
1481
1482// linear matrix * T
1483template<typename Other,int Mode, int Options, int Dim, int HDim>
1484struct transform_left_product_impl<Other,Mode,Options,Dim,HDim, Dim,Dim>
1485{
1487 typedef typename TransformType::MatrixType MatrixType;
1488 typedef TransformType ResultType;
1489 static ResultType run(const Other& other, const TransformType& tr)
1490 {
1491 TransformType res;
1492 if(Mode!=int(AffineCompact))
1493 res.matrix().row(Dim) = tr.matrix().row(Dim);
1494 res.matrix().template topRows<Dim>().noalias()
1495 = other * tr.matrix().template topRows<Dim>();
1496 return res;
1497 }
1498};
1499
1500/**********************************************************
1501*** Specializations of operator* with another Transform ***
1502**********************************************************/
1503
1504template<typename Scalar, int Dim, int LhsMode, int LhsOptions, int RhsMode, int RhsOptions>
1506{
1511 static ResultType run(const Lhs& lhs, const Rhs& rhs)
1512 {
1513 ResultType res;
1514 res.linear() = lhs.linear() * rhs.linear();
1515 res.translation() = lhs.linear() * rhs.translation() + lhs.translation();
1516 res.makeAffine();
1517 return res;
1518 }
1519};
1520
1521template<typename Scalar, int Dim, int LhsMode, int LhsOptions, int RhsMode, int RhsOptions>
1523{
1527 static ResultType run(const Lhs& lhs, const Rhs& rhs)
1528 {
1529 return ResultType( lhs.matrix() * rhs.matrix() );
1530 }
1531};
1532
1533template<typename Scalar, int Dim, int LhsOptions, int RhsOptions>
1535{
1539 static ResultType run(const Lhs& lhs, const Rhs& rhs)
1540 {
1541 ResultType res;
1542 res.matrix().template topRows<Dim>() = lhs.matrix() * rhs.matrix();
1543 res.matrix().row(Dim) = rhs.matrix().row(Dim);
1544 return res;
1545 }
1546};
1547
1548template<typename Scalar, int Dim, int LhsOptions, int RhsOptions>
1550{
1554 static ResultType run(const Lhs& lhs, const Rhs& rhs)
1555 {
1556 ResultType res(lhs.matrix().template leftCols<Dim>() * rhs.matrix());
1557 res.matrix().col(Dim) += lhs.matrix().col(Dim);
1558 return res;
1559 }
1560};
1561
1562} // end namespace internal
1563
1564} // end namespace Eigen
1565
1566#endif // EIGEN_TRANSFORM_H
Expression of a fixed-size or dynamic-size block.
Definition Block.h:105
EIGEN_DEVICE_FUNC Derived & setZero()
Sets all coefficients in this expression to zero.
Definition CwiseNullaryOp.h:546
EIGEN_DEVICE_FUNC TransposeReturnType transpose()
Definition Transpose.h:182
EIGEN_DEVICE_FUNC bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition Fuzzy.h:103
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:50
EIGEN_DEVICE_FUNC const DiagonalWrapper< const Derived > asDiagonal() const
Definition DiagonalMatrix.h:325
static EIGEN_DEVICE_FUNC const IdentityReturnType Identity()
Definition CwiseNullaryOp.h:799
EIGEN_DEVICE_FUNC const AdjointReturnType adjoint() const
Definition Transpose.h:221
NoAlias< Derived, Eigen::MatrixBase > EIGEN_DEVICE_FUNC noalias()
Definition NoAlias.h:102
EIGEN_DEVICE_FUNC Scalar determinant() const
\lu_module
Definition Determinant.h:108
EIGEN_DEVICE_FUNC const Inverse< Derived > inverse() const
\lu_module
Definition InverseImpl.h:348
EIGEN_DEVICE_FUNC Derived & setIdentity()
Writes the identity expression (not necessarily square) into *this.
Definition CwiseNullaryOp.h:873
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
This is an overloaded version of DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index,...
Definition PlainObjectBase.h:175
\geometry_module
Definition Transform.h:205
EIGEN_DEVICE_FUNC MatrixType & matrix()
Definition Transform.h:391
EIGEN_DEVICE_FUNC void makeAffine()
Sets the last row to [0 ... 0 1].
Definition Transform.h:648
EIGEN_DEVICE_FUNC Transform inverse(TransformTraits traits=(TransformTraits) Mode) const
Definition Transform.h:1226
Block< MatrixType, Dim, Dim, int(Mode)==(AffineCompact) &&(int(Options)&RowMajor)==0 > LinearPart
type of read/write reference to the linear part of the transformation
Definition Transform.h:226
EIGEN_DEVICE_FUNC Transform & preshear(const Scalar &sx, const Scalar &sy)
Applies on the left the shear transformation represented by the vector other to *this and returns a r...
Definition Transform.h:984
EIGEN_DEVICE_FUNC Transform & shear(const Scalar &sx, const Scalar &sy)
Applies on the right the shear transformation represented by the vector other to *this and returns a ...
Definition Transform.h:968
EIGEN_DEVICE_FUNC Transform(const Transform< OtherScalarType, Dim, Mode, Options > &other)
Copy constructor with scalar type conversion.
Definition Transform.h:633
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar, _Dim==Dynamic ? Dynamic :(_Dim+1) *(_Dim+1)) enum
Definition Transform.h:207
internal::make_proper_matrix_type< Scalar, Rows, HDim, Options >::type MatrixType
type of the matrix used to represent the transformation
Definition Transform.h:220
const Block< ConstMatrixType, Dim, 1,!(internal::traits< MatrixType >::Flags &RowMajorBit)> ConstTranslationPart
type of a read reference to the translation part of the rotation
Definition Transform.h:242
static EIGEN_DEVICE_FUNC const Transform Identity()
Returns an identity transformation.
Definition Transform.h:533
EIGEN_DEVICE_FUNC Scalar * data()
Definition Transform.h:620
Matrix< Scalar, Dim, Dim, Options > LinearMatrixType
type of the matrix used to represent the linear part of the transformation
Definition Transform.h:224
Eigen::Index Index
Definition Transform.h:218
_Scalar Scalar
the scalar type of the coefficients
Definition Transform.h:216
EIGEN_DEVICE_FUNC void setIdentity()
Definition Transform.h:527
Transform< Scalar, Dim, TransformTimeDiagonalMode > TransformTimeDiagonalReturnType
The return type of the product between a diagonal matrix and a transform.
Definition Transform.h:249
EIGEN_DEVICE_FUNC ConstLinearPart linear() const
Definition Transform.h:394
EIGEN_DEVICE_FUNC LinearPart linear()
Definition Transform.h:396
EIGEN_DEVICE_FUNC Transform(const EigenBase< OtherDerived > &other)
Constructs and initializes a transformation from a Dim^2 or a (Dim+1)^2 matrix.
Definition Transform.h:286
internal::conditional< int(Mode)==int(AffineCompact), MatrixType &, Block< MatrixType, Dim, HDim > >::type AffinePart
type of read/write reference to the affine part of the transformation
Definition Transform.h:232
EIGEN_DEVICE_FUNC RotationReturnType rotation() const
Definition Transform.h:1082
Translation< Scalar, Dim > TranslationType
corresponding translation type
Definition Transform.h:244
internal::conditional< int(Mode)==int(AffineCompact), constMatrixType &, constBlock< constMatrixType, Dim, HDim > >::type ConstAffinePart
type of read reference to the affine part of the transformation
Definition Transform.h:236
EIGEN_DEVICE_FUNC internal::cast_return_type< Transform, Transform< NewScalarType, Dim, Mode, Options > >::type cast() const
Definition Transform.h:628
const Block< ConstMatrixType, Dim, Dim, int(Mode)==(AffineCompact) &&(int(Options)&RowMajor)==0 > ConstLinearPart
type of read reference to the linear part of the transformation
Definition Transform.h:228
EIGEN_DEVICE_FUNC AffinePart affine()
Definition Transform.h:401
EIGEN_DEVICE_FUNC Transform & operator=(const EigenBase< OtherDerived > &other)
Set *this from a Dim^2 or (Dim+1)^2 matrix.
Definition Transform.h:297
EIGEN_DEVICE_FUNC Transform()
Default constructor without initialization of the meaningful coefficients.
Definition Transform.h:259
EIGEN_DEVICE_FUNC ConstAffinePart affine() const
Definition Transform.h:399
EIGEN_DEVICE_FUNC void computeScalingRotation(ScalingMatrixType *scaling, RotationMatrixType *rotation) const
decomposes the linear part of the transformation as a product scaling x rotation, the scaling being n...
Definition Transform.h:1131
EIGEN_DEVICE_FUNC const MatrixType & matrix() const
Definition Transform.h:389
EIGEN_DEVICE_FUNC Scalar operator()(Index row, Index col) const
shortcut for m_matrix(row,col);
Definition Transform.h:383
EIGEN_DEVICE_FUNC bool isApprox(const Transform &other, const typename NumTraits< Scalar >::Real &prec=NumTraits< Scalar >::dummy_precision()) const
Definition Transform.h:643
Block< MatrixType, Dim, 1,!(internal::traits< MatrixType >::Flags &RowMajorBit)> TranslationPart
type of a read/write reference to the translation part of the rotation
Definition Transform.h:240
Matrix< Scalar, Dim, 1 > VectorType
type of a vector
Definition Transform.h:238
friend EIGEN_DEVICE_FUNC const internal::transform_left_product_impl< OtherDerived, Mode, Options, _Dim, _Dim+1 >::ResultType operator*(const EigenBase< OtherDerived > &a, const Transform &b)
Definition Transform.h:447
EIGEN_DEVICE_FUNC TranslationPart translation()
Definition Transform.h:406
const MatrixType ConstMatrixType
constified MatrixType
Definition Transform.h:222
EIGEN_DEVICE_FUNC const Scalar * data() const
Definition Transform.h:618
EIGEN_DEVICE_FUNC ConstTranslationPart translation() const
Definition Transform.h:404
EIGEN_DEVICE_FUNC void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const
decomposes the linear part of the transformation as a product rotation x scaling, the scaling being n...
Definition Transform.h:1101
Definition svm.cpp:197
TransformTraits
Enum used to specify how a particular transformation is stored in a matrix.
Definition Constants.h:455
@ DontAlign
Don't require alignment for the matrix itself (the array of coefficients, if dynamically allocated,...
Definition Constants.h:325
@ RowMajor
Storage order is row major (see TopicStorageOrders).
Definition Constants.h:321
@ ComputeFullV
Used in JacobiSVD to indicate that the square matrix V is to be computed.
Definition Constants.h:397
@ ComputeFullU
Used in JacobiSVD to indicate that the square matrix U is to be computed.
Definition Constants.h:393
@ Affine
Transformation is an affine transformation stored as a (Dim+1)^2 matrix whose last row is assumed to ...
Definition Constants.h:460
@ Projective
Transformation is a general projective transformation stored as a (Dim+1)^2 matrix.
Definition Constants.h:464
@ AffineCompact
Transformation is an affine transformation stored as a (Dim) x (Dim+1) matrix.
Definition Constants.h:462
@ Isometry
Transformation is an isometry.
Definition Constants.h:457
const unsigned int RowMajorBit
for a matrix, this means that the storage order is row-major.
Definition Constants.h:66
Namespace containing all symbols from the Eigen library.
Definition LDLT.h:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:74
const int Dynamic
This value means that a positive quantity (e.g., a size) is not known at compile-time,...
Definition Constants.h:22
The type used to identify a dense storage.
Definition Constants.h:507
Holds information about the various numeric (i.e.
Definition NumTraits.h:236
Definition XprHelper.h:510
Definition Meta.h:109
Definition Meta.h:151
Definition ForwardDeclarations.h:17
Definition Transform.h:1168
Definition Transform.h:1049
Definition Transform.h:21
Definition Meta.h:96