Eigen::EulerAngles< Scalar_, _System > Class Template Reference

Represents a rotation in a 3 dimensional space as three Euler angles. More...

#include <EulerAngles.h>

+ Inheritance diagram for Eigen::EulerAngles< Scalar_, _System >:

Public Types

typedef RotationBase< EulerAngles< Scalar_, _System >, 3 > Base
 
typedef Scalar_ Scalar
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef _System System
 
typedef Matrix< Scalar, 3, 3 > Matrix3
 
typedef Matrix< Scalar, 3, 1 > Vector3
 
typedef Quaternion< ScalarQuaternionType
 
typedef AngleAxis< ScalarAngleAxisType
 
- Public Types inherited from Eigen::RotationBase< EulerAngles< Scalar_, _System >, 3 >
enum  
 
typedef internal::traits< EulerAngles< Scalar_, _System > >::Scalar Scalar
 
typedef Matrix< Scalar, Dim, DimRotationMatrixType
 
typedef Matrix< Scalar, Dim, 1 > VectorType
 

Public Member Functions

 EulerAngles ()
 
 EulerAngles (const Scalar &alpha, const Scalar &beta, const Scalar &gamma)
 
 EulerAngles (const Scalar *data)
 
template<typename Derived >
 EulerAngles (const MatrixBase< Derived > &other)
 
template<typename Derived >
 EulerAngles (const RotationBase< Derived, 3 > &rot)
 
const Vector3angles () const
 
Vector3angles ()
 
Scalar alpha () const
 
Scalaralpha ()
 
Scalar beta () const
 
Scalarbeta ()
 
Scalar gamma () const
 
Scalargamma ()
 
EulerAngles inverse () const
 
EulerAngles operator- () const
 
template<class Derived >
EulerAnglesoperator= (const MatrixBase< Derived > &other)
 
template<typename Derived >
EulerAnglesoperator= (const RotationBase< Derived, 3 > &rot)
 
bool isApprox (const EulerAngles &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
Matrix3 toRotationMatrix () const
 
 operator QuaternionType () const
 
template<typename NewScalarType >
EulerAngles< NewScalarType, Systemcast () const
 
- Public Member Functions inherited from Eigen::RotationBase< EulerAngles< Scalar_, _System >, 3 >
EIGEN_DEVICE_FUNC const EulerAngles< Scalar_, _System > & derived () const
 
EIGEN_DEVICE_FUNC EulerAngles< Scalar_, _System > & derived ()
 
EIGEN_DEVICE_FUNC RotationMatrixType toRotationMatrix () const
 
EIGEN_DEVICE_FUNC RotationMatrixType matrix () const
 
EIGEN_DEVICE_FUNC EulerAngles< Scalar_, _System > inverse () const
 
EIGEN_DEVICE_FUNC Transform< Scalar, Dim, Isometry > operator* (const Translation< Scalar, Dim > &t) const
 
EIGEN_DEVICE_FUNC RotationMatrixType operator* (const UniformScaling< Scalar > &s) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::rotation_base_generic_product_selector< EulerAngles< Scalar_, _System >, OtherDerived, OtherDerived::IsVectorAtCompileTime >::ReturnType operator* (const EigenBase< OtherDerived > &e) const
 
EIGEN_DEVICE_FUNC Transform< Scalar, Dim, Mode > operator* (const Transform< Scalar, Dim, Mode, Options > &t) const
 
EIGEN_DEVICE_FUNC VectorType _transformVector (const OtherVectorType &v) const
 

Static Public Member Functions

static Vector3 AlphaAxisVector ()
 
static Vector3 BetaAxisVector ()
 
static Vector3 GammaAxisVector ()
 

Private Attributes

Vector3 m_angles
 

Friends

std::ostream & operator<< (std::ostream &s, const EulerAngles< Scalar, System > &eulerAngles)
 

Detailed Description

template<typename Scalar_, class _System>
class Eigen::EulerAngles< Scalar_, _System >

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.

Here is how intrinsic Euler angles works:

  • first, rotate the axes system over the alpha axis in angle alpha
  • then, rotate the axes system over the beta axis(which was rotated in the first stage) in angle beta
  • then, rotate the axes system over the gamma axis(which was rotated in the two stages above) in angle gamma
Note
This class support only intrinsic Euler angles for simplicity, see EulerSystem how to easily overcome this for extrinsic systems.

Rotation representation and conversions

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).

