summaryrefslogtreecommitdiff
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
parent12f3f9532fa614b5a0a201e65b06d91c88f68871 (diff)
E, PI, PHI
-rw-r--r--instructions.html8
-rw-r--r--js/util.js12
2 files changed, 12 insertions, 8 deletions
diff --git a/instructions.html b/instructions.html
index f0c6800..435a9d9 100644
--- a/instructions.html
+++ b/instructions.html
@@ -20,10 +20,10 @@ mousex, mousey
<u>Math aliases</u>
floor, ceil, round, abs, sign
pow, exp, sqrt
-sin, cos, tan
-asin, acos, atan, atan2
+cos, sin, tan
+acos, asin, atan, atan2
random()
-E, PI
+E, PI, PHI
<u>convenience functions</u>
clamp(n,min,max)
@@ -31,7 +31,7 @@ lerp(n,a,b)
mix(n,a,b)
step(n,a,b)
smoothstep(n,a,b)
-sinp, cosp (mapped to [0,1])
+cosp, sinp (mapped to [0,1])
pixel(x,y) == 4*(y*w+h)
rand(n), randint(n)
choice(array)
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 }