Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DevLiquidKnight

Making a faster cosf, and sinf function?

This topic is 5436 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

Does anyone have a accuate yet fast cosf and sinf function? I just was wondering cuz i could just maybe add it to make things a bit faster sense speed in games is always an issue

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Foxostro
Try using look up tables. Personally, I like to use arrays with 3600 values or so and precompute the values.


Sizing your table to be a power of two makes better sense. Remember that dividing a circle in ''360 degrees'' is a completely arbitrary decision.


“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
— Brian W. Kernighan (C programming language co-inventor)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Also, if you weren''t exactly going for accuracy, you could always break it down into the Taylor Polynomials around whichever point was closest to you.... for some points (pi/3, for example) a linear approximation does wonders.

Share this post


Link to post
Share on other sites
quote:
Original post by Foxostro
Try using look up tables. Personally, I like to use arrays with 3600 values or so and precompute the values.


Way to kill the cache. A 14K lookup table sounds like a bad idea to me... Anyway I would recommend the taylor-series approimations (you can find them everywhere). To seven powers should give you accuracy in the range [0, 2 * pi) that is good enough for government work.

Share this post


Link to post
Share on other sites

  • 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!