doc/examples/EulerAngles.cpp File Reference
#include <unsupported/Eigen/EulerAngles>
#include <iostream>

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
6  {
7  // A common Euler system by many armies around the world,
8  // where the first one is the azimuth(the angle from the north -
9  // the same angle that is show in compass)
10  // and the second one is elevation(the angle from the horizon)
11  // and the third one is roll(the angle between the horizontal body
12  // direction and the plane ground surface)
13  // Keep remembering we're using radian angles here!
14  typedef EulerSystem<-EULER_Z, EULER_Y, EULER_X> MyArmySystem;
15  typedef EulerAngles<double, MyArmySystem> MyArmyAngles;
16 
17  MyArmyAngles vehicleAngles(3.14 /*PI*/ / 2, /* heading to east, notice that this angle is counter-clockwise */
18  -0.3, /* going down from a mountain */
19  0.1); /* slightly rolled to the right */
20 
21  // Some Euler angles representation that our plane use.
22  EulerAnglesZYZd planeAngles(0.78474, 0.5271, -0.513794);
23 
24  MyArmyAngles planeAnglesInMyArmyAngles(planeAngles);
25 
26  std::cout << "vehicle angles(MyArmy): " << vehicleAngles << std::endl;
27  std::cout << "plane angles(ZYZ): " << planeAngles << std::endl;
28  std::cout << "plane angles(MyArmy): " << planeAnglesInMyArmyAngles << std::endl;
29 
30  // Now lets rotate the plane a little bit
31  std::cout << "==========================================================\n";
32  std::cout << "rotating plane now!\n";
33  std::cout << "==========================================================\n";
34 
35  Quaterniond planeRotated = AngleAxisd(-0.342, Vector3d::UnitY()) * planeAngles;
36 
37  planeAngles = planeRotated;
38  planeAnglesInMyArmyAngles = planeRotated;
39 
40  std::cout << "new plane angles(ZYZ): " << planeAngles << std::endl;
41  std::cout << "new plane angles(MyArmy): " << planeAnglesInMyArmyAngles << std::endl;
42 
43  return 0;
44 }
Represents a rotation in a 3 dimensional space as three Euler angles.
Definition: unsupported/Eigen/src/EulerAngles/EulerAngles.h:103
Represents a fixed Euler rotation system.
Definition: EulerSystem.h:121
The quaternion class used to represent 3D orientations and rotations.
Definition: Eigen/Eigen/src/Geometry/Quaternion.h:285
AngleAxis< double > AngleAxisd
Definition: AngleAxis.h:168
@ EULER_X
Definition: EulerSystem.h:58
@ EULER_Z
Definition: EulerSystem.h:60
@ EULER_Y
Definition: EulerSystem.h:59

References Eigen::EULER_X, Eigen::EULER_Y, and Eigen::EULER_Z.