Main MRPT website > C++ reference for MRPT 1.5.7
xseuler.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef XSEULER_H
10 #define XSEULER_H
11 
12 #include "xsmath.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #else
17 #define XSEULER_INITIALIZER { { { XsMath_zero,XsMath_zero,XsMath_zero } } }
18 #endif
19 
20 struct XsEuler;
21 struct XsQuaternion;
22 struct XsMatrix;
23 
24 XSTYPES_DLL_API void XsEuler_destruct(struct XsEuler* thisPtr);
25 XSTYPES_DLL_API int XsEuler_empty(const struct XsEuler* thisPtr);
26 XSTYPES_DLL_API void XsEuler_fromQuaternion(struct XsEuler* thisPtr, const struct XsQuaternion* quat);
27 
28 #ifdef __cplusplus
29 } // extern "C"
30 #endif
31 
32 struct XsEuler {
33 #ifdef __cplusplus
34  //! \brief Constructor that creates an Euler object with all angles 0
36  //! \brief Constructor that creates an Euler object the specified angles
37  inline XsEuler(XsReal x_, XsReal y_, XsReal z_) : m_x(x_), m_y(y_), m_z(z_) {}
38  //! \brief Constructor that creates an Euler object from \a other
39  inline XsEuler(const XsEuler& other) : m_x(other.m_x), m_y(other.m_y), m_z(other.m_z) {}
40 
41  //! \brief \copybrief XsEuler_fromQuaternion
42  inline explicit XsEuler(const XsQuaternion& q)
43  {
44  XsEuler_fromQuaternion(this, &q);
45  }
46 
47  //! \brief Assigns the \a other XsEuler object to this one
48  inline XsEuler& operator=(const XsEuler& other)
49  {
50  m_x = other.m_x;
51  m_y = other.m_y;
52  m_z = other.m_z;
53  return *this;
54  }
55 
56  //! \brief Returns the \a index'th euler angle in the object
57  inline XsReal operator[](XsSize index) const
58  {
59  assert (index <= 2);
60  return m_data[index];
61  }
62 
63  //! \brief Returns a reference to the \a index'th euler angle in the object
64  inline XsReal &operator[](XsSize index)
65  {
66  assert (index <= 2);
67  return m_data[index];
68  }
69 
70  //! \brief Returns true if all angles in this object are zero
71  inline bool empty() const
72  {
73  return m_x == XsMath_zero && m_y == XsMath_zero && m_z == XsMath_zero;
74  }
75 
76  //! \brief Return a const pointer to the internal data
77  inline const XsReal* data() const
78  {
79  return m_data;
80  }
81 
82  //! \brief \copybrief XsEuler_fromQuaternion
83  inline XsEuler& fromQuaternion(const XsQuaternion& quat)
84  {
85  XsEuler_fromQuaternion(this, &quat);
86  return *this;
87  }
88 
89  /*! \brief Returns true if the values in \a other are exactly equal to this
90  */
91  inline bool operator == (const XsEuler& other) const
92  {
93  return m_roll == other.m_roll && m_pitch == other.m_pitch && m_yaw == other.m_yaw;
94  }
95 
96  /*! \brief Returns true if the values in \a other are different from this
97  */
98  inline bool operator != (const XsEuler& other) const
99  {
100  return m_roll != other.m_roll || m_pitch != other.m_pitch || m_yaw != other.m_yaw;
101  }
102 
103  //! \brief Returns the roll or x value
104  inline XsReal roll() const { return m_roll; }
105  //! \brief Returns the pitch or y value
106  inline XsReal pitch() const { return m_pitch; }
107  //! \brief Returns the yaw or z value
108  inline XsReal yaw() const { return m_yaw; }
109 
110  //! \brief Returns the x or roll value
111  inline XsReal x() const { return m_x; }
112  //! \brief Returns the y or pitch value
113  inline XsReal y() const { return m_y; }
114  //! \brief Returns the z or yaw value
115  inline XsReal z() const { return m_z; }
116 
117 private:
118 #endif
119 
120  union {
121  struct {
122  XsReal m_x; //!< Stores the x component of the euler triplet
123  XsReal m_y; //!< Stores the y component of the euler triplet
124  XsReal m_z; //!< Stores the z component of the euler triplet
125  };
126  struct {
127  XsReal m_roll; //!< Stores the roll component of the euler triplet
128  XsReal m_pitch; //!< Stores the pitch component of the euler triplet
129  XsReal m_yaw; //!< Stores the yaw component of the euler triplet
130  };
131  XsReal m_data[3]; //!< Stores the euler triplet in an array of three elements
132  };
133 };
134 
135 typedef struct XsEuler XsEuler;
136 
137 #endif // file guard
XsReal m_z
Stores the z component of the euler triplet.
Definition: xseuler.h:124
bool operator==(const TPoint2D &p1, const TPoint2D &p2)
Exact comparison between 2D points.
EIGEN_STRONG_INLINE bool empty() const
GLdouble GLdouble z
Definition: glext.h:3734
XSTYPES_DLL_API const XsReal XsMath_zero
GLdouble GLdouble GLdouble GLdouble q
Definition: glext.h:3626
bool operator!=(const TPoint2D &p1, const TPoint2D &p2)
Exact comparison between 2D points.
XsReal m_roll
Stores the roll component of the euler triplet.
Definition: xseuler.h:127
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:17
XsReal m_data[3]
Stores the euler triplet in an array of three elements.
Definition: xseuler.h:131
GLuint index
Definition: glext.h:3891
VALUE & operator[](const KEY &key)
Write/read via [i] operator, that creates an element if it didn&#39;t exist already.
Definition: ts_hash_map.h:123
XsReal m_yaw
Stores the yaw component of the euler triplet.
Definition: xseuler.h:129
XSTYPES_DLL_API void XsEuler_destruct(struct XsEuler *thisPtr)
#define XSTYPES_DLL_API
Definition: xstypesconfig.h:9
XSTYPES_DLL_API void XsEuler_fromQuaternion(struct XsEuler *thisPtr, const struct XsQuaternion *quat)
double XsReal
Defines the floating point type used by the Xsens libraries.
Definition: xstypedefs.h:16
struct XsEuler XsEuler
Definition: xseuler.h:135
GLenum GLint GLint y
Definition: glext.h:3516
XsReal m_y
Stores the y component of the euler triplet.
Definition: xseuler.h:123
XSTYPES_DLL_API int XsEuler_empty(const struct XsEuler *thisPtr)
GLenum GLint x
Definition: glext.h:3516
XsReal m_pitch
Stores the pitch component of the euler triplet.
Definition: xseuler.h:128
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3520
XsReal m_x
Stores the x component of the euler triplet.
Definition: xseuler.h:122



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019