Common functions that I've needed over the years.
###Math.randomTo(from, to) * _Creates a psudorandom number within the bounds given._ * _Please note that this is INCLUSIVE_ * __EXAMPLE:__```Math.randomTo(0, 10)``` * __OUTPUT:__ ```3```
###Math.deg(a)
- _Converts from radians to degrees _
-
EXAMPLE:
Math.deg(10)
-
OUTPUT:
572.957795
###Math.deg(a)
- _Converts from radians to degrees _
-
EXAMPLE:
Math.rad(572.957795)
-
OUTPUT:
10
###Math.angle(a, b, rad)
- Returns the angle from Coordinate a to b
- a and b are expected to be arrays of JSON objects as such "a = {x:10, y: 100}"
- Defaults to degrees, unless rad is truthy (non-null)
-
EXAMPLE:
Math.angle({x:0,y:0}, {x:100, y:100})
-
OUTPUT:
45
-
EXAMPLE 2:
Math.angle({x:0,y:0}, {x:100, y:100},true)
-
OUTPUT 2:
0.785398163....
jsCommons by Shane Gadsby is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Based on a work at https://github.com/schme16/jsCommons.