diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-12-06 11:04:33 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-12-06 11:04:33 +0000 |
commit | 9c0deb55cabffe00ed8c853eace67b57acb37386 (patch) | |
tree | a93131c63218ec400d28c741b5950bc9ccac4046 /Eigen/src/Geometry/EulerAngles.h | |
parent | faf942a94703208ca740e78b386443afb4505c60 (diff) |
bugfix in matrix to Euler-angles function
Diffstat (limited to 'Eigen/src/Geometry/EulerAngles.h')
-rw-r--r-- | Eigen/src/Geometry/EulerAngles.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Eigen/src/Geometry/EulerAngles.h b/Eigen/src/Geometry/EulerAngles.h index 6087a1433..7e7c2c60a 100644 --- a/Eigen/src/Geometry/EulerAngles.h +++ b/Eigen/src/Geometry/EulerAngles.h @@ -48,6 +48,7 @@ template<typename Derived> inline Matrix<typename MatrixBase<Derived>::Scalar,3,1> MatrixBase<Derived>::eulerAngles(int a0, int a1, int a2) const { + /* Implemented from Graphics Gems IV */ EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,3) Matrix<Scalar,3,1> res; @@ -62,7 +63,6 @@ MatrixBase<Derived>::eulerAngles(int a0, int a1, int a2) const if (a0==a2) { Scalar s = Vector2(coeff(j,i) , coeff(k,i)).norm(); - res[1] = std::atan2(s, coeff(i,i)); if (s > epsilon) { @@ -72,13 +72,12 @@ MatrixBase<Derived>::eulerAngles(int a0, int a1, int a2) const else { res[0] = Scalar(0); - res[2] = std::atan2(-coeff(k,j), coeff(j,j)); + res[2] = (coeff(i,i)>0?1:-1)*std::atan2(-coeff(k,j), coeff(j,j)); } } else { Scalar c = Vector2(coeff(i,i) , coeff(i,j)).norm(); - res[1] = std::atan2(-coeff(i,k), c); if (c > epsilon) { @@ -88,7 +87,7 @@ MatrixBase<Derived>::eulerAngles(int a0, int a1, int a2) const else { res[0] = Scalar(0); - res[2] = -std::atan2(-coeff(k,j), coeff(j,j)); + res[2] = (coeff(i,k)>0?1:-1)*std::atan2(-coeff(k,j), coeff(j,j)); } } if (!odd) |