12 #include <unsupported/Eigen/EulerAngles> 14 using namespace Eigen;
16 template<
typename EulerSystem,
typename Scalar>
18 bool positiveRangeAlpha,
bool positiveRangeBeta,
bool positiveRangeGamma)
27 Scalar alphaRangeStart, alphaRangeEnd;
28 Scalar betaRangeStart, betaRangeEnd;
29 Scalar gammaRangeStart, gammaRangeEnd;
31 if (positiveRangeAlpha)
33 alphaRangeStart =
Scalar(0);
42 if (positiveRangeBeta)
44 betaRangeStart =
Scalar(0);
53 if (positiveRangeGamma)
55 gammaRangeStart =
Scalar(0);
72 const Vector3
I = EulerAnglesType::AlphaAxisVector();
73 const Vector3
J = EulerAnglesType::BetaAxisVector();
74 const Vector3
K = EulerAnglesType::GammaAxisVector();
76 EulerAnglesType
e(ea[0], ea[1], ea[2]);
79 Vector3 eabis = EulerAnglesType(m, positiveRangeAlpha, positiveRangeBeta, positiveRangeGamma).angles();
82 VERIFY(alphaRangeStart <= eabis[0] && eabis[0] <= alphaRangeEnd);
83 VERIFY(betaRangeStart <= eabis[1] && eabis[1] <= betaRangeEnd);
84 VERIFY(gammaRangeStart <= eabis[2] && eabis[2] <= gammaRangeEnd);
86 Vector3 eabis2 = m.eulerAngles(i, j, k);
94 if (positiveRangeAlpha && (eabis2[0] < 0))
96 if (positiveRangeBeta && (eabis2[1] < 0))
98 if (positiveRangeGamma && (eabis2[2] < 0))
103 Matrix3 mbis(AngleAxisType(eabis[0], I) * AngleAxisType(eabis[1], J) * AngleAxisType(eabis[2], K));
107 if (!(positiveRangeAlpha || positiveRangeBeta || positiveRangeGamma))
112 VERIFY((ea-eabis).norm() <= test_precision<Scalar>());
120 eabis = EulerAnglesType(q, positiveRangeAlpha, positiveRangeBeta, positiveRangeGamma).angles();
124 template<
typename EulerSystem,
typename Scalar>
127 verify_euler_ranged<EulerSystem>(ea,
false,
false,
false);
128 verify_euler_ranged<EulerSystem>(ea,
false,
false,
true);
129 verify_euler_ranged<EulerSystem>(ea,
false,
true,
false);
130 verify_euler_ranged<EulerSystem>(ea,
false,
true,
true);
131 verify_euler_ranged<EulerSystem>(ea,
true,
false,
false);
132 verify_euler_ranged<EulerSystem>(ea,
true,
false,
true);
133 verify_euler_ranged<EulerSystem>(ea,
true,
true,
false);
134 verify_euler_ranged<EulerSystem>(ea,
true,
true,
true);
139 verify_euler<EulerSystemXYZ>(ea);
140 verify_euler<EulerSystemXYX>(ea);
141 verify_euler<EulerSystemXZY>(ea);
142 verify_euler<EulerSystemXZX>(ea);
144 verify_euler<EulerSystemYZX>(ea);
145 verify_euler<EulerSystemYZY>(ea);
146 verify_euler<EulerSystemYXZ>(ea);
147 verify_euler<EulerSystemYXY>(ea);
149 verify_euler<EulerSystemZXY>(ea);
150 verify_euler<EulerSystemZXZ>(ea);
151 verify_euler<EulerSystemZYX>(ea);
152 verify_euler<EulerSystemZYZ>(ea);
165 q1 = AngleAxisType(a, Vector3::Random().normalized());
169 Vector3 ea = m.eulerAngles(0,1,2);
171 ea = m.eulerAngles(0,1,0);
175 q1.coeffs() = Quaternionx::Coefficients::Random().normalized();
177 ea = m.eulerAngles(0,1,2);
179 ea = m.eulerAngles(0,1,0);
183 ea = (Array3::Random() + Array3(1,0,0))*
Scalar(
EIGEN_PI)*Array3(0.5,1,1);
195 ea.head(2).setZero();
205 CALL_SUBTEST_1( eulerangles<float>() );
206 CALL_SUBTEST_2( eulerangles<double>() );
void verify_euler_ranged(const Matrix< Scalar, 3, 1 > &ea, bool positiveRangeAlpha, bool positiveRangeBeta, bool positiveRangeGamma)
Namespace containing all symbols from the Eigen library.
static Cal3_S2 K(500, 500, 0.1, 640/2, 480/2)
bool test_isMuchSmallerThan(const int &a, const int &b)
void verify_euler(const Matrix< Scalar, 3, 1 > &ea)
#define VERIFY_IS_APPROX(a, b)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Represents a rotation in a 3 dimensional space as three Euler angles.
EIGEN_DEVICE_FUNC const Scalar & q
JacobiRotation< float > J
The quaternion class used to represent 3D orientations and rotations.
General-purpose arrays with easy API for coefficient-wise operations.
void check_all_var(const Matrix< Scalar, 3, 1 > &ea)
EIGEN_DEVICE_FUNC bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.