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:
Marc Jansen
2015-10-09 23:04:00 +02:00
parent 93f371ab9f
commit 449131a516

View File

@@ -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;
};