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);
34 alphaRangeEnd = Scalar(2 *
EIGEN_PI);
42 if (positiveRangeBeta)
44 betaRangeStart = Scalar(0);
53 if (positiveRangeGamma)
55 gammaRangeStart = Scalar(0);
56 gammaRangeEnd = Scalar(2 *
EIGEN_PI);
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))
101 VERIFY_IS_APPROX(eabis, eabis2);
103 Matrix3 mbis(AngleAxisType(eabis[0], I) * AngleAxisType(eabis[1], J) * AngleAxisType(eabis[2], K));
104 VERIFY_IS_APPROX(m, mbis);
107 if (!(positiveRangeAlpha || positiveRangeBeta || positiveRangeGamma))
111 if( (i!=k || ea[1]!=0) && (i==k || !internal::isApprox(
abs(ea[1]),Scalar(
EIGEN_PI/2),test_precision<Scalar>())) )
112 VERIFY((ea-eabis).norm() <= test_precision<Scalar>());
115 VERIFY(0 < eabis[0] || test_isMuchSmallerThan(eabis[0], Scalar(1)));
120 eabis = EulerAnglesType(q, positiveRangeAlpha, positiveRangeBeta, positiveRangeGamma).angles();
121 VERIFY_IS_APPROX(eabis, eabis2);
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);
186 ea[2] = ea[0] = internal::random<Scalar>(0,Scalar(
EIGEN_PI));
189 ea[0] = ea[1] = internal::random<Scalar>(0,Scalar(
EIGEN_PI));
195 ea.head(2).setZero();
204 for(
int i = 0; i < g_repeat; i++) {
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)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
void verify_euler(const Matrix< Scalar, 3, 1 > &ea)
TFSIMD_FORCE_INLINE Vector3 normalized() const
TFSIMD_FORCE_INLINE Vector3()
Represents a rotation in a 3 dimensional space as three Euler angles.
EIGEN_DEVICE_FUNC const Scalar & q
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)
Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.