|
@@ -31,6 +31,8 @@
|
|
|
#ifndef RANDOM_PCG_H
|
|
|
#define RANDOM_PCG_H
|
|
|
|
|
|
+#include <math.h>
|
|
|
+
|
|
|
#include "core/math/math_defs.h"
|
|
|
|
|
|
#include "thirdparty/misc/pcg.h"
|
|
@@ -61,6 +63,13 @@ public:
|
|
|
_FORCE_INLINE_ double randd() { return (double)rand() / (double)RANDOM_MAX; }
|
|
|
_FORCE_INLINE_ float randf() { return (float)rand() / (float)RANDOM_MAX; }
|
|
|
|
|
|
+ _FORCE_INLINE_ double randfn(double p_mean, double p_deviation) {
|
|
|
+ return p_mean + p_deviation * (cos(Math_TAU * randd()) * sqrt(-2.0 * log(randd()))); // Box-Muller transform
|
|
|
+ }
|
|
|
+ _FORCE_INLINE_ float randfn(float p_mean, float p_deviation) {
|
|
|
+ return p_mean + p_deviation * (cos(Math_TAU * randf()) * sqrt(-2.0 * log(randf()))); // Box-Muller transform
|
|
|
+ }
|
|
|
+
|
|
|
double random(double p_from, double p_to);
|
|
|
float random(float p_from, float p_to);
|
|
|
real_t random(int p_from, int p_to) { return (real_t)random((real_t)p_from, (real_t)p_to); }
|