1 #ifndef __GfxTL_MEAN_HEADER__
2 #define __GfxTL_MEAN_HEADER__
13 template<
class Po
intT,
class Po
intsForwardIt,
class WeightsForwardIt >
14 void Mean(PointsForwardIt begin, PointsForwardIt end,
18 typename PointT::ScalarType totalWeight = 0;
19 for (; begin != end; ++begin, ++weights)
21 *
mean +=
typename PointT::ScalarType(*weights)
22 * ((
const PointT)(*begin));
23 totalWeight += *weights;
31 template<
class PointsForwardIt,
class WeightsForwardIt,
33 void Mean(PointsForwardIt begin, PointsForwardIt end,
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 >
59 template<
class NormalsItT,
class WeightsItT,
class MeanT >
60 bool MeanOfNormals(NormalsItT begin, NormalsItT end, WeightsItT weights,
63 typedef typename MeanT::ScalarType ScalarType;
64 enum { Dim = MeanT::Dim };
69 if (!
Jacobi(cov, &eigenValues, &eigenVectors))
75 ScalarType maxEigVal = eigenValues[0];
76 unsigned int maxEigIdx = 0;
77 for (
unsigned int i = 1; i < Dim; ++i)
78 if (eigenValues[i] > maxEigVal)
80 maxEigVal = eigenValues[i];
83 *
mean = MeanT(eigenVectors[maxEigIdx]);
87 template<
class NormalsItT,
class MeanT >