math: Add degrees->radians and radians->degrees procedures.
authorDavid Thompson <dthompson2@worcester.edu>
Thu, 19 Dec 2019 13:17:45 +0000 (08:17 -0500)
committerDavid Thompson <dthompson2@worcester.edu>
Tue, 7 Apr 2020 20:10:23 +0000 (16:10 -0400)
chickadee/math.scm

index b695e92..050dac1 100644 (file)
@@ -23,7 +23,9 @@
             clamp
             min
             max
-            lerp)
+            lerp
+            degrees->radians
+            radians->degrees)
   #:replace (min max))
 
 (define pi 3.14159265358979323846)
@@ -65,3 +67,9 @@ actually less than MAX."
 (define-inlinable (lerp start end alpha)
   (+ (* start (- 1.0 alpha))
      (* end alpha)))
+
+(define-inlinable (degrees->radians degrees)
+  (/ (* pi degrees) 180.0))
+
+(define-inlinable (radians->degrees radians)
+  (/ (* 180.0 radians) pi))