Commits

Alex Szpakowski committed e436583

Renamed randnormal to randomnormal

Comments (0)

Files changed (8)

src/modules/graphics/opengl/ParticleSystem.cpp

 			pLast->position[1] += Math::instance.random(-areaSpread.getY(), areaSpread.getY());
 			break;
 		case DISTRIBUTION_NORMAL:
-			pLast->position[0] += Math::instance.randnormal(areaSpread.getX());
-			pLast->position[1] += Math::instance.randnormal(areaSpread.getY());
+			pLast->position[0] += Math::instance.randomnormal(areaSpread.getX());
+			pLast->position[1] += Math::instance.randomnormal(areaSpread.getY());
 			break;
 		case DISTRIBUTION_NONE:
 		default:

src/modules/math/MathModule.h

 	}
 
 	/**
-	 * @copydoc RandomGenerator::randnormal()
+	 * @copydoc RandomGenerator::randomnormal()
 	 **/
-	inline double randnormal(double stddev)
+	inline double randomnormal(double stddev)
 	{
-		return rng->randnormal(stddev);
+		return rng->randomnormal(stddev);
 	}
 
 	/**

src/modules/math/RandomGenerator.cpp

 // George Marsaglia, "Xorshift RNGs", Journal of Statistical Software, Vol.8 (Issue 14), 2003
 
 RandomGenerator::RandomGenerator()
-	: last_randnormal(std::numeric_limits<double>::infinity())
+	: last_randomnormal(std::numeric_limits<double>::infinity())
 {
 	// because it is too big for some compilers to handle ... if you know what
 	// i mean
 }
 
 // Box–Muller transform
-double RandomGenerator::randnormal(double stddev)
+double RandomGenerator::randomnormal(double stddev)
 {
 	// use cached number if possible
-	if (last_randnormal != std::numeric_limits<double>::infinity())
+	if (last_randomnormal != std::numeric_limits<double>::infinity())
 	{
-		double r = last_randnormal;
-		last_randnormal = std::numeric_limits<double>::infinity();
+		double r = last_randomnormal;
+		last_randomnormal = std::numeric_limits<double>::infinity();
 		return r * stddev;
 	}
 
 	double r   = sqrt(-2.0 * log(1. - random()));
 	double phi = 2.0 * LOVE_M_PI * (1. - random());
 
-	last_randnormal = r * cos(phi);
+	last_randomnormal = r * cos(phi);
 	return r * sin(phi) * stddev;
 }
 

src/modules/math/RandomGenerator.h

 	 * @param stddev Standard deviation of the distribution.
 	 * @return Normally distributed random number with mean 0 and variance (stddev)².
 	 **/
-	double randnormal(double stddev);
+	double randomnormal(double stddev);
 
 private:
 
 	uint64 rng_state;
-	double last_randnormal;
+	double last_randomnormal;
 
 }; // RandomGenerator
 

src/modules/math/wrap_Math.cpp

 	return luax_getrandom(L, 1, Math::instance.random());
 }
 
-int w_randnormal(lua_State *L)
+int w_randomnormal(lua_State *L)
 {
 	double mean = 0.0, stddev = 1.0;
 	if (lua_gettop(L) > 1)
 		stddev = luaL_optnumber(L, 1, 1.);
 	}
 
-	double r = Math::instance.randnormal(stddev);
+	double r = Math::instance.randomnormal(stddev);
 	lua_pushnumber(L, r + mean);
 	return 1;
 }
 {
 	{ "randomseed", w_randomseed },
 	{ "random", w_random },
-	{ "randnormal", w_randnormal },
+	{ "randomnormal", w_randomnormal },
 	{ "newRandomGenerator", w_newRandomGenerator },
 	{ "triangulate", w_triangulate },
 	{ 0, 0 }

src/modules/math/wrap_Math.h

 
 int w_randomseed(lua_State *L);
 int w_random(lua_State *L);
-int w_randnormal(lua_State *L);
+int w_randomnormal(lua_State *L);
 int w_newRandomGenerator(lua_State *L);
 int w_triangulate(lua_State *L);
 extern "C" LOVE_EXPORT int luaopen_love_math(lua_State *L);

src/modules/math/wrap_RandomGenerator.cpp

 	return luax_getrandom(L, 2, rng->random());
 }
 
-int w_RandomGenerator_randnormal(lua_State *L)
+int w_RandomGenerator_randomnormal(lua_State *L)
 {
 	RandomGenerator *rng = luax_checkrandomgenerator(L, 1);
 
 		stddev = luaL_optnumber(L, 2, 1.0);
 	}
 
-	double r = rng->randnormal(stddev);
+	double r = rng->randomnormal(stddev);
 	lua_pushnumber(L, r + mean);
 	return 1;
 }
 {
 	{ "randomseed", w_RandomGenerator_randomseed },
 	{ "random", w_RandomGenerator_random },
-	{ "randnormal", w_RandomGenerator_randnormal },
+	{ "randomnormal", w_RandomGenerator_randomnormal },
 	{ 0, 0 }
 };
 

src/modules/math/wrap_RandomGenerator.h

 RandomGenerator *luax_checkrandomgenerator(lua_State *L, int idx);
 int w_RandomGenerator_randomseed(lua_State *L);
 int w_RandomGenerator_random(lua_State *L);
-int w_RandomGenerator_randnormal(lua_State *L);
+int w_RandomGenerator_randomnormal(lua_State *L);
 extern "C" int luaopen_randomgenerator(lua_State *L);
 
 } // math