Euler angles usually used for:

  • convenient human representation of rotation, especially in interactive GUI.
  • gimbal systems and robotics
  • efficient encoding(i.e. 3 floats only) of rotation for network protocols.

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.

Euler angles ranges in conversions

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:

  • If the rotation we converting from is an EulerAngles (even when it represented as RotationBase explicitly), angles ranges are undefined.
  • otherwise, alpha and gamma angles will be in the range [-PI, PI].
    As for Beta angle:
    • If the system is Tait-Bryan, the beta angle will be in the range [-PI/2, PI/2].
    • otherwise:
      • If the beta axis is positive, the beta angle will be in the range [0, PI]
      • If the beta axis is negative, the beta angle will be in the range [-PI, 0]
See also
EulerAngles(const MatrixBase<Derived>&)
EulerAngles(const RotationBase<Derived, 3>&)

Convenient user typedefs

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.

Example

// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2015 Tal Hadad <tal_hd@hotmail.com>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "main.h"
#include <unsupported/Eigen/EulerAngles>
using namespace Eigen;
// Unfortunately, we need to specialize it in order to work. (We could add it in main.h test framework)
template <typename Scalar, class System>
return verifyIsApprox(a.angles(), b.angles());
}
// Verify that x is in the approxed range [a, b]
#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)
const char X = EULER_X;
const char Y = EULER_Y;
const char Z = EULER_Z;
template <typename Scalar, class EulerSystem>
typedef EulerAngles<Scalar, EulerSystem> EulerAnglesType;
typedef Matrix<Scalar, 3, 3> Matrix3;
typedef Matrix<Scalar, 3, 1> Vector3;
typedef AngleAxis<Scalar> AngleAxisType;
const Scalar ONE = Scalar(1);
const Scalar HALF_PI = Scalar(EIGEN_PI / 2);
const Scalar PI = Scalar(EIGEN_PI);
// It's very important calc the acceptable precision depending on the distance from the pole.
const Scalar longitudeRadius = std::abs(EulerSystem::IsTaitBryan ? std::cos(e.beta()) : std::sin(e.beta()));
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();
// Is approx checks
VERIFY(e.isApprox(e));
VERIFY_IS_NOT_APPROX(e, EulerAnglesType(e.alpha() + ONE, e.beta() + ONE, e.gamma() + ONE));
const Matrix3 m(e);
VERIFY_IS_APPROX(Scalar(m.determinant()), ONE);
EulerAnglesType ebis(m);
// When no roll(acting like polar representation), we have the best precision.
// One of those cases is when the Euler angles are on the pole, and because it's singular case,
// the computation returns no roll.
if (ebis.beta() == 0) precision = test_precision<Scalar>();
// Check that eabis in range
VERIFY_APPROXED_RANGE(-PI, ebis.alpha(), PI);
VERIFY_APPROXED_RANGE(betaRangeStart, ebis.beta(), betaRangeEnd);
VERIFY_APPROXED_RANGE(-PI, ebis.gamma(), PI);
const Matrix3 mbis(AngleAxisType(ebis.alpha(), I_) * AngleAxisType(ebis.beta(), J_) *
AngleAxisType(ebis.gamma(), K_));
VERIFY_IS_APPROX(Scalar(mbis.determinant()), ONE);
VERIFY_IS_APPROX(mbis, ebis.toRotationMatrix());
/*std::cout << "===================\n" <<
"e: " << e << std::endl <<
"eabis: " << eabis.transpose() << std::endl <<
"m: " << m << std::endl <<
"mbis: " << mbis << std::endl <<
"X: " << (m * Vector3::UnitX()).transpose() << std::endl <<
"X: " << (mbis * Vector3::UnitX()).transpose() << std::endl;*/
VERIFY(m.isApprox(mbis, precision));
// Test if ea and eabis are the same
// Need to check both singular and non-singular cases
// There are two singular cases.
// 1. When I==K and sin(ea(1)) == 0
// 2. When I!=K and cos(ea(1)) == 0
// TODO: Make this test work well, and use range saturation function.
/*// If I==K, and ea[1]==0, then there no unique solution.
// The remark apply in the case where I!=K, and |ea[1]| is close to +-pi/2.
if( (i!=k || ea[1]!=0) && (i==k || !internal::isApprox(abs(ea[1]),Scalar(EIGEN_PI/2),test_precision<Scalar>())) )
VERIFY_IS_APPROX(ea, eabis);*/
// Quaternions
const QuaternionType q(e);
ebis = q;
const QuaternionType qbis(ebis);
VERIFY(internal::isApprox<Scalar>(std::abs(q.dot(qbis)), ONE, precision));
// VERIFY_IS_APPROX(eabis, eabis2);// Verify that the euler angles are still the same
// A suggestion for simple product test when will be supported.
/*EulerAnglesType e2(PI/2, PI/2, PI/2);
Matrix3 m2(e2);
VERIFY_IS_APPROX(e*e2, m*m2);*/
}
template <signed char A, signed char B, signed char C, typename Scalar>
void verify_euler_vec(const Matrix<Scalar, 3, 1>& ea) {
verify_euler(EulerAngles<Scalar, EulerSystem<A, B, C> >(ea[0], ea[1], ea[2]));
}
template <signed char A, signed char B, signed char C, typename Scalar>
void verify_euler_all_neg(const Matrix<Scalar, 3, 1>& ea) {
verify_euler_vec<+A, +B, +C>(ea);
verify_euler_vec<+A, +B, -C>(ea);
verify_euler_vec<+A, -B, +C>(ea);
verify_euler_vec<+A, -B, -C>(ea);
verify_euler_vec<-A, +B, +C>(ea);
verify_euler_vec<-A, +B, -C>(ea);
verify_euler_vec<-A, -B, +C>(ea);
verify_euler_vec<-A, -B, -C>(ea);
}
template <typename Scalar>
void check_all_var(const Matrix<Scalar, 3, 1>& ea) {
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>
void check_singular_cases(const Scalar& singularBeta) {
typedef Matrix<Scalar, 3, 1> Vector3;
const Scalar PI = Scalar(EIGEN_PI);
check_all_var(Vector3(PI / 4, singularBeta, PI / 3));
check_all_var(Vector3(PI / 4, singularBeta - epsilon, PI / 3));
check_all_var(Vector3(PI / 4, singularBeta - Scalar(1.5) * epsilon, PI / 3));
check_all_var(Vector3(PI / 4, singularBeta - 2 * epsilon, PI / 3));
check_all_var(Vector3(PI * Scalar(0.8), singularBeta - epsilon, Scalar(0.9) * PI));
check_all_var(Vector3(PI * Scalar(-0.9), singularBeta + epsilon, PI * Scalar(0.3)));
check_all_var(Vector3(PI * Scalar(-0.6), singularBeta + Scalar(1.5) * epsilon, PI * Scalar(0.3)));
check_all_var(Vector3(PI * Scalar(-0.5), singularBeta + 2 * epsilon, PI * Scalar(0.4)));
check_all_var(Vector3(PI * Scalar(0.9), singularBeta + epsilon, Scalar(0.8) * PI));
}
// This one for sanity, it had a problem with near pole cases in float scalar.
check_all_var(Vector3(PI * Scalar(0.8), singularBeta - Scalar(1E-6), Scalar(0.9) * PI));
}
template <typename Scalar>
typedef Matrix<Scalar, 3, 1> Vector3;
typedef Matrix<Scalar, Dynamic, 1> VectorX;
const Scalar PI = Scalar(EIGEN_PI);
// singular cases
// non-singular cases
VectorX alpha = VectorX::LinSpaced(20, Scalar(-0.99) * PI, PI);
VectorX beta = VectorX::LinSpaced(20, Scalar(-0.49) * PI, Scalar(0.49) * PI);
VectorX gamma = VectorX::LinSpaced(20, Scalar(-0.99) * PI, PI);
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;
typedef Quaternion<Scalar> Quaternionx;
typedef AngleAxis<Scalar> AngleAxisType;
Scalar a = internal::random<Scalar>(-Scalar(EIGEN_PI), Scalar(EIGEN_PI));
Quaternionx q1;
q1 = AngleAxisType(a, Vector3::Random().normalized());
m = q1;
Vector3 ea = m.eulerAngles(0, 1, 2);
ea = m.eulerAngles(0, 1, 0);
// Check with purely random Quaternion:
q1.coeffs() = Quaternionx::Coefficients::Random().normalized();
m = q1;
ea = m.eulerAngles(0, 1, 2);
ea = m.eulerAngles(0, 1, 0);
// Check with random angles in range [0:pi]x[-pi:pi]x[-pi:pi].
ea = (Array3::Random() + Array3(1, 0, 0)) * Scalar(EIGEN_PI) * Array3(0.5, 1, 1);
ea[2] = ea[0] = internal::random<Scalar>(0, Scalar(EIGEN_PI));
ea[0] = ea[1] = internal::random<Scalar>(0, Scalar(EIGEN_PI));
ea[1] = 0;
ea.head(2).setZero();
ea.setZero();
}
// Simple cast test
EulerAnglesXYZd onesEd(1, 1, 1);
EulerAnglesXYZf onesEf = onesEd.cast<float>();
VERIFY_IS_APPROX(onesEd, onesEf.cast<double>());
// Simple Construction from Vector3 test
VERIFY_IS_APPROX(onesEd, EulerAnglesXYZd(Vector3d::Ones()));
CALL_SUBTEST_1(eulerangles_manual<float>());
CALL_SUBTEST_2(eulerangles_manual<double>());
for (int i = 0; i < g_repeat; i++) {
CALL_SUBTEST_3(eulerangles_rand<float>());
CALL_SUBTEST_4(eulerangles_rand<double>());
}
// TODO: Add tests for auto diff
// TODO: Add tests for complex numbers
}
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

