blob: 6b5736f15f36a83e1841e6a876f5641d1242f940 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <mbgl/util/interpolate.hpp>
#include <cmath>
namespace mbgl {
namespace util {
float interpolationFactor(float base, Range<float> range, float z) {
const float zoomDiff = range.max - range.min;
const float zoomProgress = z - range.min;
if (zoomDiff == 0) {
return 0;
} else if (base == 1.0f) {
return zoomProgress / zoomDiff;
} else {
return (std::pow(static_cast<double>(base), zoomProgress) - 1) /
(std::pow(static_cast<double>(base), zoomDiff) - 1);
}
}
} // namespace util
} // namespace mbgl
|