1 # compute arctangent table for CORDIC computations in fttrigon.c
4 #units = 64*65536.0 # don't change !!
13 shrink
= shrink
* math
.cos(angle
)
14 return angle
/math
.pi
* units
16 def print_val( n
, x
):
23 ax
= math
.atan(2.0**n
)
25 errlo
= abs( alo
- ax
)
26 errhi
= abs( ahi
- ax
)
31 sys
.stdout
.write( comma
+ repr( int(hi
) ) )
36 print "table of arctan( 1/2^n ) for PI = " + repr(units
/65536.0) + " units"
38 # compute range of "i"
45 x
= 1.0/(2.0**n
) # tangent value
49 angle
= math
.atan(x
) # arctangent
50 angle2
= angle
*scale
# arctangent in FT_Angle units
52 # determine which integer value for angle gives the best tangent
55 tlo
= math
.tan(lo
/scale
)
56 thi
= math
.tan(hi
/scale
)
58 errlo
= abs( tlo
- x
)
59 errhi
= abs( thi
- x
)
68 sys
.stdout
.write( comma
+ repr( int(angle2
) ) )
71 shrink
= shrink
* math
.cos( angle2
/scale
)
75 print "shrink factor = " + repr( shrink
)
76 print "shrink factor 2 = " + repr( shrink
* (2.0**32) )
77 print "expansion factor = " + repr(1/shrink
)