Posted: Sun Mar 27, 2011 8:03 am
Interesting - pdf link here. I think their idea is to use quadratic interpolation and therefore have smaller lookup tables than needed for linear interpolation (with a second idea of minimising the length of the coefficients and a third idea of using squaring hardware to speed up the interpolation)
Moving slightly back towards integer arithmetic and plotting of a sine curve, there's an old trick due to Minsky which is a close approximation, and uses only add and shift. In fact, maybe not even a shift because a shift by 8 is just picking off a different byte:

At first this was drawing spirals, but it turned out I was using floating point division: it draws near-circles if integer division is used.
(Lots of other interesting tricks in the Hakmem memo.)
Moving slightly back towards integer arithmetic and plotting of a sine curve, there's an old trick due to Minsky which is a close approximation, and uses only add and shift. In fact, maybe not even a shift because a shift by 8 is just picking off a different byte:

At first this was drawing spirals, but it turned out I was using floating point division: it draws near-circles if integer division is used.
Code: Select all
10 A%=256
20 C%=32768
30 S%=A%
40 FOR I%=0 TO 8000
50 C%=C%-S% DIV A%
60 S%=S%+C% DIV A%
70 PLOT69,S%/128+600,C%/128+600
80 PLOT69,I%,S%/128+300
90 PLOT69,I%,C%/128+300
100 NEXT