diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2008-08-24 21:36:14 +0000 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2008-08-24 21:36:14 +0000 |
commit | aa54d6bef0be9b769aa974a7d3a86d85c5d11885 (patch) | |
tree | 4831b8350045058994e36c7c46574345fe1709e6 /Eigen | |
parent | 124ec71c50b8a5dd8e2ebd3590e067367d1040a5 (diff) |
arf, of course a meta-selector was required here
Diffstat (limited to 'Eigen')
-rw-r--r-- | Eigen/src/Geometry/Transform.h | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 65d52b51d..4645083b3 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -89,18 +89,31 @@ public: inline Transform& operator=(const Transform& other) { m_matrix = other.m_matrix; return *this; } + template<typename OtherDerived, bool select = OtherDerived::RowsAtCompileTime == Dim> + struct construct_from_matrix + { + static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other) + { + transform->matrix() = other; + } + }; + + template<typename OtherDerived> struct construct_from_matrix<OtherDerived, true> + { + static inline void run(Transform *transform, const MatrixBase<OtherDerived>& other) + { + transform->linear() = other; + transform->translation().setZero(); + transform->matrix()(Dim,Dim) = Scalar(1); + transform->matrix().template block<1,Dim>(Dim,0).setZero(); + } + }; + /** Constructs and initializes a transformation from a Dim^2 or a (Dim+1)^2 matrix. */ template<typename OtherDerived> inline explicit Transform(const MatrixBase<OtherDerived>& other) { - if(OtherDerived::RowsAtCompileTime == Dim) - { - linear() = other; - translation().setZero(); - m_matrix(Dim,Dim) = Scalar(1); - m_matrix.template block<1,Dim>(Dim,0).setZero(); - } - else m_matrix = other; + construct_from_matrix<OtherDerived>::run(this, other); } /** Set \c *this from a (Dim+1)^2 matrix. */ |