From dc44ff8265173ab325510a6f1754f70ba0a8b5a8 Mon Sep 17 00:00:00 2001 From: cignoni Date: Tue, 27 Nov 2012 22:49:21 +0000 Subject: [PATCH] Added ComputeSimilarityMatchMatrix (and removed useless printout...) --- vcg/space/point_matching.h | 60 +++++++++++++++----------------------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/vcg/space/point_matching.h b/vcg/space/point_matching.h index 082d53e2..be36aa79 100644 --- a/vcg/space/point_matching.h +++ b/vcg/space/point_matching.h @@ -118,8 +118,8 @@ void ComputeRigidMatchMatrix(std::vector > &Pfix, Eigen::SelfAdjointEigenSolver eig(QQ); Eigen::Vector4d eval = eig.eigenvalues(); Eigen::Matrix4d evec = eig.eigenvectors(); - std::cout << "EigenVectors:" << std::endl << evec << std::endl; - std::cout << "eigenvalues:" << std::endl << eval << std::endl; +// std::cout << "EigenVectors:" << std::endl << evec << std::endl; +// std::cout << "Eigenvalues:" << std::endl << eval << std::endl; int ind; eval.cwiseAbs().maxCoeff(&ind); @@ -143,10 +143,10 @@ void ComputeRigidMatchMatrix(std::vector > &Pfix, * IEEE TPAMI Vol 14, No 2 1992 */ - template < class S > - void ComputeRigidMatchMatrix(std::vector > &Pfix, - std::vector > &Pmov, - Matrix44 &res) +template < class S > +void ComputeRigidMatchMatrix(std::vector > &Pfix, + std::vector > &Pmov, + Matrix44 &res) { Quaternion q; Point3 tr; @@ -162,44 +162,32 @@ void ComputeRigidMatchMatrix(std::vector > &Pfix, } -#if 0 /* Compute a similarity matching (rigid + uniform scaling) simply create a temporary point set with the correct scaling factor */ -static bool ComputeSimilarityMatchMatrix( Matrix44x &res, - std::vector &Pfix, // vertici corrispondenti su fix (rossi) - std::vector &Pmov) // normali scelti su mov (verdi) +template +void ComputeSimilarityMatchMatrix(std::vector > &Pfix, + std::vector > &Pmov, + Matrix44 &res) { - Quaternionx qtmp; - Point3x tr; - - std::vector Pnew(Pmov.size()); - - ScalarType scalingFactor=0; - - for(size_t i=0;i<( Pmov.size()-1);++i) - { - scalingFactor += Distance(Pmov[i],Pmov[i+1])/ Distance(Pfix[i],Pfix[i+1]); -#ifdef _DEBUG - printf("Scaling Factor is %f",scalingFactor/(i+1)); -#endif - } - scalingFactor/=(Pmov.size()-1); + S scalingFactor=0; + for(size_t i=0;i<( Pmov.size()-1);++i) + { + scalingFactor += Distance(Pmov[i],Pmov[i+1])/ Distance(Pfix[i],Pfix[i+1]); + } + scalingFactor/=(Pmov.size()-1); - for(size_t i=0;i > Pnew(Pmov.size()); + for(size_t i=0;i scaleM; scaleM.SetDiagonal(1.0/scalingFactor); + res = res * scaleM; } -#endif } // end namespace #endif