diff --git a/common/include/pcl/common/impl/pca.hpp b/common/include/pcl/common/impl/pca.hpp index 228831b97ba..e91b7dac4ec 100644 --- a/common/include/pcl/common/impl/pca.hpp +++ b/common/include/pcl/common/impl/pca.hpp @@ -68,7 +68,8 @@ pcl::PCA::initCompute () demeanPointCloud (*input_, *indices_, mean_, cloud_demean); assert (cloud_demean.cols () == int (indices_->size ())); // Compute the product cloud_demean * cloud_demean^T - Eigen::Matrix3f alpha = static_cast (cloud_demean.topRows<3> () * cloud_demean.topRows<3> ().transpose ()); + const Eigen::Matrix3f alpha = (1.f / (float (indices_->size ()) - 1.f)) + * cloud_demean.topRows<3> () * cloud_demean.topRows<3> ().transpose (); // Compute eigen vectors and values Eigen::SelfAdjointEigenSolver evd (alpha);