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


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:16