From deb7a542d465e69462e0ca500d21db9d97e14aea Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 Jun 2015 10:06:01 +0200 Subject: options: add support for QRadioButton --- opentrack/options.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'opentrack') diff --git a/opentrack/options.hpp b/opentrack/options.hpp index c33c2f53..5511f567 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -450,4 +451,12 @@ namespace options { base_value::connect(t, SIGNAL(currentChanged(int)), &v, SLOT(setValue(int)), v.DIRECT_CONNTYPE); base_value::connect(&v, SIGNAL(valueChanged(int)), t, SLOT(setCurrentIndex(int)), v.SAFE_CONNTYPE); } + + template<> + inline void tie_setting(value& v, QRadioButton* t) + { + t->setChecked(v); + base_value::connect(t, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.DIRECT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(bool)), t, SLOT(setChecked(bool)), v.SAFE_CONNTYPE); + } } -- cgit v1.2.3 From 16a111959fb89594d5cb15bd223372d9d2b3d12b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 Jun 2015 12:04:24 +0200 Subject: simple-mat: allow pitch axis go -180->180 To be reverted if broken --- opentrack/simple-mat.hpp | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'opentrack') diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index 5ee9029c..1cea967e 100644 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace { // last param to fool SFINAE into overloading @@ -215,22 +216,20 @@ struct Mat static dmat<3, 1> rmat_to_euler(const dmat<3, 3>& R) { static constexpr double pi = 3.141592653; - const double up = 90 * pi / 180.; - static constexpr double bound = 1. - 2e-4; - if (R(0, 2) > bound) + const double pitch_1 = asin(-R(0, 2)); + const double pitch_2 = pi - pitch_1; + const double cos_p1 = cos(pitch_1), cos_p2 = cos(pitch_2); + const double roll_1 = atan2(R(1, 2) / cos_p1, R(2, 2) / cos_p1); + const double roll_2 = atan2(R(1, 2) / cos_p2, R(2, 2) / cos_p2); + const double yaw_1 = atan2(R(0, 1) / cos_p1, R(0, 0) / cos_p1); + const double yaw_2 = atan2(R(0, 1) / cos_p2, R(0, 0) / cos_p2); + if (std::abs(pitch_1) + std::abs(roll_1) + std::abs(yaw_1) > std::abs(pitch_2) + std::abs(roll_2) + std::abs(yaw_2)) { - double roll = atan(R(1, 0) / R(2, 0)); - return dmat<3, 1>({0., up, roll}); + bool fix_neg_pitch = pitch_1 < 0; + return dmat<3, 1>({yaw_2, std::fmod(fix_neg_pitch ? -pi - pitch_1 : pitch_2, pi), roll_2}); } - if (R(0, 2) < -bound) - { - double roll = atan(R(1, 0) / R(2, 0)); - return dmat<3, 1>({0., -up, roll}); - } - double pitch = asin(-R(0, 2)); - double roll = atan2(R(1, 2), R(2, 2)); - double yaw = atan2(R(0, 1), R(0, 0)); - return dmat<3, 1>({yaw, pitch, roll}); + else + return dmat<3, 1>({yaw_1, pitch_1, roll_1}); } // tait-bryan angles, not euler -- cgit v1.2.3 From 3fafaac47277ff5932aad10e02bd1cd5470f41a5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 18 Jun 2015 08:46:18 +0200 Subject: forgot #pragma once, add headers --- opentrack/state.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'opentrack') diff --git a/opentrack/state.hpp b/opentrack/state.hpp index a9f66241..bfbf113e 100644 --- a/opentrack/state.hpp +++ b/opentrack/state.hpp @@ -1,11 +1,13 @@ +#pragma once + #include #include "opentrack/options.hpp" using namespace options; #include "opentrack/plugin-support.hpp" #include "opentrack/main-settings.hpp" #include "opentrack/mappings.hpp" - -struct Work; +#include "opentrack/selected-libraries.hpp" +#include "opentrack/work.hpp" struct State { State() : -- cgit v1.2.3