diff options
Diffstat (limited to 'src/mbgl/util/interpolate.hpp')
-rw-r--r-- | src/mbgl/util/interpolate.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mbgl/util/interpolate.hpp b/src/mbgl/util/interpolate.hpp new file mode 100644 index 0000000000..c9232db4eb --- /dev/null +++ b/src/mbgl/util/interpolate.hpp @@ -0,0 +1,27 @@ +#ifndef MBGL_UTIL_INTERPOLATE +#define MBGL_UTIL_INTERPOLATE + +#include <array> + +namespace mbgl { +namespace util { + +template <typename T> +T interpolate(const T a, const T b, const double t) { + return a * (1.0 - t) + b * t; +} + +template <typename T> +inline std::array<T, 4> interpolate(const std::array<T, 4>& a, const std::array<T, 4>& b, const double t) { + return {{ + interpolate(a[0], b[0], t), + interpolate(a[1], b[1], t), + interpolate(a[2], b[2], t), + interpolate(a[3], b[3], t) + }}; +} + +} +} + +#endif |