summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-06 10:34:52 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-07 21:03:42 +0200
commitf76be9a78c531a4a882bc2e37eb423ddecccff5b (patch)
tree52757a32795049191f4cb293a17af9259880cd3e
parenta497af1ad4298de4ae9fab4453a0164950c4faf4 (diff)
logic/simple-mat: fix axis swap sign
It lied in euler-to-rmat and not rmat-to-euler because rotating a vector by an rmat returned a vector as if rmat had different signs
-rw-r--r--opentrack-logic/simple-mat.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/opentrack-logic/simple-mat.cpp b/opentrack-logic/simple-mat.cpp
index 6397ed4e..1aaeb296 100644
--- a/opentrack-logic/simple-mat.cpp
+++ b/opentrack-logic/simple-mat.cpp
@@ -12,21 +12,21 @@ euler_t OPENTRACK_LOGIC_EXPORT rmat_to_euler(const dmat<3, 3>& R)
const double cy = sqrt(R(2,2)*R(2, 2) + R(2, 1)*R(2, 1));
const bool large_enough = cy > 1e-10;
if (large_enough)
- return euler_t(atan2(-R(2, 1), R(2, 2)),
+ return euler_t(atan2(-R(1, 0), R(0, 0)),
atan2(R(2, 0), cy),
- atan2(-R(1, 0), R(0, 0)));
+ atan2(-R(2, 1), R(2, 2)));
else
- return euler_t(0.,
+ return euler_t(atan2(R(0, 1), R(1, 1)),
atan2(R(2, 0), cy),
- atan2(R(0, 1), R(1, 1)));
+ 0);
}
// tait-bryan angles, not euler
rmat OPENTRACK_LOGIC_EXPORT euler_to_rmat(const euler_t& input)
{
- const double H = input(0);
- const double P = input(1);
- const double B = input(2);
+ const double H = -input(0);
+ const double P = -input(1);
+ const double B = -input(2);
using std::cos;
using std::sin;