Browse Source

Add logarithm function to Math API.

Eugene Kozlov 9 years ago
parent
commit
0acd25e763

+ 1 - 0
Source/Urho3D/AngelScript/MathAPI.cpp

@@ -65,6 +65,7 @@ static void RegisterMathFunctions(asIScriptEngine* engine)
     engine->RegisterGlobalFunction("float Sign(float)", asFUNCTION(Sign<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Sign(float)", asFUNCTION(Sign<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Sqrt(float)", asFUNCTION(Sqrt<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Sqrt(float)", asFUNCTION(Sqrt<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Pow(float, float)", asFUNCTION(Pow<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Pow(float, float)", asFUNCTION(Pow<float>), asCALL_CDECL);
+    engine->RegisterGlobalFunction("float Ln(float)", asFUNCTION(Ln<float>), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Min(float, float)", asFUNCTIONPR(Min, (float, float), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Min(float, float)", asFUNCTIONPR(Min, (float, float), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("int Min(int, int)", asFUNCTIONPR(Min, (int, int), int), asCALL_CDECL);
     engine->RegisterGlobalFunction("int Min(int, int)", asFUNCTIONPR(Min, (int, int), int), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Max(float, float)", asFUNCTIONPR(Max, (float, float), float), asCALL_CDECL);
     engine->RegisterGlobalFunction("float Max(float, float)", asFUNCTIONPR(Max, (float, float), float), asCALL_CDECL);

+ 1 - 0
Source/Urho3D/LuaScript/pkgs/Math/MathDefs.pkg

@@ -45,6 +45,7 @@ float Atan(float x);
 float Atan2(float y, float x);
 float Atan2(float y, float x);
 float Sqrt(float x);
 float Sqrt(float x);
 float Pow(float x, float y);
 float Pow(float x, float y);
+float Ln(float x);
 float Mod(float x, float y);
 float Mod(float x, float y);
 float Fract(float x);
 float Fract(float x);
 float Floor(float x);
 float Floor(float x);

+ 3 - 0
Source/Urho3D/Math/MathDefs.h

@@ -149,6 +149,9 @@ template <class T> inline T Atan2(T y, T x) { return M_RADTODEG * atan2(y, x); }
 /// Return X in power Y.
 /// Return X in power Y.
 template <class T> T Pow(T x, T y) { return pow(x, y); }
 template <class T> T Pow(T x, T y) { return pow(x, y); }
 
 
+/// Return natural logarithm of X.
+template <class T> T Ln(T x) { return log(x); }
+
 /// Return square root of X.
 /// Return square root of X.
 template <class T> T Sqrt(T x) { return sqrt(x); }
 template <class T> T Sqrt(T x) { return sqrt(x); }