diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-04-20 12:01:46 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-04-20 12:01:46 +0200 |
commit | 2831073f85b502ed0b00c3fb335fadfd705524a5 (patch) | |
tree | 695ad03668a87e69b54688843aefe34a8ee4db60 /include | |
parent | 219737ffa656dd71a69b7d54d9c50f8f8ce20298 (diff) | |
parent | 8b44cfeb7642c74307c4c946fded280fe7e7bbad (diff) | |
download | qtlocation-mapboxgl-2831073f85b502ed0b00c3fb335fadfd705524a5.tar.gz |
Merge pull request #1295 from mapbox/1199-whee
Ensure correct spin direction
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/util/math.hpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/include/mbgl/util/math.hpp b/include/mbgl/util/math.hpp index e800fc7847..647fa5e67f 100644 --- a/include/mbgl/util/math.hpp +++ b/include/mbgl/util/math.hpp @@ -99,6 +99,12 @@ T clamp(T value, T min, T max) { } template <typename T> +T wrap(T value, T min, T max) { + T d = max - min; + return value == max ? value : std::fmod((std::fmod((value - min), d) + d), d) + min; +} + +template <typename T> T smoothstep(T edge0, T edge1, T x) { T t = clamp((x - edge0) / (edge1 - edge0), T(0), T(1)); return t * t * (T(3) - T(2) * t); |