Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. # compute arctangent table for CORDIC computations in fttrigon.c
  2. import sys, math
  3.  
  4. #units  = 64*65536.0   # don't change !!
  5. units  = 180 * 2**16
  6. scale  = units/math.pi
  7. shrink = 1.0
  8. comma  = ""
  9.  
  10. print ""
  11. print "table of arctan( 1/2^n ) for PI = " + repr(units/65536.0) + " units"
  12.  
  13. for n in range(1,32):
  14.  
  15.     x = 0.5**n                      # tangent value
  16.  
  17.     angle  = math.atan(x)           # arctangent
  18.     angle2 = round(angle*scale)     # arctangent in FT_Angle units
  19.  
  20.     if angle2 <= 0:
  21.         break
  22.  
  23.     sys.stdout.write( comma + repr( int(angle2) ) )
  24.     comma = ", "
  25.  
  26.     shrink /= math.sqrt( 1 + x*x )
  27.  
  28. print
  29. print "shrink factor    = " + repr( shrink )
  30. print "shrink factor 2  = " + repr( int( shrink * (2**32) ) )
  31. print "expansion factor = " + repr( 1/shrink )
  32. print ""
  33.  
  34.