Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
cordic.py
Go to the documentation of this file.
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 
typedef int
Definition: png.h:978
T round(T x)
Definition: glsl_math.hpp:764