10 #ifndef EIGEN_EULERSYSTEM_H 11 #define EIGEN_EULERSYSTEM_H 16 template <
typename _Scalar,
class _System>
22 template <
int Num,
bool IsPositive = (Num > 0)>
29 struct Abs<Num, false>
41 #define EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(COND)?1:-1] 119 template <
int _AlphaAxis,
int _BetaAxis,
int _GammaAxis>
127 static const int AlphaAxis = _AlphaAxis;
130 static const int BetaAxis = _BetaAxis;
133 static const int GammaAxis = _GammaAxis;
141 IsAlphaOpposite = (AlphaAxis < 0) ? 1 : 0,
142 IsBetaOpposite = (BetaAxis < 0) ? 1 : 0,
143 IsGammaOpposite = (GammaAxis < 0) ? 1 : 0,
145 IsOdd = ((AlphaAxisAbs)%3 == (BetaAxisAbs - 1)%3) ? 0 : 1,
146 IsEven = IsOdd ? 0 : 1,
148 IsTaitBryan = ((unsigned)AlphaAxisAbs != (
unsigned)GammaAxisAbs) ? 1 : 0
154 ALPHA_AXIS_IS_INVALID);
157 BETA_AXIS_IS_INVALID);
160 GAMMA_AXIS_IS_INVALID);
163 ALPHA_AXIS_CANT_BE_EQUAL_TO_BETA_AXIS);
166 BETA_AXIS_CANT_BE_EQUAL_TO_GAMMA_AXIS);
173 I = AlphaAxisAbs - 1,
174 J = (AlphaAxisAbs - 1 + 1 + IsOdd)%3,
175 K = (AlphaAxisAbs - 1 + 2 - IsOdd)%3
179 template <
typename Derived>
186 typedef typename Derived::Scalar Scalar;
189 res[0] =
atan2(mat(J,K), mat(K,K));
190 Scalar c2 = Vector2(mat(I,I), mat(I,J)).norm();
191 if((IsOdd && res[0]<Scalar(0)) || ((!IsOdd) && res[0]>Scalar(0))) {
192 if(res[0] > Scalar(0)) {
198 res[1] =
atan2(-mat(I,K), -c2);
201 res[1] =
atan2(-mat(I,K), c2);
202 Scalar s1 =
sin(res[0]);
203 Scalar c1 =
cos(res[0]);
204 res[2] =
atan2(s1*mat(K,I)-c1*mat(J,I), c1*mat(J,J) - s1 * mat(K,J));
207 template <
typename Derived>
214 typedef typename Derived::Scalar Scalar;
217 res[0] =
atan2(mat(J,I), mat(K,I));
218 if((IsOdd && res[0]<Scalar(0)) || ((!IsOdd) && res[0]>Scalar(0)))
220 if(res[0] > Scalar(0)) {
226 Scalar s2 = Vector2(mat(J,I), mat(K,I)).norm();
227 res[1] = -
atan2(s2, mat(I,I));
231 Scalar s2 = Vector2(mat(J,I), mat(K,I)).norm();
232 res[1] =
atan2(s2, mat(I,I));
245 Scalar s1 =
sin(res[0]);
246 Scalar c1 =
cos(res[0]);
247 res[2] =
atan2(c1*mat(J,K)-s1*mat(K,K), c1*mat(J,J) - s1 * mat(K,J));
250 template<
typename Scalar>
255 CalcEulerAngles(res, mat,
false,
false,
false);
259 bool PositiveRangeAlpha,
260 bool PositiveRangeBeta,
261 bool PositiveRangeGamma,
267 CalcEulerAngles(res, mat, PositiveRangeAlpha, PositiveRangeBeta, PositiveRangeGamma);
270 template<
typename Scalar>
274 bool PositiveRangeAlpha,
275 bool PositiveRangeBeta,
276 bool PositiveRangeGamma)
282 if (IsAlphaOpposite == IsOdd)
285 if (IsBetaOpposite == IsOdd)
288 if (IsGammaOpposite == IsOdd)
292 if (PositiveRangeAlpha && (res.
alpha() < 0))
295 if (PositiveRangeBeta && (res.
beta() < 0))
298 if (PositiveRangeGamma && (res.
gamma() < 0))
302 template <
typename _Scalar,
class _System>
306 #define EIGEN_EULER_SYSTEM_TYPEDEF(A, B, C) \ 308 typedef EulerSystem<EULER_##A, EULER_##B, EULER_##C> EulerSystem##A##B##C; 326 #endif // EIGEN_EULERSYSTEM_H
Represents a fixed Euler rotation system.
static void CalcEulerAngles(EulerAngles< Scalar, EulerSystem > &res, const typename EulerAngles< Scalar, EulerSystem >::Matrix3 &mat)
internal::traits< Derived >::Scalar Scalar
static void CalcEulerAngles(EulerAngles< Scalar, EulerSystem > &res, const typename EulerAngles< Scalar, EulerSystem >::Matrix3 &mat)
static void CalcEulerAngles_imp(Matrix< typename MatrixBase< Derived >::Scalar, 3, 1 > &res, const MatrixBase< Derived > &mat, internal::true_type)
EIGEN_DEVICE_FUNC const CosReturnType cos() const
#define EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT(COND, MSG)
Represents a rotation in a 3 dimensional space as three Euler angles.
const Vector3 & angles() const
#define EIGEN_EULER_SYSTEM_TYPEDEF(A, B, C)
static void CalcEulerAngles(EulerAngles< Scalar, EulerSystem > &res, const typename EulerAngles< Scalar, EulerSystem >::Matrix3 &mat, bool PositiveRangeAlpha, bool PositiveRangeBeta, bool PositiveRangeGamma)
static void CalcEulerAngles_imp(Matrix< typename MatrixBase< Derived >::Scalar, 3, 1 > &res, const MatrixBase< Derived > &mat, internal::false_type)
const AutoDiffScalar< Matrix< typename internal::traits< typename internal::remove_all< DerTypeA >::type >::Scalar, Dynamic, 1 > > atan2(const AutoDiffScalar< DerTypeA > &a, const AutoDiffScalar< DerTypeB > &b)
EIGEN_DEVICE_FUNC const SinReturnType sin() const
The matrix class, also used for vectors and row-vectors.
Base class for all dense matrices, vectors, and expressions.
EulerAxis
Representation of a fixed signed rotation axis for EulerSystem.