~ubuntu-branches/ubuntu/quantal/hedgewars/quantal

« back to all changes in this revision

Viewing changes to misc/libfreetype/src/tools/cordic.py

  • Committer: Bazaar Package Importer
  • Author(s): Dmitry E. Oboukhov
  • Date: 2011-09-23 10:16:55 UTC
  • mfrom: (1.1.10 upstream) (3.2.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110923101655-1qxqx6rpqdk8nws1
Tags: 0.9.16-1
* New upstream version.
 + Downloadable content! Simply click to install any content.
   New voices, hats, maps, themes, translations, music, scripts...
   Hedgewars is now more customisable than ever before! As time goes
   by we will be soliciting community content to feature on this page,
   so remember to check it from time to time. If you decide you want
   to go back to standard Hedgewars, just remove the Data directory
   from your Hedgewars config directory.
 + 3-D rendering! Diorama-like rendering of the game in a variety
   of 3D modes. Let us know which ones work best for you, we didn't
   really have the equipment to test them all.
 + Resizable game window.
 + New utilities! The Time Box will remove one of your hedgehogs
   from the game for a while, protecting from attack until it returns,
   somewhere else on the map. Land spray will allow you to build bridges,
   seal up holes, or just make life unpleasant for your enemies.
 + New single player: Bamboo Thicket, That Sinking Feeling, Newton and
   the Tree and multi-player: The Specialists, Space Invaders,
   Racer - scripts! And a ton more script hooks for scripters
 + New twists on old weapons. Drill strike, seduction and fire have
   been adjusted. Defective mines have been added, rope can attach to
   hogs/crates/barrels again, grenades now have variable bounce (use
   precise key + 1-5). Portal gun is now more usable in flight and
   all game actions are a lot faster.
 + New theme - Golf, dozens of new community hats and a new
   localised Default voice, Ukranian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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  = 256
 
6
scale  = units/math.pi
 
7
shrink = 1.0
 
8
comma  = ""
 
9
 
 
10
def calc_val( x ):
 
11
    global units, shrink
 
12
    angle  = math.atan(x)
 
13
    shrink = shrink * math.cos(angle)
 
14
    return angle/math.pi * units
 
15
 
 
16
def  print_val( n, x ):
 
17
    global comma
 
18
 
 
19
    lo  = int(x)
 
20
    hi  = lo + 1
 
21
    alo = math.atan(lo)
 
22
    ahi = math.atan(hi)
 
23
    ax  = math.atan(2.0**n)
 
24
 
 
25
    errlo = abs( alo - ax )
 
26
    errhi = abs( ahi - ax )
 
27
 
 
28
    if ( errlo < errhi ):
 
29
      hi = lo
 
30
 
 
31
    sys.stdout.write( comma + repr( int(hi) ) )
 
32
    comma = ", "
 
33
 
 
34
 
 
35
print ""
 
36
print "table of arctan( 1/2^n ) for PI = " + repr(units/65536.0) + " units"
 
37
 
 
38
# compute range of "i"
 
39
r = [-1]
 
40
r = r + range(32)
 
41
 
 
42
for n in r:
 
43
 
 
44
    if n >= 0:
 
45
        x = 1.0/(2.0**n)    # tangent value
 
46
    else:
 
47
        x = 2.0**(-n)
 
48
 
 
49
    angle  = math.atan(x)    # arctangent
 
50
    angle2 = angle*scale     # arctangent in FT_Angle units
 
51
 
 
52
    # determine which integer value for angle gives the best tangent
 
53
    lo  = int(angle2)
 
54
    hi  = lo + 1
 
55
    tlo = math.tan(lo/scale)
 
56
    thi = math.tan(hi/scale)
 
57
 
 
58
    errlo = abs( tlo - x )
 
59
    errhi = abs( thi - x )
 
60
 
 
61
    angle2 = hi
 
62
    if errlo < errhi:
 
63
        angle2 = lo
 
64
 
 
65
    if angle2 <= 0:
 
66
        break
 
67
 
 
68
    sys.stdout.write( comma + repr( int(angle2) ) )
 
69
    comma = ", "
 
70
 
 
71
    shrink = shrink * math.cos( angle2/scale)
 
72
 
 
73
 
 
74
print
 
75
print "shrink factor    = " + repr( shrink )
 
76
print "shrink factor 2  = " + repr( shrink * (2.0**32) )
 
77
print "expansion factor = " + repr(1/shrink)
 
78
print ""
 
79