]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/random.qc
Purge other from blocked
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / random.qc
index be0f80a089c15b5057f25c974a1533963ba79c57..aff961c55da56b9dcde016c90335dbee7026d5e9 100644 (file)
@@ -66,6 +66,26 @@ float DistributeEvenly_GetRandomized(float weight)
        return f;
 }
 
+// from the GNU Scientific Library
+float gsl_ran_gaussian_lastvalue;
+float gsl_ran_gaussian_lastvalue_set;
+float gsl_ran_gaussian(float sigma)
+{
+       if (gsl_ran_gaussian_lastvalue_set)
+       {
+               gsl_ran_gaussian_lastvalue_set = 0;
+               return sigma * gsl_ran_gaussian_lastvalue;
+       }
+       else
+       {
+               float a = random() * 2 * M_PI;
+               float b = sqrt(-2 * log(random()));
+               gsl_ran_gaussian_lastvalue = cos(a) * b;
+               gsl_ran_gaussian_lastvalue_set = 1;
+               return sigma * sin(a) * b;
+       }
+}
+
 // prandom - PREDICTABLE random number generator (not seeded yet)
 
 #ifdef USE_PRANDOM