Output:

Additional reading

If you're want to get more idea about how Euler system work in Eigen see EulerSystem.

More information about Euler angles: https://en.wikipedia.org/wiki/Euler_angles

Template Parameters
Scalar_the scalar type, i.e. the type of the angles.
_Systemthe EulerSystem to use, which represents the axes of rotation.

Member Typedef Documentation

◆ AngleAxisType

template<typename Scalar_ , class _System >
typedef AngleAxis<Scalar> Eigen::EulerAngles< Scalar_, _System >::AngleAxisType

the equivalent angle-axis type

◆ Base

template<typename Scalar_ , class _System >
typedef RotationBase<EulerAngles<Scalar_, _System>, 3> Eigen::EulerAngles< Scalar_, _System >::Base

◆ Matrix3

template<typename Scalar_ , class _System >
typedef Matrix<Scalar, 3, 3> Eigen::EulerAngles< Scalar_, _System >::Matrix3

the equivalent rotation matrix type

◆ QuaternionType

template<typename Scalar_ , class _System >
typedef Quaternion<Scalar> Eigen::EulerAngles< Scalar_, _System >::QuaternionType

the equivalent quaternion type

◆ RealScalar

template<typename Scalar_ , class _System >
typedef NumTraits<Scalar>::Real Eigen::EulerAngles< Scalar_, _System >::RealScalar

