From 128cb6525535acbddd324861c8d124e7f1729e18 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 5 Feb 2018 19:37:41 +0100 Subject: tracker/hatire: clamp rotation to (-180)->180 Some devices have numeric stability problems. --- tracker-hatire/ftnoir_tracker_hat.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tracker-hatire/ftnoir_tracker_hat.cpp b/tracker-hatire/ftnoir_tracker_hat.cpp index a3f10d35..9ac44cf2 100644 --- a/tracker-hatire/ftnoir_tracker_hat.cpp +++ b/tracker-hatire/ftnoir_tracker_hat.cpp @@ -10,6 +10,7 @@ */ #include #include "ftnoir_tracker_hat.h" +#include "compat/math.hpp" #include hatire::hatire() @@ -128,6 +129,9 @@ void hatire::data(double *data) CptError=0; } + for (unsigned k = 0; k < 3; k++) + HAT.Rot[k] = clamp(HAT.Rot[k], -180, 180); + const struct { bool enable; @@ -147,7 +151,7 @@ void hatire::data(double *data) for (unsigned i = 0; i < std::size(spec); i++) { auto& k = spec[i]; - k.place = (k.sign ? -1.f : 1.f) * (k.enable ? k.input : 0.f); + k.place = (k.sign ? -1 : 1) * (k.enable ? k.input : 0); } } -- cgit v1.2.3