summaryrefslogtreecommitdiff
path: root/js/util.js
diff options
context:
space:
mode:
authorjules <jules@okfoc.us>2013-12-16 23:52:28 -0500
committerjules <jules@okfoc.us>2013-12-16 23:52:28 -0500
commitf85814b15b6f6d0a80e0e15dc1d15e8c43147b99 (patch)
tree7aa0811c413a8f57a623c80df75d2615f5ae70f5 /js/util.js
parent12f3f9532fa614b5a0a201e65b06d91c88f68871 (diff)
E, PI, PHI
Diffstat (limited to 'js/util.js')
-rw-r--r--js/util.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/js/util.js b/js/util.js
index e4c50dc..024476e 100644
--- a/js/util.js
+++ b/js/util.js
@@ -10,6 +10,7 @@ function trim(s){ return s.replace(/^\s+/,"").replace(/\s+$/,"") }
var E = Math.E
var PI = Math.PI
+var PHI = (1+Math.sqrt(5))/2
function clamp(n,a,b){ return n<a?a:n<b?n:b }
function lerp(n,a,b){ return (b-a)*n+a }
function mix(n,a,b){ return a*(1-n)+b*n }
@@ -21,15 +22,18 @@ function sign(n){ return Math.abs(n)/n }
function pow(n,b) { return Math.pow(n,b) }
function exp(n) { return Math.exp(n) }
function sqrt(n) { return Math.sqrt(n,b) }
-function sin(n){ return Math.sin(n) }
function cos(n){ return Math.cos(n) }
+function sin(n){ return Math.sin(n) }
function tan(n){ return Math.tan(n) }
-function asin(n){ return Math.sin(n) }
function acos(n){ return Math.cos(n) }
+function asin(n){ return Math.sin(n) }
function atan(n){ return Math.atan(n) }
function atan2(n){ return Math.atan2(n) }
-function sinp(n){ return (Math.sin(n)+1)/2 }
-function cosp(n){ return (Math.cos(n)+1)/2 }
+function sec(n){ return 1/cos(n) }
+function csc(n){ return 1/sin(n) }
+function cot(n){ return 1/tan(n) }
+function cosp(n){ return (1+Math.cos(n))/2 } // cos^2
+function sinp(n){ return (1+Math.sin(n))/2 }
function random(){ return Math.random() }
function rand(n){ return (Math.random()*n) }
function randint(n){ return rand(n)|0 }