◆ Scalar

template<typename Scalar_ , class _System >
typedef Scalar_ Eigen::EulerAngles< Scalar_, _System >::Scalar

the scalar type of the angles

◆ System

template<typename Scalar_ , class _System >
typedef _System Eigen::EulerAngles< Scalar_, _System >::System

the EulerSystem to use, which represents the axes of rotation.

◆ Vector3

template<typename Scalar_ , class _System >
typedef Matrix<Scalar, 3, 1> Eigen::EulerAngles< Scalar_, _System >::Vector3

the equivalent 3 dimension vector type

Constructor & Destructor Documentation

◆ EulerAngles() [1/5]

template<typename Scalar_ , class _System >
Eigen::EulerAngles< Scalar_, _System >::EulerAngles ( )
inline

Default constructor without initialization.

142 {}

◆ EulerAngles() [2/5]

template<typename Scalar_ , class _System >
Eigen::EulerAngles< Scalar_, _System >::EulerAngles ( const Scalar alpha,
const Scalar beta,
const Scalar gamma 
)
inline

Constructs and initialize an EulerAngles (alpha, beta, gamma).

144 : m_angles(alpha, beta, gamma) {}
Vector3 m_angles
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:138

◆ EulerAngles() [3/5]

template<typename Scalar_ , class _System >
Eigen::EulerAngles< Scalar_, _System >::EulerAngles ( const Scalar data)
inlineexplicit

