Use ol.math.clamp()

This commit is contained in:
Tim Schaub
2015-09-27 09:54:11 -06:00
parent 5cac9d61cc
commit f746cb7f57
12 changed files with 67 additions and 30 deletions
+13
View File
@@ -3,6 +3,19 @@ goog.provide('ol.math');
goog.require('goog.asserts');
/**
* Takes a number and clamps it to within the provided bounds.
* @param {number} value The input number.
* @param {number} min The minimum value to return.
* @param {number} max The maximum value to return.
* @return {number} The input number if it is within bounds, or the nearest
* number within the bounds.
*/
ol.math.clamp = function(value, min, max) {
return Math.min(Math.max(value, min), max);
};
/**
* @param {number} x X.
* @return {number} Hyperbolic cosine of x.