summaryrefslogtreecommitdiffhomepage
path: root/tracker-steamvr/steamvr.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-04-14 07:11:26 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-04-14 07:11:26 +0200
commitf218f1ea6258e18af38aee6469c70c787ff6de01 (patch)
tree181d11e100109d37b05479fe1c4d16e1345d4dfa /tracker-steamvr/steamvr.cpp
parentacb12232452d6a4be368702eedaa1ba871653eef (diff)
tracker/steamvr: use double promotion for all arithmetic
The computation order isn't defined so parts might only get promoted to double after arithmetic. Promote all parts manually before arithmetic.
Diffstat (limited to 'tracker-steamvr/steamvr.cpp')
-rw-r--r--tracker-steamvr/steamvr.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/tracker-steamvr/steamvr.cpp b/tracker-steamvr/steamvr.cpp
index 8998149c9..d32c9d446 100644
--- a/tracker-steamvr/steamvr.cpp
+++ b/tracker-steamvr/steamvr.cpp
@@ -275,9 +275,11 @@ void steamvr::matrix_to_euler(double& yaw, double& pitch, double& roll, const vr
using std::atan2;
using std::sqrt;
- yaw = atan2((double)-result.m[2][0], sqrt(double(result.m[2][1]) * result.m[2][1] + result.m[2][2] * result.m[2][2]));
- pitch = atan2((double)result.m[2][1], (double)result.m[2][2]);
- roll = atan2((double)result.m[1][0], (double)result.m[0][0]);
+ using d = double;
+
+ yaw = atan2(d(-result.m[2][0]), sqrt(d(result.m[2][1]) * d(result.m[2][1]) + d(result.m[2][2]) * d(result.m[2][2])));
+ pitch = atan2(d(result.m[2][1]), d(result.m[2][2]));
+ roll = atan2(d(result.m[1][0]), d(result.m[0][0]));
// TODO: gimbal lock avoidance?
}