Archived

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

evilchicken

just how slow is...

Recommended Posts

lmv    122
Well, at least it used to be faster to make lookup tables but nowadays there''s really no need to precalc them since there is basically no change in speed.

-----------------------------
Yes, this is a very witty signature.

Share this post


Link to post
Share on other sites
mcfly    151
It may actually still be a good idea to put them into a table, at least if you limit yourself to 256 entries so there won''t be any cache miss. If you can live with the not-so-good-precision go for it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
> [just how slow is] the C++ sin() and cos() functions?

It depends ... on your compiler, compiler settings, processor, operating environment, etc.

> is it really worth trading off memory to make lookup tables?

This depends on the benefit to you. If you only call sin() and cos() a few times a frame it probably won''t make a difference. If you rely on them a lot then you may benefit from using lookup tables, but then a better optimisation may be to redudce your dependence on trigonometry, e.g. by using quaternions instead of angles to represent rotations.

The best way is to try it and see: there''s no general answer to a problem like this and the only way to discover what''s best for you is try it in your own code.

Share this post


Link to post
Share on other sites
LilBudyWizer    491
Well, I setup a program that calculated the sin of 1024 double values in an input table and put the results in an output table 1024 times. On a 450MHZ Pentium III I got about 3.2 million per second. On 1.3ghz Pentium 4 I got about 6.5 million per second. So I would think a starting point would be how many do you need to do per second? If you don''t know then you need to reevaluate your approach to performance.

Share this post


Link to post
Share on other sites