Use MDN polyfill for Math.cosh
This commit replaces the current implementation of ol.math.cosh with the reference implementation of the Mozilla developer network. This method only has one call to the Math.exp-function compared to two in the original implementation. See also: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh
This commit is contained in:
1 parent
93f371ab9f
commit
449131a516
1 file changed
+2
-1
+2
-1
@@ -21,7 +21,8 @@ ol.math.clamp = function(value, min, max) {
|
||||
* @return {number} Hyperbolic cosine of x.
|
||||
*/
|
||||
ol.math.cosh = function(x) {
|
||||
return (Math.exp(x) + Math.exp(-x)) / 2;
|
||||
var y = Math.exp(x);
|
||||
return (y + 1 / y) / 2;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user