From aa7fe04754cad9c1277e9e19b570b8b69c7f5103 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 12 Sep 2014 08:26:15 +0200 Subject: Correct axis scale logic Issue: #38 --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp') diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index a4f026de..d3f5806b 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -2,6 +2,7 @@ #include "facetracknoir/plugin-support.h" #undef NDEBUG #include +#include FTNoIR_Tracker::FTNoIR_Tracker() : g_pDI(nullptr), @@ -225,9 +226,8 @@ void FTNoIR_Tracker::GetHeadPoseData(double *data) auto mid = (min_[idx] + max_[idx]) / 2; auto val = values[idx] - mid; - auto max = (max_[idx] - mid); - auto min = (mid - min_[idx]); - data[i] = val * limits[i] / (double) (val > 0 ? max : min); + int scale = val > 0 ? abs(max_[idx] - mid) : -abs(mid - min_[idx]); + data[i] = abs(val) * limits[i] / scale; } } } -- cgit v1.2.3