diff options
author | Tal Hadad <tal_hd@hotmail.com> | 2015-12-20 12:49:12 +0200 |
---|---|---|
committer | Tal Hadad <tal_hd@hotmail.com> | 2015-12-20 12:49:12 +0200 |
commit | 6752a69aa521d4a0979d575af79b4acfd54dd089 (patch) | |
tree | a51d2706bdc974b4cc6bb48e86536922bfadc9c3 /unsupported/Eigen/src/EulerAngles | |
parent | 5e0a178df2b70829e990e84602fd70f92131484f (diff) |
Much better tests, and a little bit more functionality.
Diffstat (limited to 'unsupported/Eigen/src/EulerAngles')
-rw-r--r-- | unsupported/Eigen/src/EulerAngles/EulerAngles.h | 20 | ||||
-rw-r--r-- | unsupported/Eigen/src/EulerAngles/EulerSystem.h | 26 |
2 files changed, 39 insertions, 7 deletions
diff --git a/unsupported/Eigen/src/EulerAngles/EulerAngles.h b/unsupported/Eigen/src/EulerAngles/EulerAngles.h index b3bd66441..ccde28eb6 100644 --- a/unsupported/Eigen/src/EulerAngles/EulerAngles.h +++ b/unsupported/Eigen/src/EulerAngles/EulerAngles.h @@ -37,16 +37,26 @@ namespace Eigen typedef Matrix<Scalar,3,1> Vector3; typedef Quaternion<Scalar> QuaternionType; typedef AngleAxis<Scalar> AngleAxisType; + + static Vector3 HeadingAxisVector() { + return internal::NegativeIf<System::IsHeadingOpposite>::run(Vector3::Unit(System::HeadingAxisAbs - 1)); + } + + static Vector3 PitchAxisVector() { + return internal::NegativeIf<System::IsPitchOpposite>::run(Vector3::Unit(System::PitchAxisAbs - 1)); + } + + static Vector3 RollAxisVector() { + return internal::NegativeIf<System::IsRollOpposite>::run(Vector3::Unit(System::RollAxisAbs - 1)); + } - protected: - + private: Vector3 m_angles; public: EulerAngles() {} inline EulerAngles(Scalar a0, Scalar a1, Scalar a2) : m_angles(a0, a1, a2) {} - inline EulerAngles(Vector3 angles) : m_angles(angles) {} inline EulerAngles(const QuaternionType& q) { *this = q; } inline EulerAngles(const AngleAxisType& aa) { *this = aa; } template<typename Derived> @@ -116,7 +126,7 @@ namespace Eigen EulerAngles& operator=(const QuaternionType& q){ // TODO: Implement it in a better way // According to http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/ - // we can compute only the needed matrix cells and then convert to euler angles. + // we can compute only the needed matrix cells and then convert to euler angles. (see ZYX example below) // Currently we compute all matrix cells from quaternion. fromRotationMatrix(q.toRotationMatrix()); @@ -131,6 +141,8 @@ namespace Eigen return *this; } + // TODO: Support isApprox function + /** Set \c *this from AngleAxis \a ea. */ EulerAngles& operator=(const AngleAxisType& ea) diff --git a/unsupported/Eigen/src/EulerAngles/EulerSystem.h b/unsupported/Eigen/src/EulerAngles/EulerSystem.h index fc782e914..6ee3f51df 100644 --- a/unsupported/Eigen/src/EulerAngles/EulerSystem.h +++ b/unsupported/Eigen/src/EulerAngles/EulerSystem.h @@ -32,6 +32,26 @@ namespace Eigen }; template <bool Cond> + struct NegativeIf + { + template <typename T> + static T run(const T& t) + { + return -t; + } + }; + + template <> + struct NegativeIf<false> + { + template <typename T> + static T run(const T& t) + { + return t; + } + }; + + template <bool Cond> struct NegateIf { template <typename T> @@ -45,7 +65,7 @@ namespace Eigen struct NegateIf<false> { template <typename T> - static void run(T& t) + static void run(T&) { // no op } @@ -113,7 +133,7 @@ namespace Eigen }; template <typename Derived> - static void eulerAngles_imp(Matrix<typename MatrixBase<Derived>::Scalar, 3, 1>& res, const MatrixBase<Derived>& mat, internal::true_type isTaitBryan) + static void eulerAngles_imp(Matrix<typename MatrixBase<Derived>::Scalar, 3, 1>& res, const MatrixBase<Derived>& mat, internal::true_type /*isTaitBryan*/) { using std::atan2; using std::sin; @@ -136,7 +156,7 @@ namespace Eigen } template <typename Derived> - static void eulerAngles_imp(Matrix<typename MatrixBase<Derived>::Scalar,3,1>& res, const MatrixBase<Derived>& mat, internal::false_type isTaitBryan) + static void eulerAngles_imp(Matrix<typename MatrixBase<Derived>::Scalar,3,1>& res, const MatrixBase<Derived>& mat, internal::false_type /*isTaitBryan*/) { using std::atan2; using std::sin; |