mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-05-03 01:04:23 +08:00
Add static assertion
This commit is contained in:
parent
06206482d9
commit
6e1c086593
@ -229,6 +229,8 @@ namespace Eigen
|
|||||||
typename Derived>
|
typename Derived>
|
||||||
static EulerAngles FromRotation(const MatrixBase<Derived>& m)
|
static EulerAngles FromRotation(const MatrixBase<Derived>& m)
|
||||||
{
|
{
|
||||||
|
EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
|
||||||
|
|
||||||
EulerAngles e;
|
EulerAngles e;
|
||||||
System::CalcEulerAngles<PositiveRangeAlpha, PositiveRangeBeta, PositiveRangeGamma>(e, m);
|
System::CalcEulerAngles<PositiveRangeAlpha, PositiveRangeBeta, PositiveRangeGamma>(e, m);
|
||||||
return e;
|
return e;
|
||||||
@ -272,6 +274,8 @@ namespace Eigen
|
|||||||
/** Set \c *this from a rotation matrix(i.e. pure orthogonal matrix with determinant of +1). */
|
/** Set \c *this from a rotation matrix(i.e. pure orthogonal matrix with determinant of +1). */
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
EulerAngles& operator=(const MatrixBase<Derived>& m) {
|
EulerAngles& operator=(const MatrixBase<Derived>& m) {
|
||||||
|
EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
|
||||||
|
|
||||||
System::CalcEulerAngles(*this, m);
|
System::CalcEulerAngles(*this, m);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -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.
|
/** \brief Representation of a fixed signed rotation axis for EulerAngles.
|
||||||
*
|
*
|
||||||
* Values here represent:
|
* Values here represent:
|
||||||
@ -83,7 +85,7 @@ namespace Eigen
|
|||||||
* - right handed or left handed
|
* - right handed or left handed
|
||||||
* - counterclockwise or clockwise
|
* - 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.
|
* Same unsigned axes can't be neighbors, e.g. {X,X,Y} is invalid.
|
||||||
* This yield two and only two classes:
|
* This yield two and only two classes:
|
||||||
* - tait bryan - all unsigned axes are distinct, e.g. {X,Y,Z}
|
* - 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,
|
IsOdd = ((AlphaAxisAbs)%3 == (BetaAxisAbs - 1)%3) ? 0 : 1,
|
||||||
IsEven = IsOdd ? 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 = ((unsigned)AlphaAxisAbs != (unsigned)GammaAxisAbs) ? 1 : 0
|
||||||
IsTaitBryan = (IsValid && (unsigned)AlphaAxisAbs != (unsigned)GammaAxisAbs) ? 1 : 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
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
|
enum
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user