summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-02-17 04:24:19 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-02-17 04:24:19 +0100
commit9e77315ecb6f5b5aaafa2be600fea3706142515e (patch)
tree6ad9cd71d6305484d44a1a4ce62ef680f8a6c71a
parent6820de3418ee3816b99de5d15dfa7416304cde0d (diff)
parenta1a1bab331843cf7fea34c7f64e1c8b4bbe73875 (diff)
Merge pull request #135 from DaMichel/mapping-pr
Linear Interpolation of Mapping Curves
-rw-r--r--qfunctionconfigurator/functionconfig.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp
index 4f808c80..e4a7e283 100644
--- a/qfunctionconfigurator/functionconfig.cpp
+++ b/qfunctionconfigurator/functionconfig.cpp
@@ -24,8 +24,12 @@ Map::Map() :
float Map::getValue(float x) {
QMutexLocker foo(&_mutex);
- int x2 = x * (double) MEMOIZE_PRECISION;
- float ret = getValueInternal(x2);
+ double q = x * (double) MEMOIZE_PRECISION;
+ int xi = (int)q;
+ float yi = getValueInternal(xi);
+ float yiplus1 = getValueInternal(xi+1);
+ float f = (q-xi);
+ float ret = yiplus1 * f + yi * (1.0f - f); // at least do a linear interpolation.
last_input_value.setX(x);
last_input_value.setY(ret);
return ret;