summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--opentrack/mappings.hpp2
-rw-r--r--opentrack/tracker.cpp19
2 files changed, 4 insertions, 17 deletions
diff --git a/opentrack/mappings.hpp b/opentrack/mappings.hpp
index 3b86dfe3..3336dcd8 100644
--- a/opentrack/mappings.hpp
+++ b/opentrack/mappings.hpp
@@ -39,7 +39,7 @@ public:
Mapping("ty","ty_alt", 100, 100, *opts[TY]),
Mapping("tz","tz_alt", 100, 100, *opts[TZ]),
Mapping("rx", "rx_alt", 180, 180, *opts[Yaw]),
- Mapping("ry", "ry_alt", 90, 180, *opts[Pitch]),
+ Mapping("ry", "ry_alt", 180, 180, *opts[Pitch]),
Mapping("rz", "rz_alt", 180, 180, *opts[Roll])
}
{}
diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp
index 4e12132e..8892c85a 100644
--- a/opentrack/tracker.cpp
+++ b/opentrack/tracker.cpp
@@ -51,22 +51,9 @@ double Tracker::map(double pos, bool invertp, Mapping& axis)
// http://stackoverflow.com/a/18436193
static dmat<3, 1> rmat_to_euler(const dmat<3, 3>& R)
{
- static constexpr double pi = 3.141592653;
- const double up = 90 * pi / 180.;
- if (R(0, 2) > 0.9991)
- {
- double roll = atan(R(1, 0) / R(2, 0));
- return dmat<3, 1>({0., up, roll});
- }
- if (R(0, 2) < -0.9991)
- {
- double roll = atan(R(1, 0) / R(2, 0));
- return dmat<3, 1>({0., -up, roll});
- }
- // don't use atan2 here, confuses quadrants. see issue #63 -sh
- double pitch = asin(R(0, 2));
- double roll = atan(R(1, 2) / R(2, 2));
- double yaw = atan(R(0, 1) / R(0, 0));
+ 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});
}