If you want to use non-discreet values, then for a look-up table you'd have to do something like this:
...Which interpolates between the two values. It's much better than using the nearest discreet value.
Using a LUT array directly is about twice as fast as Cos() on my laptop (probably largely due to L2 caching), however this function is about 5 times slower. As the use of Sin/Cos using discreet inputs is extremely limited, it's hard to justify not using the Sin()/Cos() functions.
Why?
Function array_cos:Double(x:Double) Local a:Int = Floor(x) Local b:Int = Ceil(x) While a<0 a:+360 EndWhile While b>359 a:-360 EndWhile Local fa:Double = pcos[a] Local fb:Double = pcos[b] Local dx:Double = x - Double(fa) Return(dx*fa + (1.0-dx)*fb) EndFunction
...Which interpolates between the two values. It's much better than using the nearest discreet value.
Using a LUT array directly is about twice as fast as Cos() on my laptop (probably largely due to L2 caching), however this function is about 5 times slower. As the use of Sin/Cos using discreet inputs is extremely limited, it's hard to justify not using the Sin()/Cos() functions.
The most Important thing is Do cos and sin give different results on different comp. Because then we should use lookups.
Why?