From 1461489bea1fca789e18d462b52e654e7437c30c Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 14 Dec 2013 02:14:57 -0500 Subject: other math funcs :-p --- js/util.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index 0dffc74..ac0f517 100644 --- a/js/util.js +++ b/js/util.js @@ -11,21 +11,34 @@ function mix(n,a,b){ return a*(1-n)+b*n } function ceil(n){ return Math.ceil(n) } function floor(n){ return Math.floor(n) } function round(n){ return Math.round(n) } +function abs(n){ return Math.abs(n) } +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 tan(n){ return Math.tan(n) } +function asin(n){ return Math.sin(n) } +function acos(n){ return Math.cos(n) } function atan(n){ return Math.atan(n) } +function atan2(n){ return Math.atan2(n) } +function random(){ return Math.random() } function rand(n){ return (Math.random()*n) } function randint(n){ return rand(n)|0 } function choice(a){ return a[randint(a.length)] } function deg(n){ return n*180/PI } function rad(n){ return n*PI/180 } + +function step (n,a,b) { + return clamp((n - a) / (b - a), 0.0, 1.0); +} +// hermite curve apparently function smoothstep(n,a,b){ var t = clamp((n - a) / (b - a), 0.0, 1.0); return t * t * (3.0 - 2.0 * t) } - function loadImage(imageURL, callback) { var imageURL = proxify( imageURL ); -- cgit v1.2.3-70-g09d2