Jump to content
  • Advertisement
Sign in to follow this  
Trikko

Simple Math Library

This topic is 4104 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Good news, then I'll update my genetic arm code soon.

PS: I see my nick on 2.10.0 changelog... ;)

Thank you,
Andrea Fontana

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!