From 1725f518183bd5643b8c8f4eb0d16cbecf6d5644 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 17 Jan 2016 23:27:44 +0200 Subject: [PATCH] Add math utils namespace. --- src/uxbox/math.cljs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/uxbox/math.cljs diff --git a/src/uxbox/math.cljs b/src/uxbox/math.cljs new file mode 100644 index 000000000..d073fdc73 --- /dev/null +++ b/src/uxbox/math.cljs @@ -0,0 +1,33 @@ +(ns uxbox.math + "A collection of math utils." + (:require [goog.math :as math])) + +(defn sin + "Returns the sine of a number" + [^number v] + (js/Math.sin v)) + +(defn cos + "Returns the cosine of a number." + [^number v] + (js/Math.cos v)) + +(defn tan + "Returns the tangent of a number." + [^number v] + (js/Math.tan v)) + +(defn neg + "Negate the number" + [^number v] + (- v)) + +(defn radiants + "Converts degrees to radians." + [^number degrees] + (math/toRadians degrees)) + +(defn degrees + "Converts radians to degrees." + [^number radiants] + (math/toDegrees radiants))