summaryrefslogtreecommitdiff
path: root/app/client/util/math.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/client/util/math.js')
-rw-r--r--app/client/util/math.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/app/client/util/math.js b/app/client/util/math.js
index c301ffd..064d37c 100644
--- a/app/client/util/math.js
+++ b/app/client/util/math.js
@@ -4,14 +4,14 @@ export const norm = (n,a,b) => (n-a) / (b-a)
export const lerp = (n,a,b) => (b-a)*n+a
export const mix = (n,a,b) => a*(1-n)+b*n
export const randint = (n) => Math.floor(Math.random()*n)
-export function randrange(a,b){ return Math.random() * (b-a) + a }
-export function randsign(){ return Math.random() >= 0.5 ? -1 : 1 }
-export function choice (a){ return a[ Math.floor(Math.random() * a.length) ] }
-export function angle(x0,y0,x1,y1){ return Math.atan2(y1-y0,x1-x0) }
-export function dist(x0,y0,x1,y1){ return Math.sqrt(Math.pow(x1-x0,2)+Math.pow(y1-y0,2)) }
-export function xor(a,b){ a=!!a; b=!!b; return (a||b) && !(a&&b) }
-export function quantize(a,b){ return Math.floor(a/b)*b }
-export function shuffle(a){
+export const randrange = (a,b) => Math.random() * (b-a) + a
+export const randsign = () => Math.random() >= 0.5 ? -1 : 1
+export const choice = (a) => a[ Math.floor(Math.random() * a.length) ]
+export const angle = (x0,y0,x1,y1) => Math.atan2(y1-y0, x1-x0)
+export const dist = (x0,y0,x1,y1) => Math.sqrt(Math.pow(x1-x0, 2) + Math.pow(y1-y0, 2))
+export const xor = (a,b) => { a=!!a; b=!!b; return (a||b) && !(a&&b) }
+export const quantize = (a,b) => Math.floor(a/b)*b
+export const shuffle = (a) => {
for (var i = a.length; i > 0; i--){
var r = randint(i)
var swap = a[i-1]