https://github.com/mozilla/gecko-dev
Raw File
Tip revision: 79bc6fa50f588d5ebc6daa726ebebf88a4e4c3c6 authored by Nika Layzell on 21 March 2024, 19:35:40 UTC
Bug 1886852 - Avoid registering unnecessary MessageManager listeners when SHIP is enabled, r=smaug, a=dsmith
Tip revision: 79bc6fa
cordic.py
#!/usr/bin/env python3

# compute arctangent table for CORDIC computations in fttrigon.c
import math

# units  = 64*65536.0   # don't change !!
units = 180 * 2 ** 16
scale = units / math.pi
shrink = 1.0
angles2 = []

print("")
print("table of arctan( 1/2^n ) for PI = " + repr(units / 65536.0) + " units")

for n in range(1, 32):

    x = 0.5 ** n  # tangent value

    angle = math.atan(x)  # arctangent
    angle2 = round(angle * scale)  # arctangent in FT_Angle units

    if angle2 <= 0:
        break

    angles2.append(repr(int(angle2)))
    shrink /= math.sqrt(1 + x * x)

print(", ".join(angles2))
print("shrink factor    = " + repr(shrink))
print("shrink factor 2  = " + repr(int(shrink * (2 ** 32))))
print("expansion factor = " + repr(1 / shrink))
print("")
back to top