-
how many decimal places are enough for sin, cos
I am making game and I need to move MovieClips around with
x += speed * cos( angle );
y += speed * sin( angle );
Instead of calling cos() and sin() functions, which is too slow, I'll use sin and cos table.
So I wonder if anyone knows what's optimal number of decimal places for sin values. Five, seven, twelve, more...?
-
5+5=55
I really don't think you'll notice any speed increase by using a sin/cos table instead of using the Math.sin and Math.cos functions. If you're using one anyway though, I would think that 5 decimal places would be enough. Some games use 3.14 for pi and it's not really noticeable.
-
Ive benchmarked it in the past and lookup tables are slower than calling the actual functions.
The greatest pleasure in life is doing what people say you cannot do.
- Walter Bagehot
The height of cleverness is to be able to conceal it.
- Francois de La Rochefoucauld
-
My table is 1 second faster than Math.sin... per million lops.
And it has 15 decimal places.
Well maybe it's a bug in Flash CS and AS3...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|