summaryrefslogtreecommitdiffhomepage
path: root/tracker-steamvr/steamvr.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-05-21 08:37:11 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-05-21 08:37:11 +0200
commitec88c2032420cad4920e516a176fb7866be9074f (patch)
treeb90a592dcaa9aa324c0df57c7eeb57b795a77f2e /tracker-steamvr/steamvr.cpp
parent49efdd88361e564139d5f0cd365779ab48425e1c (diff)
tracker/steamvr: fix formulae, pitch is/was broken
@KydDynoMyte said on reddit pitch goes +180 on yaw over 90. It must be invalid matrix elements used in the call to atan2. Replace with the version from April. cf. https://www.reddit.com/r/Vive/comments/63qula/opentracks_almostdone_vive_support/dhrgh5l/?context=3
Diffstat (limited to 'tracker-steamvr/steamvr.cpp')
-rw-r--r--tracker-steamvr/steamvr.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/tracker-steamvr/steamvr.cpp b/tracker-steamvr/steamvr.cpp
index 3f0cd1d4..4cdec5e8 100644
--- a/tracker-steamvr/steamvr.cpp
+++ b/tracker-steamvr/steamvr.cpp
@@ -282,12 +282,13 @@ void steamvr::matrix_to_euler(double& yaw, double& pitch, double& roll, const vr
{
using std::atan2;
using std::sqrt;
+ using std::asin;
using d = double;
yaw = atan2(d(result.m[2][0]), d(result.m[0][0]));
- pitch = atan2(d(result.m[2][1]), d(result.m[2][2]));
- roll = atan2(d(result.m[1][0]), d(result.m[0][0]));
+ pitch = atan2(-d(result.m[1][2]), d(result.m[1][1]));
+ roll = asin(d(result.m[1][0]));
// TODO: gimbal lock avoidance?
}