Generate sin and cos tables
This commit is contained in:
parent
030eeea846
commit
bc947a6c7f
3 changed files with 8230 additions and 0 deletions
4102
axl_cos_table.inc
Normal file
4102
axl_cos_table.inc
Normal file
File diff suppressed because it is too large
Load diff
4102
axl_sin_table.inc
Normal file
4102
axl_sin_table.inc
Normal file
File diff suppressed because it is too large
Load diff
26
gen_math_tables.py
Normal file
26
gen_math_tables.py
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/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