mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Much better tests, and a little bit more functionality.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -31,6 +31,26 @@ namespace Eigen
|
||||
enum { value = -Num };
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user