Last active
July 9, 2019 12:37
-
-
Save dvdfreitag/214cda06be4ac22b19b061af698d0975 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import * | |
steps = 8 | |
values = [[[0, 0] * steps for j in range(steps)] * 4 for i in range(4)] | |
for i in range(0, steps): | |
if i == 0: | |
x = 0 | |
else: | |
x = pi / (2.0 * (steps / i)) | |
a = round(100 * sin(x)) | |
b = round(100 * cos(x)) | |
values[0][i][0] = a; | |
values[0][i][1] = b; | |
values[1][i][0] = b; | |
values[1][i][1] = -a; | |
values[2][i][0] = -a; | |
values[2][i][1] = -b; | |
values[3][i][0] = -b; | |
values[3][i][1] = a; | |
print("const int8_t sin_table[4][{}][2] =\n{{".format(steps)) | |
for i in range(4): | |
print(" {", end="") | |
for j in range(steps): | |
print("{{{0:4},{1:4}}}".format(values[i][j][0], values[i][j][1]), end="") | |
if j < (steps - 1): | |
print(",", end="") | |
if i < 3: | |
print("},") | |
else: | |
print("}") | |
print("};") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment