🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Simple Math Library
Hello! I'm writing an app using angelscript as script system. I need to provide commons math function to user. Does it exists a library I can include? (providing for example sin, cos, rand... etc..?)
Thank you,
A. Fontana
Just register the standard functions from math.h :)
Example:
Regards,
Andreas
Example:
r = engine->RegisterGlobalFunction("float sin(float)", asFUNCTION(sinf), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalFunction("float cos(float)", asFUNCTION(cosf), asCALL_CDECL); assert( r >= 0 );
Regards,
Andreas
Quote: Original post by WitchLord
Just register the standard functions from math.h :)
Example:r = engine->RegisterGlobalFunction("float sin(float)", asFUNCTION(sinf), asCALL_CDECL); assert( r >= 0 ); r = engine->RegisterGlobalFunction("float cos(float)", asFUNCTION(cosf), asCALL_CDECL); assert( r >= 0 );
Regards,
Andreas
Thank you. :) I thought there was a pre-made bind (or an internal version) of these. Your scripting system works really good, and it's fast too. I call it hundred of times for seconds on my AI app :)
A. Fontana
I've not gotten around to write a lot of add-ons, but this is definitely a good candidate for a future add-on.
Another good one, would be a good 3D math package, with support for vectors, matrices, etc. The vector and matrix classes should of course be compatible with D3D and OpenGL (maybe two different packages to take care of that).
Thanks for the compliments. I've worked hard to make it as good as I can. There is still a lot more that can be done though, even in the performance department. Let me know if there's something you feel is missing.
If you feel like presenting your project to the public I'd be more than happy to link to it from the AngelScript user's page.
Regards,
Andreas
Another good one, would be a good 3D math package, with support for vectors, matrices, etc. The vector and matrix classes should of course be compatible with D3D and OpenGL (maybe two different packages to take care of that).
Thanks for the compliments. I've worked hard to make it as good as I can. There is still a lot more that can be done though, even in the performance department. Let me know if there's something you feel is missing.
If you feel like presenting your project to the public I'd be more than happy to link to it from the AngelScript user's page.
Regards,
Andreas
It complains about function overload... sin, cos etc have actually some overload version for float, double etc... I need float only... I know a bad workaround: write a wrapper function. Does it exists a better and clean way to select one of overloads?
A. Fontana
A. Fontana
Who's complaining? AngelScript or C++?
If it is C++ you can pick the specific function by using the asFUNCTIONPR() macro, i.e. asFUNCTIONPR(sin, (float), float).
Also, the float version usually have an f appended to the name, i.e. sinf, cosf, etc. You should be able to use those directly without any overload conflicts.
If it is C++ you can pick the specific function by using the asFUNCTIONPR() macro, i.e. asFUNCTIONPR(sin, (float), float).
Also, the float version usually have an f appended to the name, i.e. sinf, cosf, etc. You should be able to use those directly without any overload conflicts.
This post is old, but in case you hadn't noticed already, I've now written an add-on that registers the math functions from the standard C library. It's available in the 2.9.1 release that you can find on the site.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement