10 #ifndef EIGEN_EULERSYSTEM_H 11 #define EIGEN_EULERSYSTEM_H 14 #include "./InternalHeaderCheck.h" 18 template <
typename Scalar_,
class _System>
23 template <
int Num,
bool IsPositive = (Num > 0)>
29 struct Abs<Num, false> {
30 enum { value = -Num };
35 enum { value = Axis != 0 && Abs<Axis>::value <= 3 };
38 template <
typename System,
typename Other,
int OtherRows = Other::RowsAtCompileTime,
39 int OtherCols = Other::ColsAtCompileTime>
40 struct eulerangles_assign_impl;
43 #define EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT(COND, MSG) typedef char static_assertion_##MSG[(COND) ? 1 : -1] 120 template <
int _AlphaAxis,
int _BetaAxis,
int _GammaAxis>
154 EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT(internal::IsValidAxis<AlphaAxis>::value, ALPHA_AXIS_IS_INVALID);
156 EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT(internal::IsValidAxis<BetaAxis>::value, BETA_AXIS_IS_INVALID);
158 EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT(internal::IsValidAxis<GammaAxis>::value, GAMMA_AXIS_IS_INVALID);
161 ALPHA_AXIS_CANT_BE_EQUAL_TO_BETA_AXIS);
164 BETA_AXIS_CANT_BE_EQUAL_TO_GAMMA_AXIS);
174 template <
typename Derived>
180 typedef typename Derived::Scalar Scalar;
182 const Scalar plusMinus =
IsEven ? 1 : -1;
183 const Scalar minusPlus =
IsOdd ? 1 : -1;
185 const Scalar Rsum =
sqrt((mat(I_, I_) * mat(I_, I_) + mat(I_, J_) * mat(I_, J_) + mat(J_, K_) * mat(J_, K_) +
186 mat(K_, K_) * mat(K_, K_)) /
188 res[1] = atan2(plusMinus * mat(I_, K_), Rsum);
192 res[0] = atan2(minusPlus * mat(J_, K_), mat(K_, K_));
193 res[2] = atan2(minusPlus * mat(I_, J_), mat(I_, I_));
194 }
else if (plusMinus * mat(I_, K_) > 0) {
195 Scalar spos = mat(J_, I_) + plusMinus * mat(K_, J_);
196 Scalar cpos = mat(J_, J_) + minusPlus * mat(K_, I_);
197 Scalar alphaPlusMinusGamma = atan2(spos, cpos);
198 res[0] = alphaPlusMinusGamma;
201 Scalar sneg = plusMinus * (mat(K_, J_) + minusPlus * mat(J_, I_));
202 Scalar cneg = mat(J_, J_) + plusMinus * mat(K_, I_);
203 Scalar alphaMinusPlusBeta = atan2(sneg, cneg);
204 res[0] = alphaMinusPlusBeta;
209 template <
typename Derived>
211 const MatrixBase<Derived>& mat, internal::false_type ) {
215 typedef typename Derived::Scalar Scalar;
217 const Scalar plusMinus =
IsEven ? 1 : -1;
218 const Scalar minusPlus =
IsOdd ? 1 : -1;
220 const Scalar Rsum =
sqrt((mat(I_, J_) * mat(I_, J_) + mat(I_, K_) * mat(I_, K_) + mat(J_, I_) * mat(J_, I_) +
221 mat(K_, I_) * mat(K_, I_)) /
224 res[1] = atan2(Rsum, mat(I_, I_));
227 if (Rsum > 4 * NumTraits<Scalar>::epsilon()) {
228 res[0] = atan2(mat(J_, I_), minusPlus * mat(K_, I_));
229 res[2] = atan2(mat(I_, J_), plusMinus * mat(I_, K_));
230 }
else if (mat(I_, I_) > 0) {
231 Scalar spos = plusMinus * mat(K_, J_) + minusPlus * mat(J_, K_);
232 Scalar cpos = mat(J_, J_) + mat(K_, K_);
233 res[0] = atan2(spos, cpos);
236 Scalar sneg = plusMinus * mat(K_, J_) + plusMinus * mat(J_, K_);
237 Scalar cneg = mat(J_, J_) - mat(K_, K_);
238 res[0] = atan2(sneg, cneg);
243 template <
typename Scalar>
244 static void CalcEulerAngles(EulerAngles<Scalar, EulerSystem>& res,
246 CalcEulerAngles_imp(res.angles(), mat,
247 std::conditional_t<IsTaitBryan, internal::true_type, internal::false_type>());
256 template <
typename Scalar_,
class _System>
259 template <
typename System,
typename Other,
int OtherRows,
int OtherCols>
260 friend struct internal::eulerangles_assign_impl;
263 #define EIGEN_EULER_SYSTEM_TYPEDEF(A, B, C) typedef EulerSystem<EULER_##A, EULER_##B, EULER_##C> EulerSystem##A##B##C; 268 EIGEN_EULER_SYSTEM_TYPEDEF(X, Y, Z)
269 EIGEN_EULER_SYSTEM_TYPEDEF(X, Y, X)
270 EIGEN_EULER_SYSTEM_TYPEDEF(X, Z, Y)
271 EIGEN_EULER_SYSTEM_TYPEDEF(X, Z, X)
273 EIGEN_EULER_SYSTEM_TYPEDEF(Y, Z, X)
274 EIGEN_EULER_SYSTEM_TYPEDEF(Y, Z, Y)
275 EIGEN_EULER_SYSTEM_TYPEDEF(Y, X, Z)
276 EIGEN_EULER_SYSTEM_TYPEDEF(Y, X, Y)
278 EIGEN_EULER_SYSTEM_TYPEDEF(Z, X, Y)
279 EIGEN_EULER_SYSTEM_TYPEDEF(Z, X, Z)
280 EIGEN_EULER_SYSTEM_TYPEDEF(Z, Y, X)
281 EIGEN_EULER_SYSTEM_TYPEDEF(Z, Y, Z)
284 #endif // EIGEN_EULERSYSTEM_H Definition: EulerSystem.h:141
internal::traits< Derived >::Scalar Scalar
Represents a fixed Euler rotation system.
Definition: EulerSystem.h:121
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)
Definition: EulerSystem.h:147
Namespace containing all symbols from the Eigen library.
Definition: EulerSystem.h:58
EulerAxis
Representation of a fixed signed rotation axis for EulerSystem.
Definition: EulerSystem.h:57
Definition: EulerSystem.h:149
Matrix< Scalar, 3, 3 > Matrix3
Definition: EulerAngles.h:114
Definition: EulerSystem.h:142
Definition: EulerSystem.h:59
Represents a rotation in a 3 dimensional space as three Euler angles.
Definition: EulerAngles.h:103
Definition: EulerSystem.h:137
Definition: EulerSystem.h:60
static constexpr int GammaAxis
Definition: EulerSystem.h:133
Definition: EulerSystem.h:146
static constexpr int BetaAxis
Definition: EulerSystem.h:130
Definition: EulerSystem.h:140
Definition: EulerSystem.h:138
static constexpr int AlphaAxis
Definition: EulerSystem.h:127
Definition: EulerSystem.h:136