diff options
-rw-r--r-- | filter-kalman/ftnoir_kalman_filtercontrols.ui | 24 | ||||
-rw-r--r-- | filter-kalman/kalman.h | 27 |
2 files changed, 39 insertions, 12 deletions
diff --git a/filter-kalman/ftnoir_kalman_filtercontrols.ui b/filter-kalman/ftnoir_kalman_filtercontrols.ui index 2e9bcae7..6ec18ba8 100644 --- a/filter-kalman/ftnoir_kalman_filtercontrols.ui +++ b/filter-kalman/ftnoir_kalman_filtercontrols.ui @@ -9,7 +9,7 @@ <rect> <x>0</x> <y>0</y> - <width>431</width> + <width>438</width> <height>141</height> </rect> </property> @@ -52,11 +52,14 @@ <item row="0" column="1"> <widget class="QSlider" name="noiseRotSlider"> <property name="maximum"> - <number>10000</number> + <number>400</number> </property> <property name="singleStep"> <number>1</number> </property> + <property name="pageStep"> + <number>100</number> + </property> <property name="tracking"> <bool>true</bool> </property> @@ -67,10 +70,10 @@ <bool>false</bool> </property> <property name="tickPosition"> - <enum>QSlider::NoTicks</enum> + <enum>QSlider::TicksBelow</enum> </property> <property name="tickInterval"> - <number>10</number> + <number>100</number> </property> </widget> </item> @@ -84,16 +87,19 @@ <item row="1" column="1"> <widget class="QSlider" name="noisePosSlider"> <property name="maximum"> - <number>10000</number> + <number>400</number> + </property> + <property name="pageStep"> + <number>100</number> </property> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> <property name="tickPosition"> - <enum>QSlider::NoTicks</enum> + <enum>QSlider::TicksBelow</enum> </property> <property name="tickInterval"> - <number>10</number> + <number>100</number> </property> </widget> </item> @@ -101,7 +107,7 @@ <widget class="QLabel" name="noiseRotLabel"> <property name="minimumSize"> <size> - <width>60</width> + <width>65</width> <height>0</height> </size> </property> @@ -114,7 +120,7 @@ <widget class="QLabel" name="noisePosLabel"> <property name="minimumSize"> <size> - <width>60</width> + <width>65</width> <height>0</height> </size> </property> 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() : |