Useful Functions

javascript
// random const random = (min, max) => Math.random() * (max - min + 1) + min // map const map = (s, a1, a2, b1, b2) => b1 + (s - a1) * (b2 - b1) / (a2 - a1) // to radians const radian = d => d * (Math.PI / 180) // timestamp const timestamp = _ => new Date().getTime() // rotate point function rotatePoint(x,y,ox,oy,theta) { return [ Math.cos(theta) * (x-ox) - Math.sin(theta) * (y-oy) + ox, Math.sin(theta) * (x-ox) + Math.cos(theta) * (y-oy) + oy ] }

Reference

No known

History Oct 24, 2018