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