From 622d5bd3c0553ebbff09f86801fa561231694595 Mon Sep 17 00:00:00 2001 From: DaMichel Date: Sun, 15 Feb 2015 12:20:07 +0100 Subject: lerp ftw --- qfunctionconfigurator/functionconfig.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 4f808c80..1ed6d54f 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; -- cgit v1.2.3 From a1a1bab331843cf7fea34c7f64e1c8b4bbe73875 Mon Sep 17 00:00:00 2001 From: DaMichel Date: Sun, 15 Feb 2015 12:22:16 +0100 Subject: tabs --- qfunctionconfigurator/functionconfig.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 1ed6d54f..e4a7e283 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -24,12 +24,12 @@ Map::Map() : float Map::getValue(float x) { QMutexLocker foo(&_mutex); - double q = x * (double) MEMOIZE_PRECISION; + 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. + 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; -- cgit v1.2.3