Math#snapToFloor()

snapToFloor(input, gap, start) → {number} Snap a value to nearest grid slice, using floor. Example: if you have an interval gap of 5 and a position of 12... you will snap to 10.As will 14 snap to 10... but 16 will snap to 15. Parameters Name Type Argument Default Description input number The value to snap. gap number The interval gap of the grid. start number <optional> 0 Optional starting offset for gap. Returns number - The snapped value. Source code: math/Ma

Math#snapToCeil()

snapToCeil(input, gap, start) → {number} Snap a value to nearest grid slice, using ceil. Example: if you have an interval gap of 5 and a position of 12... you will snap to 15.As will 14 will snap to 15... but 16 will snap to 20. Parameters Name Type Argument Default Description input number The value to snap. gap number The interval gap of the grid. start number <optional> 0 Optional starting offset for gap. Returns number - The snapped value. Source code: math

Math#snapTo()

snapTo(input, gap, start) → {number} Snap a value to nearest grid slice, using rounding. Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15. Parameters Name Type Argument Default Description input number The value to snap. gap number The interval gap of the grid. start number <optional> 0 Optional starting offset for gap. Returns number - The snapped value. Source code: math/Math.js (Line 155)

Math#smoothstep()

smoothstep(x, min, max) → {float} Smoothstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep Parameters Name Type Description x float The input value. min float The left edge. Should be smaller than the right edge. max float The right edge. Returns float - A value between 0 and 1. Source code: math/Math.js (Line 1102)

Math#smootherstep()

smootherstep(x, min, max) → {float} Smootherstep function as detailed at http://en.wikipedia.org/wiki/Smoothstep Parameters Name Type Description x float The input value. min float The left edge. Should be smaller than the right edge. max float The right edge. Returns float - A value between 0 and 1. Source code: math/Math.js (Line 1121)

Math#sinCosGenerator()

sinCosGenerator(length, sinAmplitude, cosAmplitude, frequency) → {Object} Generate a sine and cosine table simultaneously and extremely quickly.The parameters allow you to specify the length, amplitude and frequency of the wave.This generator is fast enough to be used in real-time.Code based on research by Franky of scene.at Parameters Name Type Description length number The length of the wave sinAmplitude number The amplitude to apply to the sine table (default 1.0) if you need values b

Math#sign()

sign(x) → {integer} A value representing the sign of the value: -1 for negative, +1 for positive, 0 if value is 0. This works differently from Math.sign for values of NaN and -0, etc. Parameters Name Type Description x number Returns integer - An integer in {-1, 0, 1} Source code: math/Math.js (Line 1138)

Math#shear()

shear(n) → {number} Parameters Name Type Description n number Returns number - n mod 1 Source code: math/Math.js (Line 144)

Math#roundTo()

roundTo(value, place, base) → {number} Round to some place comparative to a base, default is 10 for decimal place.The place is represented by the power applied to base to get that place. e.g. 2000/7 ~= 285.714285714285714285714 ~= (bin)100011101.1011011011011011 roundTo(2000/7,3) === 0 roundTo(2000/7,2) == 300 roundTo(2000/7,1) == 290 roundTo(2000/7,0) == 286 roundTo(2000/7,-1) == 285.7 roundTo(2000/7,-2) == 285.71 roundTo(2000/7,-3) == 285.714 roundTo(2000/7,-4) == 285.7143 roundTo(2000/7,-

Math#roundAwayFromZero()

roundAwayFromZero(value) → {integer} Round to the next whole number away from zero. Parameters Name Type Description value number Any number. Returns integer - The rounded value of that number. Source code: math/Math.js (Line 916)