Page 2 of 2

Posted: Sun Mar 27, 2011 8:03 am
by BigEd
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:

Image

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                            
(Lots of other interesting tricks in the Hakmem memo.)

Posted: Mon Mar 28, 2011 12:31 am
by ElEctric_EyE
Fascinating. That is awesome info!

Posted: Mon Mar 28, 2011 7:31 am
by Arlet
Marvin's trick to draw circles was used as an example program in the Acorn Atom user manual: "Atomic theory and practice". An excellent book full little bits of useful code.

Posted: Mon Mar 28, 2011 8:56 am
by BigEd
Nice! Code on Page 86 - picture on next page.

(I wish I'd been able to post those graphics as an ATALAN example... an exercise for the reader?)