is there any way to do basic limits derivatives integrations or logs in ags ? I really need to use these functions for some physics i want to apply to my game but i cant even do a simple natural log function!
Here:
#define LIMIT 10000.0
float noloopcheck ln(float x) {
if (x <= 0.0) return 0.0;
float k, re;
while (k<LIMIT) {
re += (Maths.RaiseToPower((x-1.0)/(x+1.0), 2.0*k+1.0)*2.0)/(2.0*k+1.0);
k += 1.0;
}
return re;
}
float log(float base, float x) {
if (base <= 0.0 || x == 0.0) return 0.0;
return ln(x)/ln(base);
}
Adjust limit for precision vs. speed.
Quote from: glafebe6 on Tue 27/01/2009 02:46:42
is there any way to do basic limits derivatives integrations or logs in ags ? I really need to use these functions for some physics i want to apply to my game but i cant even do a simple natural log function!
Also, try to exploit every possible property of the things you're working with (e.g. logs' bases multiplication whenever ther is log + log, Taylor, etc.); Khris' code is quite silky, but overusing it could be the doom of your game.
Just out of interest, what are you planning to do in your game?