aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/src/EulerAngles
diff options
context:
space:
mode:
authorGravatar Tal Hadad <tal_hd@hotmail.com>2016-06-13 21:55:17 +0300
committerGravatar Tal Hadad <tal_hd@hotmail.com>2016-06-13 21:55:17 +0300
commit6e1c086593075e8f16e914a1c7200bceea9aea7b (patch)
tree5c8d7893308958b2f22045da6c6d07f117c1f189 /unsupported/Eigen/src/EulerAngles
parent06206482d9964835b201c682884360dd0d1e73a5 (diff)
Add static assertion
Diffstat (limited to 'unsupported/Eigen/src/EulerAngles')
-rw-r--r--unsupported/Eigen/src/EulerAngles/EulerAngles.h4
-rw-r--r--unsupported/Eigen/src/EulerAngles/EulerSystem.h29
2 files changed, 24 insertions, 9 deletions
diff --git a/unsupported/Eigen/src/EulerAngles/EulerAngles.h b/unsupported/Eigen/src/EulerAngles/EulerAngles.h
index 9d1762ace..911ba4d09 100644
--- a/unsupported/Eigen/src/EulerAngles/EulerAngles.h
+++ b/unsupported/Eigen/src/EulerAngles/EulerAngles.h
@@ -229,6 +229,8 @@ namespace Eigen
typename Derived>
static EulerAngles FromRotation(const MatrixBase<Derived>& m)
{
+ EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
+
EulerAngles e;
System::CalcEulerAngles<PositiveRangeAlpha, PositiveRangeBeta, PositiveRangeGamma>(e, m);
return e;
@@ -272,6 +274,8 @@ namespace Eigen
/** Set \c *this from a rotation matrix(i.e. pure orthogonal matrix with determinant of +1). */
template<typename Derived>
EulerAngles& operator=(const MatrixBase<Derived>& m) {
+ EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
+
System::CalcEulerAngles(*this, m);
return *this;
}
diff --git a/unsupported/Eigen/src/EulerAngles/EulerSystem.h b/unsupported/Eigen/src/EulerAngles/EulerSystem.h
index ac73b48a0..c368a8bfa 100644
--- a/unsupported/Eigen/src/EulerAngles/EulerSystem.h
+++ b/unsupported/Eigen/src/EulerAngles/EulerSystem.h
@@ -38,6 +38,8 @@ namespace Eigen
};
}
+ #define EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT(COND,MSG) typedef char static_assertion_##MSG[(COND)?1:-1]
+
/** \brief Representation of a fixed signed rotation axis for EulerAngles.
*
* Values here represent:
@@ -83,7 +85,7 @@ namespace Eigen
* - right handed or left handed
* - counterclockwise or clockwise
*
- * Notice all axed combination are valid, and would trigger an assertion !TODO!.
+ * Notice all axed combination are valid, and would trigger a static assertion.
* Same unsigned axes can't be neighbors, e.g. {X,X,Y} is invalid.
* This yield two and only two classes:
* - tait bryan - all unsigned axes are distinct, e.g. {X,Y,Z}
@@ -147,17 +149,26 @@ namespace Eigen
IsOdd = ((AlphaAxisAbs)%3 == (BetaAxisAbs - 1)%3) ? 0 : 1,
IsEven = IsOdd ? 0 : 1,
-
- // TODO: Assert this, and sort it in a better way
- IsValid = ((unsigned)AlphaAxisAbs != (unsigned)BetaAxisAbs &&
- (unsigned)BetaAxisAbs != (unsigned)GammaAxisAbs &&
- internal::IsValidAxis<AlphaAxis>::value && internal::IsValidAxis<BetaAxis>::value && internal::IsValidAxis<GammaAxis>::value) ? 1 : 0,
- // TODO: After a proper assertation, remove the "IsValid" from this expression
- IsTaitBryan = (IsValid && (unsigned)AlphaAxisAbs != (unsigned)GammaAxisAbs) ? 1 : 0
+ IsTaitBryan = ((unsigned)AlphaAxisAbs != (unsigned)GammaAxisAbs) ? 1 : 0
};
-
+
private:
+
+ EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT(internal::IsValidAxis<AlphaAxis>::value,
+ ALPHA_AXIS_IS_INVALID);
+
+ EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT(internal::IsValidAxis<BetaAxis>::value,
+ BETA_AXIS_IS_INVALID);
+
+ EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT(internal::IsValidAxis<GammaAxis>::value,
+ GAMMA_AXIS_IS_INVALID);
+
+ EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT((unsigned)AlphaAxisAbs != (unsigned)BetaAxisAbs,
+ ALPHA_AXIS_CANT_BE_EQUAL_TO_BETA_AXIS);
+
+ EIGEN_EULER_ANGLES_CLASS_STATIC_ASSERT((unsigned)BetaAxisAbs != (unsigned)GammaAxisAbs,
+ BETA_AXIS_CANT_BE_EQUAL_TO_GAMMA_AXIS);
enum
{