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>
60 template <
class NormalsItT,
class WeightsItT,
class MeanT>
64 typedef typename MeanT::ScalarType ScalarType;
75 if (!
Jacobi(cov, &eigenValues, &eigenVectors))
81 ScalarType maxEigVal = eigenValues[0];
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>