From 60eb470c6cb923f4493f243a0d6ff15052b3e011 Mon Sep 17 00:00:00 2001 From: cnr-isti-vclab Date: Wed, 29 Oct 2008 15:52:07 +0000 Subject: [PATCH] of course fixing msvc breaked gcc... not anymore... spoke too fast gcc 4.0.1 had troubles --- vcg/math/matrix44.h | 68 +++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 48 deletions(-) diff --git a/vcg/math/matrix44.h b/vcg/math/matrix44.h index e571fafb..5f0be2f0 100644 --- a/vcg/math/matrix44.h +++ b/vcg/math/matrix44.h @@ -149,43 +149,15 @@ public: /** taken from Eigen::Transform * \returns the product between the transform \c *this and a matrix expression \a other - * - * The right hand side \a other might be either: - * \li a matrix expression with 4 rows - * \li a 3D vector/point - */ - // note: this function is defined here because some compilers cannot find the respective declaration - template - inline const typename ei_matrix44_product_impl::ResultType - operator * (const Eigen::MatrixBase &other) const - { return ei_matrix44_product_impl::run(*this,other.derived()); } - - /** Contatenates two transformations */ - inline const typename Eigen::ProductReturnType::Type - operator * (const Matrix44& other) const - { return (*this) * other; } - -// template Point3 operator*(const Point3 &p) { -// T w; -// Point3 s; -// s[0] = m.ElementAt(0, 0)*p[0] + m.ElementAt(0, 1)*p[1] + m.ElementAt(0, 2)*p[2] + m.ElementAt(0, 3); -// s[1] = m.ElementAt(1, 0)*p[0] + m.ElementAt(1, 1)*p[1] + m.ElementAt(1, 2)*p[2] + m.ElementAt(1, 3); -// s[2] = m.ElementAt(2, 0)*p[0] + m.ElementAt(2, 1)*p[1] + m.ElementAt(2, 2)*p[2] + m.ElementAt(2, 3); -// w = m.ElementAt(3, 0)*p[0] + m.ElementAt(3, 1)*p[1] + m.ElementAt(3, 2)*p[2] + m.ElementAt(3, 3); -// if(w!= 0) s /= w; -// return s; -// } - - //Eigen::Matrix operator * (const Eigen::Matrix& p) const { - // Scalar w; - // Eigen::Matrix s; - // s[0] = ElementAt(0, 0)*p[0] + ElementAt(0, 1)*p[1] + ElementAt(0, 2)*p[2] + ElementAt(0, 3); - // s[1] = ElementAt(1, 0)*p[0] + ElementAt(1, 1)*p[1] + ElementAt(1, 2)*p[2] + ElementAt(1, 3); - // s[2] = ElementAt(2, 0)*p[0] + ElementAt(2, 1)*p[1] + ElementAt(2, 2)*p[2] + ElementAt(2, 3); - // w = ElementAt(3, 0)*p[0] + ElementAt(3, 1)*p[1] + ElementAt(3, 2)*p[2] + ElementAt(3, 3); - // if(w!= 0) s /= w; - // return s; - //} + * + * The right hand side \a other might be either: + * \li a matrix expression with 4 rows + * \li a 3D vector/point + */ + template + inline const typename ei_matrix44_product_impl::ResultType + operator * (const Eigen::MatrixBase &other) const + { return ei_matrix44_product_impl::run(*this,other.derived()); } void print() {std::cout << *this << "\n\n";} @@ -491,28 +463,28 @@ template Matrix44 Inverse(const Matrix44 &m) { template struct ei_matrix44_product_impl { - typedef typename Other::Scalar Scalar; - typedef typename Eigen::ProductReturnType,Other>::Type ResultType; - static ResultType run(const Matrix44& tr, const Other& other) - { return tr * other; } + typedef typename Other::Scalar Scalar; + typedef typename Eigen::ProductReturnType,Other>::Type ResultType; + static ResultType run(const Matrix44& tr, const Other& other) + { return tr * other; } }; template struct ei_matrix44_product_impl { - typedef typename Other::Scalar Scalar; - typedef Eigen::Matrix ResultType; - static ResultType run(const Matrix44& tr, const Other& p) - { - Scalar w; + typedef typename Other::Scalar Scalar; + typedef Eigen::Matrix ResultType; + static ResultType run(const Matrix44& tr, const Other& p) + { + Scalar w; Eigen::Matrix s; s[0] = tr.ElementAt(0, 0)*p[0] + tr.ElementAt(0, 1)*p[1] + tr.ElementAt(0, 2)*p[2] + tr.ElementAt(0, 3); s[1] = tr.ElementAt(1, 0)*p[0] + tr.ElementAt(1, 1)*p[1] + tr.ElementAt(1, 2)*p[2] + tr.ElementAt(1, 3); s[2] = tr.ElementAt(2, 0)*p[0] + tr.ElementAt(2, 1)*p[1] + tr.ElementAt(2, 2)*p[2] + tr.ElementAt(2, 3); - w = tr.ElementAt(3, 0)*p[0] + tr.ElementAt(3, 1)*p[1] + tr.ElementAt(3, 2)*p[2] + tr.ElementAt(3, 3); + w = tr.ElementAt(3, 0)*p[0] + tr.ElementAt(3, 1)*p[1] + tr.ElementAt(3, 2)*p[2] + tr.ElementAt(3, 3); if(w!= 0) s /= w; return s; - } + } }; } //namespace