| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 | 
							- #include <math.h>
 
- #include "libraries/Math.h"
 
- #include "utils/Functions.h"
 
- #define FLOAT_FUNCTION(Name, Function)                                         \
 
-     static void l##Name(Script* sc) {                                          \
 
-         float f;                                                               \
 
-         if(!sPopFloat(sc, &f)) {                                               \
 
-             sPushFloat(sc, Function(f));                                       \
 
-         }                                                                      \
 
-     }
 
- FLOAT_FUNCTION(Sin, sinf)
 
- FLOAT_FUNCTION(Cos, cosf)
 
- FLOAT_FUNCTION(Tan, tanf)
 
- FLOAT_FUNCTION(ASin, asinf)
 
- FLOAT_FUNCTION(ACos, acosf)
 
- FLOAT_FUNCTION(ATan, atanf)
 
- FLOAT_FUNCTION(Ln, logf)
 
- FLOAT_FUNCTION(Log, log10f)
 
- FLOAT_FUNCTION(SquareRoot, sqrtf)
 
- static void lPow(Script* sc) {
 
-     float x;
 
-     float y;
 
-     if(!sPopFloat(sc, &x) && !sPopFloat(sc, &y)) {
 
-         sPushFloat(sc, powf(y, x));
 
-     }
 
- }
 
- static void lAddFloatFunction(const char* name, ScriptFunction sf) {
 
-     Function f;
 
-     gfInit(&f, name, dtFloat(), sf);
 
-     gfAddArgument(&f, dtFloat());
 
-     gfsAdd(&f);
 
- }
 
- void lMathRegister() {
 
-     lAddFloatFunction("sin", lSin);
 
-     lAddFloatFunction("cos", lCos);
 
-     lAddFloatFunction("tan", lTan);
 
-     lAddFloatFunction("asin", lASin);
 
-     lAddFloatFunction("acos", lACos);
 
-     lAddFloatFunction("atan", lATan);
 
-     lAddFloatFunction("ln", lLn);
 
-     lAddFloatFunction("log", lLog);
 
-     lAddFloatFunction("sqrt", lSquareRoot);
 
-     Function f;
 
-     gfInit(&f, "pow", dtFloat(), lPow);
 
-     gfAddArgument(&f, dtFloat());
 
-     gfAddArgument(&f, dtFloat());
 
-     gfsAdd(&f);
 
- }
 
 
  |