about summary refs log tree commit diff homepage
path: root/brutalmaze/misc.py
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-03-05 23:59:02 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-03-05 23:59:02 +0700
commit2bafc0c75ac5f9c42593c4905f12bfda66afad1b (patch)
treecd48730ce038060d84872e740ba84619bb9059c6 /brutalmaze/misc.py
parent3cf78b680a5301e0a76c908ed153e9d61b62973d (diff)
downloadbrutalmaze-2bafc0c75ac5f9c42593c4905f12bfda66afad1b.tar.gz
Add documentation for remote control
Diffstat (limited to 'brutalmaze/misc.py')
-rw-r--r--brutalmaze/misc.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/brutalmaze/misc.py b/brutalmaze/misc.py
index 1047114..e6da56c 100644
--- a/brutalmaze/misc.py
+++ b/brutalmaze/misc.py
@@ -19,7 +19,7 @@
 
 __doc__ = 'Brutal Maze module for miscellaneous functions'
 
-from math import cos, sin, pi
+from math import degrees, cos, sin, pi
 from random import uniform
 
 import pygame
@@ -57,6 +57,13 @@ def sign(n):
     return -1 if n < 0 else 1 if n else 0
 
 
+def deg(x):
+    """Convert angle x from radians to degrees casted to a nonnegative
+    integer.
+    """
+    return round2((lambda a: a if a > 0 else a + 360)(degrees(x)))
+
+
 def cosin(x):
     """Return the sum of cosine and sine of x (measured in radians)."""
     return cos(x) + sin(x)