Represents a rotation in a 3 dimensional space as three Euler angles.
Euler rotation is a set of three rotation of three angles over three fixed axes, defined by the EulerSystem given as a template parameter.
It has been proved(see Wikipedia link below) that every rotation can be represented by Euler angles, but there is no single representation (e.g. unlike rotation matrices). Therefore, you can convert from Eigen rotation and to them (including rotation matrices, which is not called "rotations" by Eigen design).
However, Euler angles are slow comparing to quaternion or matrices, because their unnatural math definition, although it's simple for human. To overcome this, this class provide easy movement from the math friendly representation to the human friendly representation, and vise-versa.
All the user need to do is a safe simple C++ type conversion, and this class take care for the math. Additionally, some axes related computation is done in compile time.
Rotations representation as EulerAngles are not single (unlike matrices), and even have infinite EulerAngles representations.
For example, add or subtract 2*PI from either angle of EulerAngles and you'll get the same rotation. This is the general reason for infinite representation, but it's not the only general reason for not having a single representation.
When converting rotation to EulerAngles, this class convert it to specific ranges When converting some rotation to EulerAngles, the rules for ranges are as follow:
Convenient typedefs for EulerAngles exist for float and double scalar, in a form of EulerAngles{A}{B}{C}{scalar}, e.g. EulerAnglesXYZd, EulerAnglesZYZf.
Only for positive axes{+x,+y,+z} Euler systems are have convenient typedef. If you need negative axes{-x,-y,-z}, it is recommended to create you own typedef with a word that represent what you need.
#include <unsupported/Eigen/EulerAngles>
template <typename Scalar, class System>
}
#define VERIFY_APPROXED_RANGE(a, x, b) \
do { \
VERIFY_IS_APPROX_OR_LESS_THAN(a, x); \
VERIFY_IS_APPROX_OR_LESS_THAN(x, b); \
} while (0)
template <typename Scalar, class EulerSystem>
typedef Matrix<Scalar, 3, 3>
Matrix3;
typedef Matrix<Scalar, 3, 1>
Vector3;
Scalar precision = test_precision<Scalar>() / longitudeRadius;
Scalar betaRangeStart, betaRangeEnd;
betaRangeStart = -HALF_PI;
betaRangeEnd = HALF_PI;
} else {
betaRangeStart = 0;
betaRangeEnd = PI;
} else {
betaRangeStart = -PI;
betaRangeEnd = 0;
}
}
const Vector3 I_ = EulerAnglesType::AlphaAxisVector();
const Vector3 J_ = EulerAnglesType::BetaAxisVector();
const Vector3 K_ = EulerAnglesType::GammaAxisVector();
if (ebis.beta() == 0) precision = test_precision<Scalar>();
VERIFY(
m.isApprox(mbis, precision));
}
template <signed char A, signed char B, signed char C, typename Scalar>
}
template <signed char A, signed char B, signed char C, typename Scalar>
verify_euler_vec<+A, +B, +C>(ea);
}
template <typename Scalar>
verify_euler_all_neg<X, Y, Z>(ea);
verify_euler_all_neg<X, Y, X>(ea);
verify_euler_all_neg<X, Z, Y>(ea);
verify_euler_all_neg<X, Z, X>(ea);
verify_euler_all_neg<Y, Z, X>(ea);
verify_euler_all_neg<Y, Z, Y>(ea);
verify_euler_all_neg<Y, X, Z>(ea);
verify_euler_all_neg<Y, X, Y>(ea);
verify_euler_all_neg<Z, X, Y>(ea);
verify_euler_all_neg<Z, X, Z>(ea);
verify_euler_all_neg<Z, Y, X>(ea);
verify_euler_all_neg<Z, Y, Z>(ea);
}
template <typename Scalar>
typedef Matrix<Scalar, 3, 1>
Vector3;
}
}
template <typename Scalar>
typedef Matrix<Scalar, 3, 1>
Vector3;
typedef Matrix<Scalar, Dynamic, 1>
VectorX;
for (
int i = 0;
i <
alpha.size(); ++
i) {
for (
int j = 0;
j <
beta.size(); ++
j) {
for (
int k = 0;
k <
gamma.size(); ++
k) {
}
}
}
}
template <typename Scalar>
typedef Matrix<Scalar, 3, 3>
Matrix3;
typedef Matrix<Scalar, 3, 1>
Vector3;
typedef Array<Scalar, 3, 1> Array3;
Quaternionx q1;
ea =
m.eulerAngles(0, 1, 0);
q1.coeffs() = Quaternionx::Coefficients::Random().normalized();
ea =
m.eulerAngles(0, 1, 2);
ea =
m.eulerAngles(0, 1, 0);
ea = (Array3::Random() + Array3(1, 0, 0)) *
Scalar(
EIGEN_PI) * Array3(0.5, 1, 1);
ea[1] = 0;
ea.head(2).setZero();
ea.setZero();
}
EulerAnglesXYZd onesEd(1, 1, 1);
EulerAnglesXYZf onesEf = onesEd.cast<float>();
}
}
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define EIGEN_DISABLE_DEPRECATED_WARNING
Definition: Macros.h:957
#define EIGEN_PI
Definition: MathFunctions.h:16
Scalar * b
Definition: benchVecAdd.cpp:17
SCALAR Scalar
Definition: bench_gemm.cpp:45
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:47
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Definition: bench_gemm.cpp:48
Represents a rotation in a 3 dimensional space as three Euler angles.
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:103
Scalar alpha() const
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:203
Quaternion< Scalar > QuaternionType
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:116
AngleAxis< Scalar > AngleAxisType
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:117
Scalar gamma() const
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:213
Scalar_ Scalar
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:108
Scalar beta() const
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:208
Matrix< Scalar, 3, 3 > Matrix3
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:114
Matrix< Scalar, 3, 1 > Vector3
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:115
@ IsTaitBryan
Definition: EulerSystem.h:149
@ IsBetaOpposite
Definition: EulerSystem.h:141
Definition: quaternion_demo.cpp:124
This class contains the 4 components of a quaternion and the standard operators and functions needed ...
Definition: Kernel/Math/Quaternion.h:42
Definition: matrices.h:74
void verify_euler(const Matrix< Scalar, 3, 1 > &ea, int i, int j, int k)
Definition: geo_eulerangles.cpp:20
void check_all_var(const Matrix< Scalar, 3, 1 > &ea)
Definition: geo_eulerangles.cpp:69
#define X
Definition: icosphere.cpp:20
#define Z
Definition: icosphere.cpp:21
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
#define VERIFY_IS_NOT_APPROX(a, b)
Definition: integer_types.cpp:15
const Scalar * a
Definition: level2_cplx_impl.h:32
int * m
Definition: level2_cplx_impl.h:294
char char char int int * k
Definition: level2_impl.h:374
#define VERIFY(a)
Definition: main.h:362
#define EIGEN_DECLARE_TEST(X)
Definition: main.h:220
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:2019
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
static int g_repeat
Definition: main.h:191
bool verifyIsApprox(const Type1 &a, const Type2 &b)
Definition: main.h:609
@ EULER_X
Definition: EulerSystem.h:58
@ EULER_Z
Definition: EulerSystem.h:60
@ EULER_Y
Definition: EulerSystem.h:59
double E
Elastic modulus.
Definition: TwenteMeshGluing.cpp:68
double Zero
Definition: pseudosolid_node_update_elements.cc:35
double epsilon
Definition: osc_ring_sarah_asymptotics.h:43
Matrix< Scalar, Dynamic, 1 > VectorX
Definition: sparse_lu.cpp:43
#define CALL_SUBTEST_3(FUNC)
Definition: split_test_helper.h:16
#define CALL_SUBTEST_1(FUNC)
Definition: split_test_helper.h:4
#define CALL_SUBTEST_2(FUNC)
Definition: split_test_helper.h:10
#define CALL_SUBTEST_4(FUNC)
Definition: split_test_helper.h:22
void eulerangles_manual()
Definition: test/EulerAngles.cpp:185
void eulerangles_rand()
Definition: test/EulerAngles.cpp:217
void verify_euler_vec(const Matrix< Scalar, 3, 1 > &ea)
Definition: test/EulerAngles.cpp:128
#define VERIFY_APPROXED_RANGE(a, x, b)
Definition: test/EulerAngles.cpp:25
void check_singular_cases(const Scalar &singularBeta)
Definition: test/EulerAngles.cpp:164
void verify_euler_all_neg(const Matrix< Scalar, 3, 1 > &ea)
Definition: test/EulerAngles.cpp:133
const char Y
Definition: test/EulerAngles.cpp:32
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
If you're want to get more idea about how Euler system work in Eigen see EulerSystem.