Making a faster cosf, and sinf function?
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
Try using look up tables. Personally, I like to use arrays with 3600 values or so and precompute the values.
My Website
My Website
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)
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.
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.
For source code to a good and fast approximation, look a Magic Software''s free math lib. Works wonders for me
Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]
Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement