1#ifndef __GfxTL_MEAN_HEADER__
2#define __GfxTL_MEAN_HEADER__
12 template <
class Po
intT,
class Po
intsForwardIt,
class WeightsForwardIt>
14 Mean(PointsForwardIt begin, PointsForwardIt end, WeightsForwardIt weights, PointT* mean)
17 typename PointT::ScalarType totalWeight = 0;
18 for (; begin != end; ++begin, ++weights)
20 *mean +=
typename PointT::ScalarType(*weights) * ((
const PointT)(*begin));
21 totalWeight += *weights;
29 template <
class Po
intsForwardIt,
class WeightsForwardIt,
class ScalarT>
31 Mean(PointsForwardIt begin,
33 WeightsForwardIt weights,
37 ScalarT totalWeight = 0, w;
38 for (; begin != end; ++begin, ++weights)
40 w = (ScalarT)*weights;
41 (*mean)[0] += w * (*begin)[0];
42 (*mean)[1] += w * (*begin)[1];
43 (*mean)[2] += w * (*begin)[2];
52 template <
class Po
intT,
class Po
intsForwardIt>
54 Mean(PointsForwardIt begin, PointsForwardIt end, PointT* mean)
60 template <
class NormalsItT,
class WeightsItT,
class MeanT>
62 MeanOfNormals(NormalsItT begin, NormalsItT end, WeightsItT weights, MeanT* mean)
75 if (!
Jacobi(cov, &eigenValues, &eigenVectors))
82 unsigned int maxEigIdx = 0;
83 for (
unsigned int i = 1; i < Dim; ++i)
84 if (eigenValues[i] > maxEigVal)
86 maxEigVal = eigenValues[i];
89 *mean = MeanT(eigenVectors[maxEigIdx]);
93 template <
class NormalsItT,
class MeanT>
void CovarianceMatrix(const PointT ¢er, PointsForwardIt begin, PointsForwardIt end, WeightsForwardIt weights, MatrixT *matrix)
void Mean(PointsForwardIt begin, PointsForwardIt end, WeightsForwardIt weights, PointT *mean)
bool Jacobi(const MatrixXX< N, N, T > &m, VectorXD< N, T > *d, MatrixXX< N, N, T > *v, int *nrot=NULL)
bool MeanOfNormals(NormalsItT begin, NormalsItT end, WeightsItT weights, MeanT *mean)