Commit 3fcb490d authored by Quentin Khan's avatar Quentin Khan

Improve plummer distribution generation

parent 6575d8c6
......@@ -259,15 +259,17 @@ FReal plummerDist(FSize& cpt, const FReal &R) {
*/
template <class FReal>
void unifRandomPlummer(const FSize N, const FReal R, FReal * points) {
constexpr const FReal rand_max = 0.995;
constexpr const FReal rand_max = 0.8;
constexpr const FReal r_max = std::sqrt(1.0/(std::pow(rand_max, -2.0/3.0) - 1.0));
std::cerr << r_max << '\n';
unifRandomPointsOnSphere<FReal>(N, 1, points);
FReal mc = 1.0/static_cast<FReal>(N);
for (FSize i = 0, j = 0 ; i< N ; ++i, j+=4) {
FReal m = getRandom<FReal>();
m = m > rand_max ? rand_max : m;
FReal m = getRandom<FReal>();
while(m > rand_max) {
m = getRandom<FReal>();
}
FReal r = FMath::Sqrt(1.0/(FMath::pow(m, -2.0/3.0) - 1.0)) / r_max;
points[j] *= r;
points[j+1] *= r;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment