summaryrefslogtreecommitdiff
path: root/include/mbgl/util
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2014-08-05 18:04:31 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2014-08-20 13:58:37 -0700
commitb9c7e1bdd99b4c6d37672ef34ffe178d4bc54ad3 (patch)
treed53d5f9068a3501bad712e8c0c3e999a25068297 /include/mbgl/util
parent2660b7bd1b77d9571ceb12adfef4b83e56d8e0f0 (diff)
downloadqtlocation-mapboxgl-b9c7e1bdd99b4c6d37672ef34ffe178d4bc54ad3.tar.gz
Consolidate duplicate interpolation definitions
While here, do not interpolate style properties that are not transitionable. The previous behavior was to switch from old to new value halfway through the transition; now the new value is used immediately, as in JS.
Diffstat (limited to 'include/mbgl/util')
-rw-r--r--include/mbgl/util/interpolate.hpp25
-rw-r--r--include/mbgl/util/math.hpp5
-rw-r--r--include/mbgl/util/transition.hpp6
3 files changed, 25 insertions, 11 deletions
diff --git a/include/mbgl/util/interpolate.hpp b/include/mbgl/util/interpolate.hpp
new file mode 100644
index 0000000000..e8c3389350
--- /dev/null
+++ b/include/mbgl/util/interpolate.hpp
@@ -0,0 +1,25 @@
+#ifndef MBGL_UTIL_INTERPOLATE
+#define MBGL_UTIL_INTERPOLATE
+
+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
diff --git a/include/mbgl/util/math.hpp b/include/mbgl/util/math.hpp
index 277fdc8fc3..fde2a4720b 100644
--- a/include/mbgl/util/math.hpp
+++ b/include/mbgl/util/math.hpp
@@ -57,11 +57,6 @@ inline T angle_to(const vec2<S>& a, const vec2<S>& b) {
return std::atan2(a.y - b.y, a.x - b.x);
}
-template <typename T, typename S1, typename S2>
-inline T interp(S1 a, S2 b, T t) {
- return (a * ((T)1 - t)) + (b * t);
-}
-
// Reflect an angle around 0 degrees
template <typename T>
inline std::array<T, 2> flip(const std::array<T, 2>& c) {
diff --git a/include/mbgl/util/transition.hpp b/include/mbgl/util/transition.hpp
index b12527124e..8a6836c885 100644
--- a/include/mbgl/util/transition.hpp
+++ b/include/mbgl/util/transition.hpp
@@ -30,12 +30,6 @@ public:
virtual ~transition();
protected:
- double interpolateDouble(double from, double to, double t) const;
- float interpolateFloat(float from, float to, double t) const;
- Color interpolateColor(Color from, Color to, double t) const;
- std::array<float, 2> interpolateFloatArray(std::array<float, 2> from, std::array<float, 2> to, double t) const;
-
-protected:
const timestamp start, duration;
};