GLIBC 2.27 added new versioned symbols of powf and logf, while the double versions of pow and log remained stable. Prefer the double version to avoid introducing a dependency on a newer version of GLIBC than strictly necessary. See https://lists.gnu.org/archive/html/info-gnu/2018-02/msg00000.html
23 lines
573 B
C++
23 lines
573 B
C++
#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
|