Remove goog.math.modulo and goog.math.lerp

This commit is contained in:
Nicholas Latham
2016-04-04 19:43:24 +12:00
committed by Frédéric Junod
parent 19fd3d6987
commit 2ee1969de7
11 changed files with 82 additions and 23 deletions

View File

@@ -179,3 +179,27 @@ ol.math.toDegrees = function(angleInRadians) {
ol.math.toRadians = function(angleInDegrees) {
return angleInDegrees * Math.PI / 180;
};
/**
* Returns the modulo of a / b, depending on the sign of b.
*
* @param {number} a Dividend.
* @param {number} b Divisor.
* @return {number} Modulo.
*/
ol.math.modulo = function(a, b) {
var r = a % b;
return r * b < 0 ? r + b : r;
};
/**
* Calculates the linearly interpolated value of x between a and b.
*
* @param {number} a Number
* @param {number} b Number
* @param {number} x Value to be interpolated.
* @return {number} Interpolated value.
*/
ol.math.lerp = function(a, b, x) {
return a + x * (b - a);
};