summaryrefslogtreecommitdiffstats
path: root/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'util.py')
-rw-r--r--util.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/util.py b/util.py
new file mode 100644
index 0000000..f06bdfa
--- /dev/null
+++ b/util.py
@@ -0,0 +1,9 @@
+import math
+
+
+def floor_f(f, decimals):
+ return math.floor(f * 10**decimals) / 10**decimals
+
+
+def to_grid(point, delta=0):
+ return tuple((floor_f(val, 3) + delta/1000 for val in point))