summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2021-12-15 15:03:13 +0100
committerStanislaw Halik <sthalik@misaki.pl>2021-12-16 15:32:03 +0100
commit20ace0b4a885387f1158aa20c7346234cd7e9da4 (patch)
tree3b399e3613b448efdbbb2596100942367cac7e07
parentf8b904c094a5c76863f6e4f053b90251fa23ac12 (diff)
tracker/pt: try fixing point filter sawtooth-like motion
-rw-r--r--tracker-pt/point-filter.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/tracker-pt/point-filter.cpp b/tracker-pt/point-filter.cpp
index 49e82afb..93ad3203 100644
--- a/tracker-pt/point-filter.cpp
+++ b/tracker-pt/point-filter.cpp
@@ -15,6 +15,7 @@ const PointOrder& point_filter::operator()(const PointOrder& input)
using std::fmod;
using std::sqrt;
using std::pow;
+ using std::clamp;
if (!s.enable_point_filter)
{
@@ -39,16 +40,15 @@ const PointOrder& point_filter::operator()(const PointOrder& input)
return A * pow((f)10, (f)-log10_pos) * rest;
);
- f dist = 0;
+ f dist = 1e6;
for (unsigned i = 0; i < 3; i++)
{
vec2 tmp = input[i] - state_[i];
- f x = sqrt(tmp.dot(tmp));
- dist = std::max(dist, x);
+ dist = std::min(dist, sqrt(tmp.dot(tmp)));
}
- if (dist < (f)1e-6)
+ if (dist < (f)1e-6 || dist > (f)1e4)
return state_;
f dt = (f)t->elapsed_seconds(); t->start();
@@ -58,7 +58,7 @@ const PointOrder& point_filter::operator()(const PointOrder& input)
for (unsigned i = 0; i < 3; i++)
{
- f x = std::clamp(delta, (f)0, limit);
+ f x = clamp(delta, (f)0, limit);
state_[i] += x*(input[i] - state_[i]);
}