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

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Thu Jul 1 12:44:51 CEST 2010


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 
-- 
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22



More information about the Qt-interest-old mailing list