[Qt-interest] What the algorithm of sinTable based on?

Kermit Mei kermit.mei at gmail.com
Thu Jul 1 13:11:56 CEST 2010


On Thu, 2010-07-01 at 12:44 +0200, Oliver.Knoll at comit.ch wrote:
> Kermit Mei wrote on Thursday, July 01, 2010 12:16 PM:
> 
> > ...
> > But I can't understand why there is a "sinTable" needed. What's the
> > theory it based on?
> 
> Without looking at the actual code I think the theory behind this "sinTable" is based on the following: "Everything you pre-compute is faster than when you (re-)compute it everytime you need it" ;)
> 
> So I guess the "sinTable" contains precomputed sin(x) values which you look up given an angle x, and linearly interpolate when the angle y "falls in between" 2 precomputed values x1 and x2.
> 
> And yes, calculating sin(x) is still expensive, compared with other mathematical operations. This performance pattern is at least as old as the first computer games that I played on my C64 ;)
> 
> Cheers, Oliver 

Yes, I see.
Thanks:)

B.R
Kermit




More information about the Qt-interest-old mailing list