From aa54d6bef0be9b769aa974a7d3a86d85c5d11885 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Sun, 24 Aug 2008 21:36:14 +0000 Subject: arf, of course a meta-selector was required here --- Eigen/src/Geometry/Transform.h | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'Eigen') 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 + struct construct_from_matrix + { + static inline void run(Transform *transform, const MatrixBase& other) + { + transform->matrix() = other; + } + }; + + template struct construct_from_matrix + { + static inline void run(Transform *transform, const MatrixBase& 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 inline explicit Transform(const MatrixBase& 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::run(this, other); } /** Set \c *this from a (Dim+1)^2 matrix. */ -- cgit v1.2.3