2 #include <tclap/CmdLine.h>     6 #include <itkVariableLengthVector.h>     8 int main(
int argc,  
char **argv)
    10     TCLAP::CmdLine cmd(
"INRIA / IRISA - VisAGeS/Empenn Team", 
' ',ANIMA_VERSION);
    12     TCLAP::ValueArg<unsigned int> numPointsArg(
"n",
"nb-points",
"Number of points (default: 20)",
false,20,
"number of points",cmd);
    13     TCLAP::SwitchArg equalWeightsArg(
"E", 
"equal-weights", 
"Use equal weights",cmd,
false);
    19     catch (TCLAP::ArgException& e)
    21         std::cerr << 
"Error: " << e.error() << 
"for argument " << e.argId() << std::endl;
    25     typedef std::mt19937 RandomGeneratorType;
    26     RandomGeneratorType generator(time(0));
    29     std::vector < std::vector <double> > random_sphere_points(numPointsArg.getValue());
    30     std::vector <double> random_sphere_point(3,0);
    31     std::vector <double> average_point(3);
    32     std::vector <double> weights(numPointsArg.getValue());
    34     for (
unsigned int i = 0;i < numPointsArg.getValue();++i)
    37         random_sphere_points[i] = random_sphere_point;
    40     if (equalWeightsArg.isSet())
    42         for (
unsigned int i = 0;i < numPointsArg.getValue();++i)
    43             weights[i] = 1.0 / numPointsArg.getValue();
    47         double sumWeights = 0;
    49         for (
unsigned int i = 0;i < numPointsArg.getValue();++i)
    52             sumWeights += weights[i];
    55         for (
unsigned int i = 0;i < numPointsArg.getValue();++i)
    56             weights[i] /= sumWeights;
    61     std::cout << 
"Initial points: " << std::endl;
    63     for (
unsigned int i = 0;i < numPointsArg.getValue();++i)
    64         std::cout << random_sphere_points[i][0] << 
" " << random_sphere_points[i][1] << 
" " << random_sphere_points[i][2] << std::endl;
    66     std::cout << 
"Weights: ";
    67     for (
unsigned int i = 0;i < weights.size();++i)
    68         std::cout << weights[i] << 
" ";
    69     std::cout << std::endl;
    71     std::cout << 
"Average point: " << average_point[0] << 
" " << average_point[1] << 
" " << average_point[2] << std::endl;
 void SampleFromUniformDistributionOn2Sphere(std::mt19937 &generator, VectorType &resVec)
 
int main(int argc, char **argv)
 
void ComputeSphericalCentroid(const std::vector< std::vector< ScalarType > > &dataPoints, std::vector< ScalarType > ¢roidValue, const std::vector< ScalarType > &initPoint, const std::vector< ScalarType > &weights, std::vector< ScalarType > *workLogVector=0, std::vector< ScalarType > *workVector=0, double tol=1.0e-4)
 
double SampleFromUniformDistribution(const T &a, const T &b, std::mt19937 &generator)