sbg_vector3.h
Go to the documentation of this file.
1 
36 #ifndef SBG_VECTOR_3_H
37 #define SBG_VECTOR_3_H
38 
39 // ROS headers
40 #include <geometry_msgs/Vector3.h>
41 
42 // Sbg headers
43 #include <sbgDefines.h>
44 
45 namespace sbg
46 {
55 template <typename T>
56 bool areEquals(T firstValue, T secondValue)
57 {
58  //
59  // The machine epsilon has to be scaled to the magnitude of the values used.
60  //
61  return std::fabs(firstValue - secondValue) <= (std::numeric_limits<T>::epsilon() * std::fabs(firstValue + secondValue));
62 }
63 
67 template <class T>
69 {
70 private:
71 
72  //---------------------------------------------------------------------//
73  //- Private variables -//
74  //---------------------------------------------------------------------//
75 
76  std::array<T, 3> m_data;
77 
78 public:
79 
80  //---------------------------------------------------------------------//
81  //- Constructor -//
82  //---------------------------------------------------------------------//
83 
87  SbgVector3(void)
88  {
89  m_data[0] = static_cast<T>(0.0);
90  m_data[1] = static_cast<T>(0.0);
91  m_data[2] = static_cast<T>(0.0);
92  }
93 
101  SbgVector3(T x_value, T y_value, T z_value)
102  {
103  m_data[0] = x_value;
104  m_data[1] = y_value;
105  m_data[2] = z_value;
106  };
107 
114  SbgVector3(const T* p_raw_data, size_t array_size)
115  {
116  assert(array_size == 3);
117 
118  m_data[0] = p_raw_data[0];
119  m_data[1] = p_raw_data[1];
120  m_data[2] = p_raw_data[2];
121  };
122 
123  //---------------------------------------------------------------------//
124  //- Parameters -//
125  //---------------------------------------------------------------------//
126 
127  //---------------------------------------------------------------------//
128  //- Operations -//
129  //---------------------------------------------------------------------//
130 
137  bool operator==(const SbgVector3<T> &ref_vector)
138  {
139  return ((areEquals(m_data[0], ref_vector.m_data[0]))
140  && (areEquals(m_data[1], ref_vector.m_data[1]))
141  && (areEquals(m_data[2], ref_vector.m_data[2])));
142  };
143 
150  bool operator!=(const SbgVector3<T> &ref_vector)
151  {
152  return !(*this == ref_vector);
153  };
154 
160  const T operator()(size_t index) const
161  {
162  assert(index < 3);
163 
164  return m_data[index];
165  }
166 
172  const T *data(void) const
173  {
174  return static_cast<const T*>(m_data.data());
175  };
176 };
177 
180 
181 }
182 
183 #endif // SBG_VECTOR_3_H
SbgVector3< double > SbgVector3d
Definition: sbg_vector3.h:179
const T * data(void) const
Definition: sbg_vector3.h:172
bool operator!=(const SbgVector3< T > &ref_vector)
Definition: sbg_vector3.h:150
SbgVector3< float > SbgVector3f
Definition: sbg_vector3.h:178
bool operator==(const SbgVector3< T > &ref_vector)
Definition: sbg_vector3.h:137
bool areEquals(T firstValue, T secondValue)
Definition: sbg_vector3.h:56
std::array< T, 3 > m_data
Definition: sbg_vector3.h:76
SbgVector3(const T *p_raw_data, size_t array_size)
Definition: sbg_vector3.h:114
SbgVector3(T x_value, T y_value, T z_value)
Definition: sbg_vector3.h:101
Header file that contains all common definitions.
const T operator()(size_t index) const
Definition: sbg_vector3.h:160


sbg_driver
Author(s): SBG Systems
autogenerated on Sat Sep 3 2022 02:53:35