From fa839e3fc9b92a4642d50c28bc607eb97e9ac1df Mon Sep 17 00:00:00 2001 From: Tom Brazier Date: Sat, 10 Jun 2023 16:59:18 +0100 Subject: Change to a quadratic curve for alpha and use a scale where 3 * drift speed results in alpha == 1.0 --- filter-nm/ftnoir_filter_nm.cpp | 10 ++++++---- filter-nm/ftnoir_filter_nm.h | 8 ++++---- filter-nm/ftnoir_nm_filtercontrols.ui | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/filter-nm/ftnoir_filter_nm.cpp b/filter-nm/ftnoir_filter_nm.cpp index 5d274790..b222184b 100644 --- a/filter-nm/ftnoir_filter_nm.cpp +++ b/filter-nm/ftnoir_filter_nm.cpp @@ -42,17 +42,19 @@ void filter_nm::filter(const double* input, double* output) const double pos_tau = 1. / *s.pos_responsiveness; double alpha = dt / (dt + pos_tau); last_pos_speed += (pos_speed - last_pos_speed) * alpha; - alpha *= min(1.0, VectorLength(last_pos_speed) / *s.pos_drift_speed); + const double factor_pos = min(1.0, VectorLength(last_pos_speed) / (*s.pos_drift_speed * 3.0)); + alpha *= factor_pos * factor_pos; last_pos_out += (position - last_pos_out) * alpha; const tQuat rot_delta = QuatDivide(rotation, last_rot_in); - const double ms_per_s = 1000.0; // angular speed quaternions need to be small to work so use °/ms - const tQuat rot_speed = Slerp(tQuat(), rot_delta, 1.0 / dt / ms_per_s); + constexpr double ms_per_s = 1000.0; // angular speed quaternions need to be small to work so use °/ms + const tQuat rot_speed = Slerp(tQuat(), rot_delta, 1.0 / ms_per_s / dt ); const double rot_tau = 1. / *s.rot_responsiveness; alpha = dt / (dt + rot_tau); last_rot_speed = Slerp(last_rot_speed, rot_speed, alpha); const double angular_speed = AngleBetween(tQuat(), last_rot_speed) * ms_per_s; - alpha *= min(1.0, angular_speed / *s.rot_drift_speed); + const double factor_rot = min(1.0, angular_speed / (*s.rot_drift_speed * 3.0)); + alpha *= factor_rot * factor_rot; last_rot_out = Slerp(last_rot_out, rotation, alpha); } diff --git a/filter-nm/ftnoir_filter_nm.h b/filter-nm/ftnoir_filter_nm.h index 7bf012a6..84775207 100644 --- a/filter-nm/ftnoir_filter_nm.h +++ b/filter-nm/ftnoir_filter_nm.h @@ -24,10 +24,10 @@ struct settings_nm : opts settings_nm() : opts("nm-filter"), - pos_responsiveness(value(b, "pos-responsiveness", { 15.0, .0, 20.0 })), - rot_responsiveness(value(b, "rot-responsiveness", { 18.0, .0, 20.0 })), - pos_drift_speed(value(b, "pos-drift-speed", { 30.0, 1.0, 200.0 })), - rot_drift_speed(value(b, "rot-drift-speed", { 45.0, 1.0, 400.0 })) + pos_responsiveness(value(b, "pos-responsiveness", { 13.0, .0, 20.0 })), + rot_responsiveness(value(b, "rot-responsiveness", { 16.0, .0, 20.0 })), + pos_drift_speed(value(b, "pos-drift-speed", { 5.0, 0.1, 50.0 })), + rot_drift_speed(value(b, "rot-drift-speed", { 7.0, 0.1, 50.0 })) { } }; diff --git a/filter-nm/ftnoir_nm_filtercontrols.ui b/filter-nm/ftnoir_nm_filtercontrols.ui index ad307daf..7e317e74 100644 --- a/filter-nm/ftnoir_nm_filtercontrols.ui +++ b/filter-nm/ftnoir_nm_filtercontrols.ui @@ -171,7 +171,7 @@ 1 - 400 + 500 Qt::Horizontal @@ -220,7 +220,7 @@ 1 - 200 + 500 Qt::Horizontal -- cgit v1.2.3