1
1
#pragma once
2
2
#include < vector>
3
+ #include < random>
3
4
4
5
#include " ../../octree.h"
5
6
@@ -10,6 +11,7 @@ auto constexpr rMax = 8.0;
10
11
template <dim_t DIMENSION_NO>
11
12
constexpr std::vector<PointND<DIMENSION_NO>> GeneratePointsRandom (size_t pointsNo, int seed = 0 )
12
13
{
14
+ auto rng = std::mt19937 (seed);
13
15
14
16
auto aPoint = std::vector<PointND<DIMENSION_NO>>(pointsNo);
15
17
if (pointsNo <= 1 )
@@ -31,11 +33,10 @@ constexpr std::vector<PointND<DIMENSION_NO>> GeneratePointsRandom(size_t pointsN
31
33
aPoint[iNumber][iDim] = rMax;
32
34
}
33
35
34
- srand (seed);
35
36
{
36
37
for (; iNumber < pointsNo; ++iNumber)
37
38
for (dim_t iDim = 0 ; iDim < DIMENSION_NO; ++iDim)
38
- aPoint[iNumber][iDim] = double (rand () % 100 ) * (rMax / 100.0 );
39
+ aPoint[iNumber][iDim] = double (rng () % 100 ) * (rMax / 100.0 );
39
40
}
40
41
41
42
return aPoint;
@@ -83,7 +84,7 @@ BoundingBoxND<DIMENSION_NO> CreateSearcBox(double rBegin, double rSize)
83
84
84
85
85
86
template <dim_t DIMENSION_NO>
86
- constexpr std::vector<BoundingBoxND<DIMENSION_NO>> GenerateBoxesRandom (size_t nNumber, int seed = 0 )
87
+ constexpr std::vector<BoundingBoxND<DIMENSION_NO>> GenerateBoxesRandom (size_t nNumber, int seed = 0 , double boxSizeScale = 0.125 )
87
88
{
88
89
if (nNumber == 0 )
89
90
return {};
@@ -116,16 +117,18 @@ constexpr std::vector<BoundingBoxND<DIMENSION_NO>> GenerateBoxesRandom(size_t nN
116
117
++iNumber;
117
118
}
118
119
119
- srand (seed);
120
+ auto rng = std::mt19937 (seed);
120
121
121
122
{
123
+ auto const rMaxBoxSize = boxSizeScale * rMax;
122
124
for (size_t iRemain = 1 ; iNumber < nNumber; ++iNumber, ++iRemain)
123
125
{
124
126
auto const iNumberBox = nNumber - iNumber - 1 ;
125
127
for (dim_t iDim = 0 ; iDim < DIMENSION_NO && iNumber < nNumber; ++iDim)
126
- aBox[iNumberBox].Min [iDim] = double (rand () % 100 ) * ((rMax - 1.0 ) / 100.0 );
127
-
128
- aBox[iNumberBox].Max = CreateBoxMax (aBox[iNumberBox].Min , double (rand () % 100 ) * (1.0 * rUnit / 100.0 ));
128
+ {
129
+ aBox[iNumberBox].Min [iDim] = double (rng () % 100 ) * ((rMax - 1.0 ) / 100.0 );
130
+ aBox[iNumberBox].Max [iDim] = std::min (rMax, aBox[iNumberBox].Min [iDim] + (double (rng () % 100 ) / 100.0 ) * rMaxBoxSize);
131
+ }
129
132
}
130
133
}
131
134
0 commit comments