23#ifndef VCL_ALGORITHMS_CORE_STAT_H
24#define VCL_ALGORITHMS_CORE_STAT_H
26#include <vclib/space/core.h>
37template<Po
int3Concept Po
intType>
38auto covarianceMatrixOfPointCloud(
const std::vector<PointType>& pointVec)
40 Matrix33<typename PointType::ScalarType> m;
45 for (
const PointType& p : pointVec) {
46 PointType e = p - barycenter;
47 m += e.outerProduct(e);
58template<Po
int3Concept Po
intType>
59auto weightedCovarianceMatrixOfPointCloud(
60 const std::vector<PointType>& pointVec,
61 const std::vector<typename PointType::ScalarType>& weights)
63 Matrix33<typename PointType::ScalarType> m;
65 PointType barycenter =
69 typename PointType::ScalarType wsum = 0;
70 for (uint i = 0; i < pointVec.size(); ++i) {
71 PointType e = (pointVec[i] - barycenter) * weights[i];
72 m += e.outerProduct(e);
PointT weightedBarycenter(WIterator wBegin) const
Computes the weighted barycenter of the polygon.
Definition polygon.h:215
PointT barycenter() const
Computes the barycenter of the polygon.
Definition polygon.h:200