summaryrefslogtreecommitdiffhomepage
path: root/filter-kalman/kalman.h
diff options
context:
space:
mode:
authorDaMichel <mw.pub@welter-4d.de>2016-08-04 10:06:36 +0200
committerDaMichel <mw.pub@welter-4d.de>2016-08-04 15:04:12 +0200
commite1658b7ffaae49085ea8ef501b24b8645b071b85 (patch)
treee507edb570a1b9a4bfda493a7fe459c0fb5a6c89 /filter-kalman/kalman.h
parent561c0021630481d9dfba3987a47c1a142be9a2ba (diff)
filter/kalman: log sliders that only change a single decimal digit at a time when moved
Diffstat (limited to 'filter-kalman/kalman.h')
-rw-r--r--filter-kalman/kalman.h27
1 files changed, 24 insertions, 3 deletions
diff --git a/filter-kalman/kalman.h b/filter-kalman/kalman.h
index 3bb5aad2..3c9466a5 100644
--- a/filter-kalman/kalman.h
+++ b/filter-kalman/kalman.h
@@ -96,10 +96,31 @@ struct settings : opts {
static constexpr double process_sigma_pos = 0.5;
static constexpr double process_simga_rot = 0.5;
- static double map_slider_value(const slider_value &v)
+ static double map_slider_value(const slider_value &v_)
{
- //return std::pow(4., v * 5. - 4.) / 4. * 10.; // not so much difference, except that it is harder to adjust the min-max range.
- return std::pow(10., v * 4. - 3.);
+ const double v = v_;
+#if 0
+ //return std::pow(10., v * 4. - 3.);
+#else
+ constexpr int min_log10 = -3;
+ constexpr int max_log10 = 1;
+ constexpr int num_divisions = max_log10 - min_log10;
+ /* ascii art representation of slider
+ // ----- // ------// ------// ------- // 4 divisions
+ -3 - 2 -1 0 1 power of 10
+ | |
+ | f + left_side_log10
+ |
+ left_side_log10
+ */
+ const int k = v * num_divisions; // in which division are we?!
+ const double f = v * num_divisions - k; // where in the division are we?!
+ const double ff = f * 9. + 1.;
+ const double multiplier = int(ff * 10.) / 10.;
+ const int left_side_log10 = min_log10 + k;
+ const double val = std::pow(10., left_side_log10) * multiplier;
+ return val;
+#endif
}
settings() :