![]() |
Eigen-unsupported
3.3.3
|
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:
### 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 singular 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:
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 ####
When converting some rotation to Euler angles, there are some ways you can guarantee the Euler angles ranges.
#### implicit ranges #### When using implicit ranges, all angles are guarantee to be in the range [-PI, +PI], unless you convert from some other Euler angles. In this case, the range is __undefined__ (might be even less than -PI or greater than +2*PI).
#### explicit ranges #### When using explicit ranges, all angles are guarantee to be in the range you choose. In the range Boolean parameter, you're been ask whether you prefer the positive range or not:
##### compile time ranges ##### This is when you have compile time ranges and you prefer to use template parameter. (e.g. for performance)
##### run-time time ranges ##### Run-time ranges are also supported.
### 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 ###
#include <unsupported/Eigen/EulerAngles> #include <iostream> using namespace Eigen; int main() { // A common Euler system by many armies around the world, // where the first one is the azimuth(the angle from the north - // the same angle that is show in compass) // and the second one is elevation(the angle from the horizon) // and the third one is roll(the angle between the horizontal body // direction and the plane ground surface) // Keep remembering we're using radian angles here! typedef EulerSystem<-EULER_Z, EULER_Y, EULER_X> MyArmySystem; typedef EulerAngles<double, MyArmySystem> MyArmyAngles; MyArmyAngles vehicleAngles( 3.14/*PI*/ / 2, /* heading to east, notice that this angle is counter-clockwise */ -0.3, /* going down from a mountain */ 0.1); /* slightly rolled to the right */ // Some Euler angles representation that our plane use. EulerAnglesZYZd planeAngles(0.78474, 0.5271, -0.513794); MyArmyAngles planeAnglesInMyArmyAngles = MyArmyAngles::FromRotation<true, false, false>(planeAngles); std::cout << "vehicle angles(MyArmy): " << vehicleAngles << std::endl; std::cout << "plane angles(ZYZ): " << planeAngles << std::endl; std::cout << "plane angles(MyArmy): " << planeAnglesInMyArmyAngles << std::endl; // Now lets rotate the plane a little bit std::cout << "==========================================================\n"; std::cout << "rotating plane now!\n"; std::cout << "==========================================================\n"; Quaterniond planeRotated = AngleAxisd(-0.342, Vector3d::UnitY()) * planeAngles; planeAngles = planeRotated; planeAnglesInMyArmyAngles = MyArmyAngles::FromRotation<true, false, false>(planeRotated); std::cout << "new plane angles(ZYZ): " << planeAngles << std::endl; std::cout << "new plane angles(MyArmy): " << planeAnglesInMyArmyAngles << std::endl; return 0; }
Output:
vehicle angles(MyArmy): 1.57 -0.3 0.1 plane angles(ZYZ): 0.78474 0.5271 -0.513794 plane angles(MyArmy): 6.07691 0.453463 -0.278617 ========================================================== rotating plane now! ========================================================== new plane angles(ZYZ): 1.44358 0.366507 -1.23637 new plane angles(MyArmy): 6.09671 0.117896 -0.347841
### 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
_Scalar | the scalar type, i.e., the type of the angles. |
_System | the EulerSystem to use, which represents the axes of rotation. |
Inherits RotationBase< EulerAngles< _Scalar, _System >, 3 >.
Public Types | |
typedef AngleAxis< Scalar > | AngleAxisType |
typedef Matrix< Scalar, 3, 3 > | Matrix3 |
typedef Quaternion< Scalar > | QuaternionType |
typedef _Scalar | Scalar |
typedef _System | System |
typedef Matrix< Scalar, 3, 1 > | Vector3 |
Public Member Functions | |
Scalar | alpha () const |
Scalar & | alpha () |
const Vector3 & | angles () const |
Vector3 & | angles () |
Scalar | beta () const |
Scalar & | beta () |
EulerAngles () | |
EulerAngles (const Scalar &alpha, const Scalar &beta, const Scalar &gamma) | |
template<typename Derived > | |
EulerAngles (const MatrixBase< Derived > &m) | |
template<typename Derived > | |
EulerAngles (const MatrixBase< Derived > &m, bool positiveRangeAlpha, bool positiveRangeBeta, bool positiveRangeGamma) | |
template<typename Derived > | |
EulerAngles (const RotationBase< Derived, 3 > &rot) | |
template<typename Derived > | |
EulerAngles (const RotationBase< Derived, 3 > &rot, bool positiveRangeAlpha, bool positiveRangeBeta, bool positiveRangeGamma) | |
Scalar | gamma () const |
Scalar & | gamma () |
EulerAngles | inverse () const |
operator QuaternionType () const | |
EulerAngles | operator- () const |
template<typename Derived > | |
EulerAngles & | operator= (const MatrixBase< Derived > &m) |
template<typename Derived > | |
EulerAngles & | operator= (const RotationBase< Derived, 3 > &rot) |
Matrix3 | toRotationMatrix () const |
Static Public Member Functions | |
static Vector3 | AlphaAxisVector () |
static Vector3 | BetaAxisVector () |
template<bool PositiveRangeAlpha, bool PositiveRangeBeta, bool PositiveRangeGamma, typename Derived > | |
static EulerAngles | FromRotation (const MatrixBase< Derived > &m) |
template<bool PositiveRangeAlpha, bool PositiveRangeBeta, bool PositiveRangeGamma, typename Derived > | |
static EulerAngles | FromRotation (const RotationBase< Derived, 3 > &rot) |
static Vector3 | GammaAxisVector () |
typedef AngleAxis<Scalar> Eigen::EulerAngles< _Scalar, _System >::AngleAxisType |
the equivalent angle-axis type
typedef Matrix<Scalar,3,3> Eigen::EulerAngles< _Scalar, _System >::Matrix3 |
the equivalent rotation matrix type
typedef Quaternion<Scalar> Eigen::EulerAngles< _Scalar, _System >::QuaternionType |
the equivalent quaternion type
typedef _Scalar Eigen::EulerAngles< _Scalar, _System >::Scalar |
the scalar type of the angles
typedef _System Eigen::EulerAngles< _Scalar, _System >::System |
the EulerSystem to use, which represents the axes of rotation.
typedef Matrix<Scalar,3,1> Eigen::EulerAngles< _Scalar, _System >::Vector3 |
the equivalent 3 dimension vector type
Eigen::EulerAngles< _Scalar, _System >::EulerAngles | ( | ) | [inline] |
Default constructor without initialization.
Eigen::EulerAngles< _Scalar, _System >::EulerAngles | ( | const Scalar & | alpha, |
const Scalar & | beta, | ||
const Scalar & | gamma | ||
) | [inline] |
Constructs and initialize Euler angles(alpha
, beta
, gamma
).
Eigen::EulerAngles< _Scalar, _System >::EulerAngles | ( | const MatrixBase< Derived > & | m | ) | [inline] |
Constructs and initialize Euler angles from a 3x3 rotation matrix m
.
Eigen::EulerAngles< _Scalar, _System >::EulerAngles | ( | const MatrixBase< Derived > & | m, |
bool | positiveRangeAlpha, | ||
bool | positiveRangeBeta, | ||
bool | positiveRangeGamma | ||
) | [inline] |
Constructs and initialize Euler angles from a 3x3 rotation matrix m
, with options to choose for each angle the requested range.
If positive range is true, then the specified angle will be in the range [0, +2*PI]. Otherwise, the specified angle will be in the range [-PI, +PI].
m | The 3x3 rotation matrix to convert |
positiveRangeAlpha | If true, alpha will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
positiveRangeBeta | If true, beta will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
positiveRangeGamma | If true, gamma will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
Eigen::EulerAngles< _Scalar, _System >::EulerAngles | ( | const RotationBase< Derived, 3 > & | rot | ) | [inline] |
Constructs and initialize Euler angles from a rotation rot
.
rot
is an EulerAngles. If rot is an EulerAngles, expected EulerAngles range is __undefined__. (Use other functions here for enforcing range if this effect is desired) Eigen::EulerAngles< _Scalar, _System >::EulerAngles | ( | const RotationBase< Derived, 3 > & | rot, |
bool | positiveRangeAlpha, | ||
bool | positiveRangeBeta, | ||
bool | positiveRangeGamma | ||
) | [inline] |
Constructs and initialize Euler angles from a rotation rot
, with options to choose for each angle the requested range.
If positive range is true, then the specified angle will be in the range [0, +2*PI]. Otherwise, the specified angle will be in the range [-PI, +PI].
rot | The 3x3 rotation matrix to convert |
positiveRangeAlpha | If true, alpha will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
positiveRangeBeta | If true, beta will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
positiveRangeGamma | If true, gamma will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
Scalar Eigen::EulerAngles< _Scalar, _System >::alpha | ( | ) | const [inline] |
Scalar& Eigen::EulerAngles< _Scalar, _System >::alpha | ( | ) | [inline] |
static Vector3 Eigen::EulerAngles< _Scalar, _System >::AlphaAxisVector | ( | ) | [inline, static] |
const Vector3& Eigen::EulerAngles< _Scalar, _System >::angles | ( | ) | const [inline] |
Vector3& Eigen::EulerAngles< _Scalar, _System >::angles | ( | ) | [inline] |
Scalar Eigen::EulerAngles< _Scalar, _System >::beta | ( | ) | const [inline] |
Scalar& Eigen::EulerAngles< _Scalar, _System >::beta | ( | ) | [inline] |
static Vector3 Eigen::EulerAngles< _Scalar, _System >::BetaAxisVector | ( | ) | [inline, static] |
static EulerAngles Eigen::EulerAngles< _Scalar, _System >::FromRotation | ( | const MatrixBase< Derived > & | m | ) | [inline, static] |
Constructs and initialize Euler angles from a 3x3 rotation matrix m
, with options to choose for each angle the requested range (__only in compile time__).
If positive range is true, then the specified angle will be in the range [0, +2*PI]. Otherwise, the specified angle will be in the range [-PI, +PI].
m | The 3x3 rotation matrix to convert |
positiveRangeAlpha | If true, alpha will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
positiveRangeBeta | If true, beta will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
positiveRangeGamma | If true, gamma will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
static EulerAngles Eigen::EulerAngles< _Scalar, _System >::FromRotation | ( | const RotationBase< Derived, 3 > & | rot | ) | [inline, static] |
Constructs and initialize Euler angles from a rotation rot
, with options to choose for each angle the requested range (__only in compile time__).
If positive range is true, then the specified angle will be in the range [0, +2*PI]. Otherwise, the specified angle will be in the range [-PI, +PI].
rot | The 3x3 rotation matrix to convert |
positiveRangeAlpha | If true, alpha will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
positiveRangeBeta | If true, beta will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
positiveRangeGamma | If true, gamma will be in [0, 2*PI]. Otherwise, in [-PI, +PI]. |
Scalar Eigen::EulerAngles< _Scalar, _System >::gamma | ( | ) | const [inline] |
Scalar& Eigen::EulerAngles< _Scalar, _System >::gamma | ( | ) | [inline] |
static Vector3 Eigen::EulerAngles< _Scalar, _System >::GammaAxisVector | ( | ) | [inline, static] |
EulerAngles Eigen::EulerAngles< _Scalar, _System >::inverse | ( | ) | const [inline] |
Eigen::EulerAngles< _Scalar, _System >::operator QuaternionType | ( | ) | const [inline] |
Convert the Euler angles to quaternion.
EulerAngles Eigen::EulerAngles< _Scalar, _System >::operator- | ( | ) | const [inline] |
EulerAngles& Eigen::EulerAngles< _Scalar, _System >::operator= | ( | const MatrixBase< Derived > & | m | ) | [inline] |
Set *this
from a rotation matrix(i.e. pure orthogonal matrix with determinant of +1).
EulerAngles& Eigen::EulerAngles< _Scalar, _System >::operator= | ( | const RotationBase< Derived, 3 > & | rot | ) | [inline] |
Set *this
from a rotation.
Matrix3 Eigen::EulerAngles< _Scalar, _System >::toRotationMatrix | ( | ) | const [inline] |