Util.hpp
Go to the documentation of this file.
1 
28 /*
29  * Util.hpp
30  *
31  * @date 30.10.2018
32  * @author Alexander Loehr (aloehr@uos.de)
33  */
34 
35 #ifndef LVR2_UTIL_HPP
36 #define LVR2_UTIL_HPP
37 
38 #include <vector>
39 #include <boost/shared_array.hpp>
40 
42 #include "lvr2/io/PointBuffer.hpp"
45 
46 
47 namespace lvr2
48 {
49 
51 
56 class Util
57 {
58 public:
59 
74  static int getSpectralChannel(int wavelength, PointBufferPtr p, int fallback = -1);
75 
88  static int getSpectralWavelength(int channel, PointBufferPtr p, int fallback = -1);
89 
98  static float wavelengthPerChannel(PointBufferPtr p);
99 
107  template<typename T>
108  static boost::shared_array<T> convert_vector_to_shared_array(std::vector<T> source)
109  {
110  boost::shared_array<T> ret = boost::shared_array<T>( new T[source.size()] );
111  std::copy(source.begin(), source.end(), ret.get());
112 
113  return ret;
114  }
115 
124  template <typename BaseVecT>
126  {
127  Matrix4<BaseVecT> ret;
128 
129  ret[0] = in[5];
130  ret[1] = -in[9];
131  ret[2] = -in[1];
132  ret[3] = -in[13];
133  ret[4] = -in[6];
134  ret[5] = in[10];
135  ret[6] = in[2];
136  ret[7] = in[14];
137  ret[8] = -in[4];
138  ret[9] = in[8];
139  ret[10] = in[0];
140  ret[11] = in[12];
141  ret[12] = -100*in[7];
142  ret[13] = 100*in[11];
143  ret[14] = 100*in[3];
144  ret[15] = in[15];
145 
146  return ret;
147  }
148 
157  template <typename T>
159  {
160  T* in = mat.data();
161  T* ret[16];
162  ret[0] = in[10];
163  ret[1] = -in[2];
164  ret[2] = in[6];
165  ret[3] = in[14]/100.0;
166  ret[4] = -in[8];
167  ret[5] = in[0];
168  ret[6] = -in[4];
169  ret[7] = -in[12]/100.0;
170  ret[8] = in[9];
171  ret[9] = -in[1];
172  ret[10] = in[5];
173  ret[11] = in[13]/100.0;
174  ret[12] = in[11];
175  ret[13] = -in[3];
176  ret[14] = in[7];
177  ret[15] = in[15];
178 
179  return Eigen::Map<Eigen::Matrix<T, 4, 4, Eigen::RowMajor> >(ret);
180  }
181 
182  template <typename ValueType>
184  {
185  return {
186  in.z / (ValueType) 100.0,
187  - in.x / (ValueType) 100.0,
188  in.y / (ValueType) 100.0
189  };
190  }
191 
192 
193 
201  template <typename ValueType>
202  static ValueType deg_to_rad(ValueType deg)
203  {
204  return M_PI / 180.0 * deg;
205  }
206 
214  template <typename ValueType>
215  static ValueType rad_to_deg(ValueType rad)
216  {
217  return rad * 180 / M_PI;
218  }
219 
224  {
225 
234  bool operator() (const VecUChar& lhs, const VecUChar& rhs) const
235  {
236  return (lhs.x < rhs.x) ||
237  (lhs.x == rhs.x && lhs.y < rhs.y) ||
238  (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z < rhs.z);
239  }
240  };
241 };
242 
243 } // namespace lvr2
244 
245 #endif
A comparison object for Vector<VecUChar>
Definition: Util.hpp:223
A 4x4 matrix class implementation for use with the provided vertex types.
Definition: Matrix4.hpp:64
bool operator()(const VecUChar &lhs, const VecUChar &rhs) const
Comparison operator.
Definition: Util.hpp:234
static int getSpectralChannel(int wavelength, PointBufferPtr p, int fallback=-1)
Returns the spectral channel index for a given wavelength.
Definition: Util.cpp:35
static ValueType deg_to_rad(ValueType deg)
Converts an angle from degree to radian.
Definition: Util.hpp:202
static ValueType rad_to_deg(ValueType rad)
Converts an angle from radian to degree.
Definition: Util.hpp:215
#define M_PI
Definition: Matrix4.hpp:52
static Matrix4< BaseVecT > riegl_to_slam6d_transform(const Matrix4< BaseVecT > &in)
Converts a transformation matrix that is used in riegl coordinate system into a transformation matrix...
Definition: Util.hpp:125
std::shared_ptr< PointBuffer > PointBufferPtr
SharedPointer p
static BaseVector< ValueType > slam6d_to_riegl_point(const BaseVector< ValueType > &in)
Definition: Util.hpp:183
static int getSpectralWavelength(int channel, PointBufferPtr p, int fallback=-1)
For a given spectral channel it return the corresponding wavelength.
Definition: Util.cpp:55
static float wavelengthPerChannel(PointBufferPtr p)
Calculates the wavelength distance between two spectral channels.
Definition: Util.cpp:73
A class that contains utility functions/types.
Definition: Util.hpp:56
Transform< T > slam6d_to_riegl_transform(const Transform< T > &mat)
Converts a transformation matrix that is used in slam6d coordinate system into a transformation matri...
Definition: Util.hpp:158
static boost::shared_array< T > convert_vector_to_shared_array(std::vector< T > source)
Creates a shared array with the data from the given vector.
Definition: Util.hpp:108
A generic, weakly-typed vector.
Definition: BaseVector.hpp:60
Eigen::Matrix< T, 4, 4 > Transform
General 4x4 transformation matrix (4x4)
Definition: MatrixTypes.hpp:65


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:09