Constructs and initialize an EulerAngles from the array data {alpha, beta, gamma}

148 : m_angles(data) {}
int data[]
Definition: Map_placement_new.cpp:1

◆ EulerAngles() [4/5]

template<typename Scalar_ , class _System >
template<typename Derived >
Eigen::EulerAngles< Scalar_, _System >::EulerAngles ( const MatrixBase< Derived > &  other)
inlineexplicit

Constructs and initializes an EulerAngles from either:

  • a 3x3 rotation matrix expression(i.e. pure orthogonal matrix with determinant of +1),
  • a 3D vector expression representing Euler angles.
Note
If other is a 3x3 rotation matrix, the angles range rules will be as follow:
Alpha and gamma angles will be in the range [-PI, PI].
As for Beta angle:
  • If the system is Tait-Bryan, the beta angle will be in the range [-PI/2, PI/2].
  • otherwise:
    • If the beta axis is positive, the beta angle will be in the range [0, PI]
    • If the beta axis is negative, the beta angle will be in the range [-PI, 0]
163  {
164  *this = other;
165  }

◆ EulerAngles() [5/5]

template<typename Scalar_ , class _System >
template<typename Derived >
Eigen::EulerAngles< Scalar_, _System >::EulerAngles ( const RotationBase< Derived, 3 > &  rot)
inline

Constructs and initialize Euler angles from a rotation rot.

Note
If rot is an EulerAngles (even when it represented as RotationBase explicitly), angles ranges are undefined. Otherwise, alpha and gamma angles will be in the range [-PI, PI].
As for Beta angle:
  • If the system is Tait-Bryan, the beta angle will be in the range [-PI/2, PI/2].
  • otherwise:
    • If the beta axis is positive, the beta angle will be in the range [0, PI]
    • If the beta axis is negative, the beta angle will be in the range [-PI, 0]
179  {
180  System::CalcEulerAngles(*this, rot.toRotationMatrix());
181  }
EIGEN_BLAS_FUNC() rot(int *n, Scalar *px, int *incx, Scalar *py, int *incy, Scalar *pc, Scalar *ps)
Definition: level1_real_impl.h:88

References rot().

Member Function Documentation

◆ alpha() [1/2]

template<typename Scalar_ , class _System >
Scalar& Eigen::EulerAngles< Scalar_, _System >::alpha ( )
inline
Returns
A read-write reference to the angle of the first angle.
205 { return m_angles[0]; }

References Eigen::EulerAngles< Scalar_, _System >::m_angles.

◆ alpha() [2/2]

template<typename Scalar_ , class _System >
Scalar Eigen::EulerAngles< Scalar_, _System >::alpha ( ) const
inline
Returns
The value of the first angle.
203 { return m_angles[0]; }

References Eigen::EulerAngles< Scalar_, _System >::m_angles.

Referenced by Eigen::EulerAngles< Scalar_, _System >::operator QuaternionType().

◆ AlphaAxisVector()

template<typename Scalar_ , class _System >
static Vector3 Eigen::EulerAngles< Scalar_, _System >::AlphaAxisVector ( )
inlinestatic
Returns
the axis vector of the first (alpha) rotation
120  {
121  const Vector3& u = Vector3::Unit(System::AlphaAxisAbs - 1);
122  return System::IsAlphaOpposite ? -u : u;
123  }

Referenced by Eigen::EulerAngles< Scalar_, _System >::operator QuaternionType().

◆ angles() [1/2]

