Helios++
Helios software for LiDAR simulations
Rotation.h
1 #pragma once
2 
3 #include "RotationOrder.h"
4 
5 #include <boost/archive/text_iarchive.hpp>
6 #include <boost/archive/text_oarchive.hpp>
7 
8 #if PYTHON_BINDING
9 #include <PythonDVec3.h>
11 #endif
12 
80 class Rotation {
81  // *** SERIALIZATION *** //
82  // *********************** //
83  friend class boost::serialization::access;
84  template<class Archive>
85  void serialize(Archive &ar, const unsigned int version) {
86  ar & q0 & q1 & q2 & q3;
87  }
88 
89  // *** ATTRIBUTES *** //
90  // ******************** //
92  double q0, q1, q2, q3;
93 
94 public:
95  // *** CONSTRUCTION / DESTRUCTION *** //
96  // ************************************ //
97  Rotation() = default;
98  Rotation(double q0, double q1, double q2, double q3, bool needsNormalization);
99  Rotation(glm::dvec3 axis, double angle);
100  Rotation(glm::dvec3 u, glm::dvec3 v);
101  Rotation(RotationOrder order, double alpha1, double alpha2, double alpha3);
102  virtual ~Rotation() = default;
103 
104 
105 
107  //const Rotation *IDENTITY = new Rotation(1.0, 0.0, 0.0, 0.0, false);
108 
109  // *** GETTERS and SETTERS *** //
110  // ***************************** //
115  double getQ0() const {return q0;}
116  void setQ0(double q0) {this->q0 = q0;}
117 
122  double getQ1() const {return q1;}
123  void setQ1(double q1) {this->q1 = q1;}
124 
130  double getQ2() const {return q2;}
131  void setQ2(double q2) {this->q2 = q2;}
132 
137  double getQ3() const {return q3;}
138  void setQ3(double q3) {this->q3 = q3;}
139 
140  // *** M E T H O D S *** //
141  // *********************** //
142  Rotation revert();
143  glm::dvec3 getAxis();
144  double getAngle();
145  double** getMatrix();
146  glm::dvec3 applyTo(glm::dvec3 u);
147  void applyTo(double* in, double* out);
148  glm::dvec3 applyInverseTo(glm::dvec3 u);
149  void applyInverseTo(double* in, double* out);
152  glm::dvec3 operator*(glm::dvec3 u) {return applyTo(u);}
153  Rotation operator*(Rotation r) {return applyTo(r);}
154 
162  void getAngles(
163  RotationOrder const *order,
164  double &roll,
165  double &pitch,
166  double &yaw
167  );
168 
169  friend std::ostream& operator << (std::ostream& out, Rotation& r);
170 
171 #ifdef PYTHON_BINDING
172  PythonDVec3 * getAxisPython() {return new PythonDVec3(getAxis());}
173 #endif
174 
175 };
Definition: RotationOrder.h:18
Definition: Rotation.h:80
double getAngle()
Definition: Rotation.cpp:196
glm::dvec3 getAxis()
Definition: Rotation.cpp:179
friend std::ostream & operator<<(std::ostream &out, Rotation &r)
Definition: Rotation.cpp:527
double getQ2() const
Get the second coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:130
double getQ1() const
Get the first coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:122
void getAngles(RotationOrder const *order, double &roll, double &pitch, double &yaw)
Get the roll, pitch and yaw for the Rotation.
Definition: Rotation.cpp:360
double q0
Definition: Rotation.h:92
double ** getMatrix()
Definition: Rotation.cpp:210
Rotation revert()
Definition: Rotation.cpp:171
glm::dvec3 applyTo(glm::dvec3 u)
Definition: Rotation.cpp:250
glm::dvec3 applyInverseTo(glm::dvec3 u)
Definition: Rotation.cpp:287
double getQ3() const
Get the third coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:137
double getQ0() const
Get the scalar coordinate of the quaternion.
Definition: Rotation.h:115
Wrapper to communicate glm::dvec3 with python.
Definition: PythonDVec3.h:16