From d98e2cb40ca820706d3c81370ae27b2714dd56be Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 15 Apr 2013 14:57:20 -0300 Subject: [PATCH] Renamed randnormal to randomnormal --HG-- branch : math-randobject --- src/modules/graphics/opengl/ParticleSystem.cpp | 4 ++-- src/modules/math/MathModule.h | 6 +++--- src/modules/math/RandomGenerator.cpp | 12 ++++++------ src/modules/math/RandomGenerator.h | 4 ++-- src/modules/math/wrap_Math.cpp | 6 +++--- src/modules/math/wrap_Math.h | 2 +- src/modules/math/wrap_RandomGenerator.cpp | 6 +++--- src/modules/math/wrap_RandomGenerator.h | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/modules/graphics/opengl/ParticleSystem.cpp b/src/modules/graphics/opengl/ParticleSystem.cpp index ab266cef7..8efce6f17 100644 --- a/src/modules/graphics/opengl/ParticleSystem.cpp +++ b/src/modules/graphics/opengl/ParticleSystem.cpp @@ -140,8 +140,8 @@ void ParticleSystem::add() 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: diff --git a/src/modules/math/MathModule.h b/src/modules/math/MathModule.h index 88ac0b337..ea7499932 100644 --- a/src/modules/math/MathModule.h +++ b/src/modules/math/MathModule.h @@ -80,11 +80,11 @@ public: } /** - * @copydoc RandomGenerator::randnormal() + * @copydoc RandomGenerator::randomnormal() **/ - inline double randnormal(double stddev) + inline double randomnormal(double stddev) { - return rng->randnormal(stddev); + return rng->randomnormal(stddev); } /** diff --git a/src/modules/math/RandomGenerator.cpp b/src/modules/math/RandomGenerator.cpp index 4752aef07..55f9c24aa 100644 --- a/src/modules/math/RandomGenerator.cpp +++ b/src/modules/math/RandomGenerator.cpp @@ -32,7 +32,7 @@ namespace math // George Marsaglia, "Xorshift RNGs", Journal of Statistical Software, Vol.8 (Issue 14), 2003 RandomGenerator::RandomGenerator() - : last_randnormal(std::numeric_limits::infinity()) + : last_randomnormal(std::numeric_limits::infinity()) { // because it is too big for some compilers to handle ... if you know what // i mean @@ -66,20 +66,20 @@ uint64 RandomGenerator::rand() } // Box–Muller transform -double RandomGenerator::randnormal(double stddev) +double RandomGenerator::randomnormal(double stddev) { // use cached number if possible - if (last_randnormal != std::numeric_limits::infinity()) + if (last_randomnormal != std::numeric_limits::infinity()) { - double r = last_randnormal; - last_randnormal = std::numeric_limits::infinity(); + double r = last_randomnormal; + last_randomnormal = std::numeric_limits::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; } diff --git a/src/modules/math/RandomGenerator.h b/src/modules/math/RandomGenerator.h index b7fd7f53e..f28aebf2c 100644 --- a/src/modules/math/RandomGenerator.h +++ b/src/modules/math/RandomGenerator.h @@ -96,12 +96,12 @@ public: * @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 diff --git a/src/modules/math/wrap_Math.cpp b/src/modules/math/wrap_Math.cpp index 88409bc64..c6f009e2b 100644 --- a/src/modules/math/wrap_Math.cpp +++ b/src/modules/math/wrap_Math.cpp @@ -42,7 +42,7 @@ int w_random(lua_State *L) 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) @@ -55,7 +55,7 @@ int w_randnormal(lua_State *L) 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; } @@ -153,7 +153,7 @@ static const luaL_Reg functions[] = { { "randomseed", w_randomseed }, { "random", w_random }, - { "randnormal", w_randnormal }, + { "randomnormal", w_randomnormal }, { "newRandomGenerator", w_newRandomGenerator }, { "triangulate", w_triangulate }, { 0, 0 } diff --git a/src/modules/math/wrap_Math.h b/src/modules/math/wrap_Math.h index 3fefbcb30..e523994cf 100644 --- a/src/modules/math/wrap_Math.h +++ b/src/modules/math/wrap_Math.h @@ -32,7 +32,7 @@ namespace math 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); diff --git a/src/modules/math/wrap_RandomGenerator.cpp b/src/modules/math/wrap_RandomGenerator.cpp index 348eb77cd..126ff7c6f 100644 --- a/src/modules/math/wrap_RandomGenerator.cpp +++ b/src/modules/math/wrap_RandomGenerator.cpp @@ -85,7 +85,7 @@ int w_RandomGenerator_random(lua_State *L) 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); @@ -100,7 +100,7 @@ int w_RandomGenerator_randnormal(lua_State *L) stddev = luaL_optnumber(L, 2, 1.0); } - double r = rng->randnormal(stddev); + double r = rng->randomnormal(stddev); lua_pushnumber(L, r + mean); return 1; } @@ -109,7 +109,7 @@ static const luaL_Reg functions[] = { { "randomseed", w_RandomGenerator_randomseed }, { "random", w_RandomGenerator_random }, - { "randnormal", w_RandomGenerator_randnormal }, + { "randomnormal", w_RandomGenerator_randomnormal }, { 0, 0 } }; diff --git a/src/modules/math/wrap_RandomGenerator.h b/src/modules/math/wrap_RandomGenerator.h index 9482fa589..a2fe347b0 100644 --- a/src/modules/math/wrap_RandomGenerator.h +++ b/src/modules/math/wrap_RandomGenerator.h @@ -38,7 +38,7 @@ int luax_getrandom(lua_State *L, int startidx, double r); 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