template<typename Scalar_ , class _System >
Vector3& Eigen::EulerAngles< Scalar_, _System >::angles ( )
inline
Returns
A read-write reference to the angle values stored in a vector (alpha, beta, gamma).
200 { return m_angles; }

References Eigen::EulerAngles< Scalar_, _System >::m_angles.

◆ angles() [2/2]

template<typename Scalar_ , class _System >
const Vector3& Eigen::EulerAngles< Scalar_, _System >::angles ( ) const
inline
Returns
The angle values stored in a vector (alpha, beta, gamma).
198 { return m_angles; }

References Eigen::EulerAngles< Scalar_, _System >::m_angles.

Referenced by Eigen::EulerAngles< Scalar_, _System >::cast(), and Eigen::EulerAngles< Scalar_, _System >::isApprox().

◆ beta() [1/2]

template<typename Scalar_ , class _System >
Scalar& Eigen::EulerAngles< Scalar_, _System >::beta ( )
inline
Returns
A read-write reference to the angle of the second angle.
210 { return m_angles[1]; }

References Eigen::EulerAngles< Scalar_, _System >::m_angles.

◆ beta() [2/2]

template<typename Scalar_ , class _System >
Scalar Eigen::EulerAngles< Scalar_, _System >::beta ( ) const
inline
Returns
The value of the second angle.
208 { return m_angles[1]; }

References Eigen::EulerAngles< Scalar_, _System >::m_angles.

Referenced by Eigen::EulerAngles< Scalar_, _System >::operator QuaternionType().

◆ BetaAxisVector()

template<typename Scalar_ , class _System >
static Vector3 Eigen::EulerAngles< Scalar_, _System >::BetaAxisVector ( )
inlinestatic
Returns
the axis vector of the second (beta) rotation
126  {
127  const Vector3& u = Vector3::Unit(System::BetaAxisAbs - 1);
128  return System::IsBetaOpposite ? -u : u;
129  }

Referenced by Eigen::EulerAngles< Scalar_, _System >::operator QuaternionType().

◆ cast()

template<typename Scalar_ , class _System >
template<typename NewScalarType >
EulerAngles<NewScalarType, System> Eigen::EulerAngles< Scalar_, _System >::cast ( ) const
inline
Returns
*this with scalar type casted to NewScalarType
288  {
290  e.angles() = angles().template cast<NewScalarType>();
291  return e;
292  }
const Vector3 & angles() const
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:198

References Eigen::EulerAngles< Scalar_, _System >::angles(), and e().

◆ gamma() [1/2]

template<typename Scalar_ , class _System >
Scalar& Eigen::EulerAngles< Scalar_, _System >::gamma ( )
inline
Returns
A read-write reference to the angle of the third angle.
215 { return m_angles[2]; }

References Eigen::EulerAngles< Scalar_, _System >::m_angles.

◆ gamma() [2/2]

template<typename Scalar_ , class _System >
Scalar Eigen::EulerAngles< Scalar_, _System >::gamma ( ) const
inline
Returns
The value of the third angle.
213 { return m_angles[2]; }

References Eigen::EulerAngles< Scalar_, _System >::m_angles.

Referenced by Eigen::EulerAngles< Scalar_, _System >::operator QuaternionType().

◆ GammaAxisVector()

template<typename Scalar_ , class _System >
static Vector3 Eigen::EulerAngles< Scalar_, _System >::GammaAxisVector ( )
inlinestatic
Returns
the axis vector of the third (gamma) rotation
132  {
133  const Vector3& u = Vector3::Unit(System::GammaAxisAbs - 1);
134  return System::IsGammaOpposite ? -u : u;
135  }

Referenced by Eigen::EulerAngles< Scalar_, _System >::operator QuaternionType().

◆ inverse()

template<typename Scalar_ , class _System >
EulerAngles Eigen::EulerAngles< Scalar_, _System >::inverse ( ) const
inline
Returns
The Euler angles rotation inverse (which is as same as the negative), (-alpha, -beta, -gamma).
220  {
222  res.m_angles = -m_angles;
223  return res;
224  }
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3

References Eigen::EulerAngles< Scalar_, _System >::m_angles, and res.

