2003-12-19: Since WME supports math functions now, this library became obsolete. So now this thread is only a example how to create your own libraries with C++.Hiya,
so - you're not just a game designer, but also a genius, right ?
OK, here is your
math functions dll for WME!
http://wme.jerrot.de/mathdll11.zipUsage:
Example:
external "math.dll" cdecl double math_pow(double,double);
Game.Msg("pow(2,8) = " + math_pow(2,8));
Supported functions :
int math_abs(int mynumber)
double math_acos(double mynumber)
double math_asin(double mynumber)
double math_atan(double mynumber)
double math_atan2(double mynumber1, double mynumber2)
double math_cos(double mynumber)
double math_cosh(double mynumber)
double math_exp(double mynumber)
double math_fabs(double mynumber)
double math_fmod(double mynumber1, double mynumber2)
double math_log(double mynumber)
double math_log10(double mynumber)
double math_pow(double mynumber1, double mynumber2)
double math_sin(double mynumber)
double math_sinh(double mynumber)
double math_tan(double mynumber)
double math_tanh(double mynumber)
double math_sqrt(double mynumber)
double DegToRad(double mynumber)
double RadToDeg(double mynumber)
Version history:2003-06-12 - [v1.0]
- initial release
2003-06-13 - [v1.1]
- added DegToRad() and RadToDeg()
C++ Sourcecode is included in the archive, but for the case my server burns up, here it is :
#include <math.h>
#define PI 3.1415926535f
extern "C" __declspec(dllexport) int math_abs(int mynumber)
{
return abs(mynumber);
}
extern "C" __declspec(dllexport) double math_acos(double mynumber)
{
return acos(mynumber);
}
extern "C" __declspec(dllexport) double math_asin(double mynumber)
{
return asin(mynumber);
}
extern "C" __declspec(dllexport) double math_atan(double mynumber)
{
return atan(mynumber);
}
extern "C" __declspec(dllexport) double math_atan2(double mynumber1, double mynumber2)
{
return atan2(mynumber1,mynumber2);
}
extern "C" __declspec(dllexport) double math_cos(double mynumber)
{
return cos(mynumber);
}
extern "C" __declspec(dllexport) double math_cosh(double mynumber)
{
return cosh(mynumber);
}
extern "C" __declspec(dllexport) double math_exp(double mynumber)
{
return exp(mynumber);
}
extern "C" __declspec(dllexport) double math_fabs(double mynumber)
{
return fabs(mynumber);
}
extern "C" __declspec(dllexport) double math_fmod(double mynumber1, double mynumber2)
{
return fmod(mynumber1,mynumber2);
}
extern "C" __declspec(dllexport) double math_log(double mynumber)
{
return log(mynumber);
}
extern "C" __declspec(dllexport) double math_log10(double mynumber)
{
return log10(mynumber);
}
extern "C" __declspec(dllexport) double math_pow(double mynumber1, double mynumber2)
{
return pow(mynumber1,mynumber2);
}
extern "C" __declspec(dllexport) double math_sin(double mynumber)
{
return sin(mynumber);
}
extern "C" __declspec(dllexport) double math_sinh(double mynumber)
{
return sinh(mynumber);
}
extern "C" __declspec(dllexport) double math_tan(double mynumber)
{
return tan(mynumber);
}
extern "C" __declspec(dllexport) double math_tanh(double mynumber)
{
return tanh(mynumber);
}
extern "C" __declspec(dllexport) double math_sqrt(double mynumber)
{
return sqrt(mynumber);
}
extern "C" __declspec(dllexport) double DegToRad(double mynumber)
{
return mynumber * (PI / 180.0f);
}
extern "C" __declspec(dllexport) double RadToDeg(double mynumber)
{
return mynumber * (180.0f / PI);
}
Have fun,
Jerrot!