Ensure correct spin direction

Ported mapbox/mapbox-gl-js#821 as well as `util.wrap()` from mapbox-gl-js.

Fixes #1199.
This commit is contained in:
Minh Nguyễn
2015-04-18 22:14:39 -07:00
parent f80238577c
commit 8b44cfeb76
2 changed files with 22 additions and 6 deletions

View File

@@ -98,6 +98,12 @@ T clamp(T value, T min, T max) {
return value < min ? min : (value > max ? max : value);
}
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));