Referenced by Eigen::EulerAngles< Scalar_, _System >::operator-().

◆ isApprox()

template<typename Scalar_ , class _System >
bool Eigen::EulerAngles< Scalar_, _System >::isApprox ( const EulerAngles< Scalar_, _System > &  other,
const RealScalar prec = NumTraits<Scalar>::dummy_precision() 
) const
inline
Returns
true if *this is approximately equal to other, within the precision determined by prec.
See also
MatrixBase::isApprox()
265  {
266  return angles().isApprox(other.angles(), prec);
267  }

References Eigen::EulerAngles< Scalar_, _System >::angles().

◆ operator QuaternionType()

template<typename Scalar_ , class _System >
Eigen::EulerAngles< Scalar_, _System >::operator QuaternionType ( ) const
inline

Convert the Euler angles to quaternion.

276  {
279  }
static Vector3 GammaAxisVector()
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:132
static Vector3 AlphaAxisVector()
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:120
static Vector3 BetaAxisVector()
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:126

References Eigen::EulerAngles< Scalar_, _System >::alpha(), Eigen::EulerAngles< Scalar_, _System >::AlphaAxisVector(), Eigen::EulerAngles< Scalar_, _System >::beta(), Eigen::EulerAngles< Scalar_, _System >::BetaAxisVector(), Eigen::EulerAngles< Scalar_, _System >::gamma(), and Eigen::EulerAngles< Scalar_, _System >::GammaAxisVector().

◆ operator-()

template<typename Scalar_ , class _System >
EulerAngles Eigen::EulerAngles< Scalar_, _System >::operator- ( void  ) const
inline
Returns
The Euler angles rotation negative (which is as same as the inverse), (-alpha, -beta, -gamma).
229 { return inverse(); }
EulerAngles inverse() const
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:220

References Eigen::EulerAngles< Scalar_, _System >::inverse().

◆ operator=() [1/2]

template<typename Scalar_ , class _System >
template<class Derived >
EulerAngles& Eigen::EulerAngles< Scalar_, _System >::operator= ( const MatrixBase< Derived > &  other)
inline

Set *this from either:

  • a 3x3 rotation matrix expression(i.e. pure orthogonal matrix with determinant of +1),
  • a 3D vector expression representing Euler angles.

See EulerAngles(const MatrixBase<Derived, 3>&) for more information about angles ranges output.

239  {
242  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
243 
245  return *this;
246  }
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
@ value
Definition: Meta.h:206
void run(const string &dir_name, LinearSolver *linear_solver_pt, const unsigned nel_1d, bool mess_up_order)
Definition: two_d_poisson_compare_solvers.cc:317

References EIGEN_STATIC_ASSERT, and run().

◆ operator=() [2/2]

template<typename Scalar_ , class _System >
template<typename Derived >
EulerAngles& Eigen::EulerAngles< Scalar_, _System >::operator= ( const RotationBase< Derived, 3 > &  rot)
inline

Set *this from a rotation.

See EulerAngles(const RotationBase<Derived, 3>&) for more information about angles ranges output.

256  {
257  System::CalcEulerAngles(*this, rot.toRotationMatrix());
258  return *this;
259  }

References rot().

◆ toRotationMatrix()

template<typename Scalar_ , class _System >
Matrix3 Eigen::EulerAngles< Scalar_, _System >::toRotationMatrix ( void  ) const
inline
Returns
an equivalent 3x3 rotation matrix.
270  {
271  // TODO: Calc it faster
272  return static_cast<QuaternionType>(*this).toRotationMatrix();
273  }

References Eigen::QuaternionBase< Derived >::toRotationMatrix().

Referenced by EulerAngles< Scalar_ >::operator QuaternionType().

Friends And Related Function Documentation

◆ operator<<

template<typename Scalar_ , class _System >
std::ostream& operator<< ( std::ostream &  s,
const EulerAngles< Scalar, System > &  eulerAngles 
)
friend
281  {
282  s << eulerAngles.angles().transpose();
283  return s;
284  }
RealScalar s
Definition: level1_cplx_impl.h:130

Member Data Documentation

◆ m_angles


The documentation for this class was generated from the following file: