aboutsummaryrefslogtreecommitdiffstats
path: root/tables
diff options
context:
space:
mode:
authornathansmith117 <nathansmith117@sdf.org>2025-02-10 08:12:55 +0000
committernathansmith117 <nathansmith117@sdf.org>2025-02-10 08:12:55 +0000
commitb04d5702719eca30a95d1db2a927b6605ebd3477 (patch)
treec388a6b152c117e2903e7acf63054211739e6df4 /tables
parentfe9b718f8978cfd792f7303214b2dd45172b8d4b (diff)
downloadsldj-b04d5702719eca30a95d1db2a927b6605ebd3477.tar.gz
sldj-b04d5702719eca30a95d1db2a927b6605ebd3477.tar.bz2
sldj-b04d5702719eca30a95d1db2a927b6605ebd3477.zip
Some fast math stuff added
Diffstat (limited to 'tables')
-rwxr-xr-xtables/square_root.py16
-rwxr-xr-xtables/trig_tables.py28
2 files changed, 44 insertions, 0 deletions
diff --git a/tables/square_root.py b/tables/square_root.py
new file mode 100755
index 0000000..67ab9f7
--- /dev/null
+++ b/tables/square_root.py
@@ -0,0 +1,16 @@
+#! /usr/bin/python3
+
+from math import sqrt
+
+table_size = 65536
+line_spacing = 20
+
+print("float sldjSqrtTable[%d] = {" % table_size)
+
+for c in range(table_size):
+ print(f"{sqrt(c)},", end="")
+
+ if c % line_spacing == 0:
+ print()
+
+print("};")
diff --git a/tables/trig_tables.py b/tables/trig_tables.py
new file mode 100755
index 0000000..7425f70
--- /dev/null
+++ b/tables/trig_tables.py
@@ -0,0 +1,28 @@
+#! /usr/bin/python3
+
+from math import *
+
+table_size = 361
+line_spacing = 5
+
+def make_table(func):
+ for c in range(table_size):
+ print(f"{func(radians(c))},", end="")
+
+ if c % line_spacing == 0:
+ print()
+
+ print("};\n")
+
+# Sin.
+print("float sldjSinTable[%d] = {" % table_size)
+make_table(sin)
+
+# Cos.
+print("float sldjCosTable[%d] = {" % table_size)
+make_table(cos)
+
+# Tan
+print("float sldjTanTable[%d] = {" % table_size)
+make_table(tan)
+