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

Improve plummer distribution generation

parent 6575d8c6
...@@ -259,7 +259,7 @@ FReal plummerDist(FSize& cpt, const FReal &R) { ...@@ -259,7 +259,7 @@ FReal plummerDist(FSize& cpt, const FReal &R) {
*/ */
template <class FReal> template <class FReal>
void unifRandomPlummer(const FSize N, const FReal R, FReal * points) { 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)); constexpr const FReal r_max = std::sqrt(1.0/(std::pow(rand_max, -2.0/3.0) - 1.0));
std::cerr << r_max << '\n'; std::cerr << r_max << '\n';
...@@ -267,7 +267,9 @@ void unifRandomPlummer(const FSize N, const FReal R, FReal * points) { ...@@ -267,7 +267,9 @@ void unifRandomPlummer(const FSize N, const FReal R, FReal * points) {
FReal mc = 1.0/static_cast<FReal>(N); FReal mc = 1.0/static_cast<FReal>(N);
for (FSize i = 0, j = 0 ; i< N ; ++i, j+=4) { for (FSize i = 0, j = 0 ; i< N ; ++i, j+=4) {
FReal m = getRandom<FReal>(); FReal m = getRandom<FReal>();
m = m > rand_max ? rand_max : m; while(m > rand_max) {
m = getRandom<FReal>();
}
FReal r = FMath::Sqrt(1.0/(FMath::pow(m, -2.0/3.0) - 1.0)) / r_max; FReal r = FMath::Sqrt(1.0/(FMath::pow(m, -2.0/3.0) - 1.0)) / r_max;
points[j] *= r; points[j] *= r;
points[j+1] *= r; points[j+1] *= r;
......
Supports Markdown
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