8 template <
class ScalarType>
void GetSphereEvenSampling(std::vector < std::vector <ScalarType> > &spherePoints,
9 unsigned int numSamples)
11 double numLatitudes = std::sqrt(numSamples * M_PI / 8.0);
12 double oldNumLatitudes = numLatitudes - 1;
14 while (std::abs(numLatitudes - oldNumLatitudes) > 1.0e-8)
16 oldNumLatitudes = numLatitudes;
17 numLatitudes = numSamples * std::sin(M_PI / (4.0 * numLatitudes)) / 2.0;
20 unsigned int roundedNumLatitudes = std::round(numLatitudes);
21 spherePoints.resize(numSamples);
23 unsigned int sumKs = 0;
24 std::vector <ScalarType> spherePoint(3,0.0);
25 for (
unsigned int i = 0;i < roundedNumLatitudes;++i)
27 double latitude = (i + 0.5) * M_PI / (2.0 * roundedNumLatitudes);
30 if (i == roundedNumLatitudes - 1)
31 k5 = numSamples - sumKs;
33 k5 = std::round(2.0 * numSamples * std::sin(latitude) * std::sin(M_PI / (4.0 * roundedNumLatitudes)));
35 spherePoint[2] = std::cos(latitude);
36 for (
unsigned int j = 0;j < k5;++j)
38 double longitude = (j + 0.5) * 2.0 * M_PI / k5;
40 spherePoint[0] = std::sin(latitude) * std::cos(longitude);
41 spherePoint[1] = std::sin(latitude) * std::sin(longitude);
43 spherePoints[sumKs + j] = spherePoint;
void GetSphereEvenSampling(std::vector< std::vector< ScalarType > > &spherePoints, unsigned int numSamples)