From 57880ef23102da27bc27c37e1a9954bf22b2ddb8 Mon Sep 17 00:00:00 2001 From: ponchio Date: Wed, 12 Feb 2014 15:07:19 +0000 Subject: [PATCH] Replaced Eigen::Vector3f p; with Eigen::Matrix p; (support for double precision). --- vcg/space/fitting3.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/vcg/space/fitting3.h b/vcg/space/fitting3.h index f8083667..aceeb94c 100644 --- a/vcg/space/fitting3.h +++ b/vcg/space/fitting3.h @@ -8,7 +8,7 @@ * \ * * All rights reserved. * * * -* This program is free software; you can redistribute it and/or modify * +* This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * @@ -49,7 +49,7 @@ void ComputeCovarianceMatrix(const std::vector > &pointVec, Point3 // second cycle: compute the covariance matrix m.setZero(); - Eigen::Vector3f p; + Eigen::Matrix p; for(pit = pointVec.begin(); pit != pointVec.end(); ++pit) { ((*pit)-barycenter).ToEigenVector(p); m+= p*p.transpose(); // outer product @@ -64,13 +64,13 @@ The algorithm used is the classical Covariance matrix eigenvector approach. template void FitPlaneToPointSet(const std::vector< Point3 > & pointVec, Plane3 & plane) { - Eigen::Matrix3f covMat=Eigen::Matrix3f::Zero(); + Eigen::Matrix covMat = Eigen::Matrix::Zero(); Point3 b; ComputeCovarianceMatrix(pointVec,b,covMat); - Eigen::SelfAdjointEigenSolver eig(covMat); - Eigen::Vector3f eval = eig.eigenvalues(); - Eigen::Matrix3f evec = eig.eigenvectors(); + Eigen::SelfAdjointEigenSolver > eig(covMat); + Eigen::Matrix eval = eig.eigenvalues(); + Eigen::Matrix evec = eig.eigenvectors(); eval = eval.cwiseAbs(); int minInd; eval.minCoeff(&minInd); @@ -107,7 +107,7 @@ void ComputeWeightedCovarianceMatrix(const std::vector > &pointVec, co // The weights are applied to the points transposed to the origin. m.setZero(); Eigen::Matrix A; - Eigen::Vector3f p; + Eigen::Matrix p; for( pit = pointVec.begin(),wit=weightVec.begin(); pit != pointVec.end(); ++pit,++wit) { (((*pit)-bp)*(*wit)).ToEigenVector(p); @@ -123,13 +123,13 @@ The algorithm used is the classical Covariance matrix eigenvector approach. template void WeightedFitPlaneToPointSet(const std::vector< Point3 > & pointVec, const std::vector &weightVec, Plane3 & plane) { - Eigen::Matrix3f covMat=Eigen::Matrix3f::Zero(); + Eigen::Matrix covMat = Eigen::Matrix::Zero(); Point3 b; ComputeWeightedCovarianceMatrix(pointVec,weightVec, b,covMat); - Eigen::SelfAdjointEigenSolver eig(covMat); - Eigen::Vector3f eval = eig.eigenvalues(); - Eigen::Matrix3f evec = eig.eigenvectors(); + Eigen::SelfAdjointEigenSolver > eig(covMat); + Eigen::Matrix eval = eig.eigenvalues(); + Eigen::Matrix evec = eig.eigenvectors(); eval = eval.cwiseAbs(); int minInd; eval.minCoeff(&minInd);