I don't think I will do 16.16 math anymore
This commit is contained in:
parent
d86948b6a9
commit
332c0e3381
3 changed files with 0 additions and 8230 deletions
4102
axl_cos_table.inc
4102
axl_cos_table.inc
File diff suppressed because it is too large
Load diff
4102
axl_sin_table.inc
4102
axl_sin_table.inc
File diff suppressed because it is too large
Load diff
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
import math
|
||||
|
||||
N = 4096
|
||||
FIXED_ONE = 65536
|
||||
|
||||
def generate_table(func_name, math_func):
|
||||
"""Generate a table for the given math function"""
|
||||
with open(f"axl_{func_name}_table.inc", "w") as file:
|
||||
file.write(f"//{func_name}[{N}] - fixed point 16.16\n")
|
||||
file.write("//Generated by gen_math_tables.py\n\n")
|
||||
file.write(f"static inline f16_16 axl_{func_name}_table[{N}] = \n{{\n")
|
||||
for i in range(N):
|
||||
angle = i * 2.0 * math.pi / (N - 1)
|
||||
value = math_func(angle)
|
||||
fixed_value = round(value * FIXED_ONE)
|
||||
file.write(f"\t{fixed_value}{',' if i < N - 1 else ''}\n")
|
||||
file.write("};")
|
||||
|
||||
def main():
|
||||
generate_table("sin", math.sin)
|
||||
generate_table("cos", math.cos)
|
||||
print("Generated sin and cos tables")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in a new issue