diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-11-11 13:22:27 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-11-11 13:22:27 +0100 |
commit | 7a14410a282f76b392eaff1ba2651b820aeb24a4 (patch) | |
tree | 378fbdfff56713c2c7fce6335089907bb25c42b5 /opentrack | |
parent | 60b6f6d8aaa1daf2dfa09ecafd7fdcac827b2e4b (diff) |
sane gimbal lock bounds
Tested-by: @KyokushinPL
Issue: #63
Diffstat (limited to 'opentrack')
-rw-r--r-- | opentrack/tracker.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index 5b36971e..07ea22b5 100644 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -53,12 +53,13 @@ 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.998) + static constexpr double bound = 1. - 2e-4; + if (R(0, 2) > bound) { double roll = atan(R(1, 0) / R(2, 0)); return dmat<3, 1>({0., up, roll}); } - if (R(0, 2) < -0.998) + if (R(0, 2) < -bound) { double roll = atan(R(1, 0) / R(2, 0)); return dmat<3, 1>({0., -up, roll}); |