Parasol Planning Library (PPL)
Conversions.h
Go to the documentation of this file.
1 #ifndef SIMULATOR_CONVERSIONS_H_
2 #define SIMULATOR_CONVERSIONS_H_
3 
4 #include <iostream>
5 
6 #include "Matrix.h"
7 #include "Quaternion.h"
8 #include "Transformation.h"
9 #include "Vector.h"
10 
11 #include "glutils/color.h"
12 #include "glutils/gltraits.h"
13 
14 using namespace mathtool;
15 
16 /*--------------------- Conversion from PMPL to glutils ----------------------*/
17 
18 inline glutils::transform ToGLUtils(const Transformation& _t) {
19  const auto& r = _t.rotation().matrix();
20  const auto& t = _t.translation();
21  // Ignore silly narrowing warnings here.
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-Wnarrowing"
24  // Note that the glutils transform is in COLUMN MAJOR order to match OpenGL's
25  // convention.
26  return glutils::transform{
27  r[0][0], r[1][0], r[2][0], 0, r[0][1], r[1][1], r[2][1], 0,
28  r[0][2], r[1][2], r[2][2], 0, t[0], t[1], t[2], 1};
29 #pragma GCC diagnostic pop
30 }
31 
32 inline glutils::vector3f ToGLUtils(const Vector3d& _v) {
33 #pragma GCC diagnostic push
34 #pragma GCC diagnostic ignored "-Wnarrowing"
35  return {_v[0], _v[1], _v[2]};
36 #pragma GCC diagnostic pop
37 }
38 
39 glutils::color StringToColor(const std::string& _color);
40 
41 /*----------------------------------------------------------------------------*/
42 
43 #endif
glutils::color StringToColor(const std::string &_color)
Definition: Conversions.cpp:9
glutils::transform ToGLUtils(const Transformation &_t)
Definition: Conversions.h:18
Definition: Cfg.h:23