summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-07-12 10:46:32 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-07-12 10:46:32 +0200
commit3ffc10b1208fd7afca500cb3caec25b05f9b446d (patch)
treeba73cae0adab24875e991d0c40269c042b7fda1d
parentf396490f2d15d699d8299b91406a9791b38c7237 (diff)
accela: introduce constants for scaling's magic numbers
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela.cpp10
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela.h5
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp10
3 files changed, 15 insertions, 10 deletions
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp
index 4d5f4a28..5d89bc96 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp
+++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp
@@ -69,16 +69,16 @@ void FTNoIR_Filter::filter(const double* input, double *output)
return;
}
- const double rot_t = 10. * (1+s.rot_threshold) / 100.;
- const double trans_t = 5. * (1+s.trans_threshold) / 100.;
+ const double rot_t = (1+s.rot_threshold) * s.mult_rot;
+ const double trans_t = (1+s.trans_threshold) * s.mult_trans;
const double dt = t.elapsed() * 1e-9;
t.start();
- const double RC = 2 * s.ewma / 1000.; // seconds
+ const double RC = s.mult_ewma * s.ewma / 1000.; // seconds
const double alpha = dt/(dt+RC);
- const double rot_dz = s.rot_deadzone * 2. / 100.;
- const double trans_dz = s.trans_deadzone * 1. / 100.;
+ const double rot_dz = s.rot_deadzone * s.mult_rot_dz;
+ const double trans_dz = s.trans_deadzone * s.mult_trans_dz;
for (int i = 0; i < 6; i++)
{
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h
index e45af03a..4b0d528f 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela.h
+++ b/ftnoir_filter_accela/ftnoir_filter_accela.h
@@ -12,6 +12,11 @@ using namespace options;
struct settings : opts {
value<int> rot_threshold, trans_threshold, ewma, rot_deadzone, trans_deadzone;
+ static constexpr double mult_rot = 10. / 100.;
+ static constexpr double mult_trans = 5. / 100.;
+ static constexpr double mult_rot_dz = 2. / 100.;
+ static constexpr double mult_trans_dz = 1. / 100.;
+ static constexpr double mult_ewma = 2.;
settings() :
opts("Accela"),
rot_threshold(b, "rotation-threshold", 30),
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp
index 52c8318a..dbac8362 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp
+++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp
@@ -62,27 +62,27 @@ void FilterControls::save() {
void FilterControls::update_rot_display(int value)
{
- ui.rot_gain->setText(QString::number((value + 1) * 10 / 100.) + "°");
+ ui.rot_gain->setText(QString::number((value + 1) * s.mult_rot) + "°");
}
void FilterControls::update_trans_display(int value)
{
- ui.trans_gain->setText(QString::number((value + 1) * 5 / 100.) + "mm");
+ ui.trans_gain->setText(QString::number((value + 1) * s.mult_trans) + "mm");
}
void FilterControls::update_ewma_display(int value)
{
- ui.ewma_label->setText(QString::number(value * 2) + "ms");
+ ui.ewma_label->setText(QString::number(value * s.mult_ewma) + "ms");
}
void FilterControls::update_rot_dz_display(int value)
{
- ui.rot_dz->setText(QString::number(value * 2 / 100.) + "°");
+ ui.rot_dz->setText(QString::number(value * s.mult_rot_dz) + "°");
}
void FilterControls::update_trans_dz_display(int value)
{
- ui.trans_dz->setText(QString::number(value * 1 / 100.) + "mm");
+ ui.trans_dz->setText(QString::number(value * s.mult_trans_dz) + "mm");
}
extern "C" OPENTRACK_EXPORT IFilterDialog* GetDialog()