summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjules <jules@okfoc.us>2013-12-17 09:00:29 -0500
committerjules <jules@okfoc.us>2013-12-17 09:00:29 -0500
commitc18321ceedd7be750f5789109c8503e4a36f39bf (patch)
treef2ad039628a83787e18c3fb137e1e7fa31998eda
parente35a3884a0d8eff37954aa3ad71b46821b14d89d (diff)
dist & angle
-rw-r--r--instructions.html2
-rw-r--r--js/util.js4
2 files changed, 5 insertions, 1 deletions
diff --git a/instructions.html b/instructions.html
index 25f6e32..612cf2e 100644
--- a/instructions.html
+++ b/instructions.html
@@ -34,6 +34,8 @@ step(n,a,b)
smoothstep(n,a,b)
cosp, sinp (mapped to [0,1])
pixel(x,y) == 4*(y*w+h)
+dist(x,y,a,b)
+angle(x,y,a,b)
rand(n), randint(n)
choice(array)
deg(radians), rad(degrees)
diff --git a/js/util.js b/js/util.js
index bbf8674..7ecb20b 100644
--- a/js/util.js
+++ b/js/util.js
@@ -41,7 +41,9 @@ function choice(a){ return a[randint(a.length)] }
function deg(n){ return n*180/PI }
function rad(n){ return n*PI/180 }
function pixel(x,y){ return 4*(y*w+x) }
-function mod(n,m){ return n-(m * Math.floor(n/m)) }
+function mod(n,m){ return n-(m * floor(n/m)) }
+function dist(x0,y0,x1,y1){ return sqrt(pow(x1-x0,2)+pow(y1-y0,2) }
+function angle(x0,y0,x1,y1){ return atan2(y1-y0,x1-x0) }
function step (n,a,b) {
return clamp((n - a) / (b - a), 0.0, 1.0);