23#ifndef VCL_ALGORITHMS_CORE_STAT_H
24#define VCL_ALGORITHMS_CORE_STAT_H
26#include <vclib/space/core/matrix.h>
27#include <vclib/space/core/polygon.h>
38template<Po
int3Concept Po
intType>
39auto covarianceMatrixOfPointCloud(
const std::vector<PointType>& pointVec)
41 Matrix33<typename PointType::ScalarType> m;
46 for (
const PointType& p : pointVec) {
47 PointType e = p - barycenter;
48 m += e.outerProduct(e);
59template<Po
int3Concept Po
intType>
60auto weightedCovarianceMatrixOfPointCloud(
61 const std::vector<PointType>& pointVec,
62 const std::vector<typename PointType::ScalarType>& weights)
64 Matrix33<typename PointType::ScalarType> m;
66 PointType barycenter =
70 typename PointType::ScalarType wsum = 0;
71 for (uint i = 0; i < pointVec.size(); ++i) {
72 PointType e = (pointVec[i] - barycenter) * weights[i];
73 m += e.outerProduct(e);
PointT weightedBarycenter(WIterator wBegin) const
Computes the weighted barycenter of the polygon.
Definition polygon.h:218
PointT barycenter() const
Computes the barycenter of the polygon.
Definition polygon.h:203