LArSoft  v10_04_05
Liquid Argon Software toolkit - https://larsoft.org/
LocalTransformation.h
Go to the documentation of this file.
1 
8 #ifndef LARCOREALG_GEOMETRY_LOCALTRANSFORMATION_H
9 #define LARCOREALG_GEOMETRY_LOCALTRANSFORMATION_H
10 
11 // ROOT libraries
12 class TGeoNode;
13 
14 // C/C++ standard libraries
15 #include <cstdlib> // std::size_t
16 #include <type_traits> // std::enable_if_t<>, std::decay_t<>
17 #include <utility> // std::move(), std::forward()
18 #include <vector>
19 
20 // forward declarations
21 class TGeoNode;
22 
23 namespace geo {
24 
25  namespace details {
26  template <typename Dest, typename Src>
28  } // namespace details
29 
31  TGeoNode const* node;
32  std::size_t hash_value;
33  };
34 
36 
38  template <typename StoredMatrix, typename ITER>
39  static StoredMatrix transformationFromPath(ITER begin, ITER end);
40 
42  template <typename StoredMatrix>
43  static StoredMatrix transformationFromPath(std::vector<GeoNodePathEntry> const& path,
44  size_t depth);
45 
60  template <typename StoredMatrix>
62  public:
64  using TransformationMatrix_t = StoredMatrix;
65 
67 
78  LocalTransformation(TransformationMatrix_t const& matrix) : fGeoMatrix(matrix) {}
79  LocalTransformation(TransformationMatrix_t&& matrix) : fGeoMatrix(std::move(matrix)) {}
81 
90  LocalTransformation(std::vector<GeoNodePathEntry> const& path, size_t depth)
91  : fGeoMatrix(transformationFromPath<StoredMatrix>(path.begin(), path.begin() + depth + 1))
92  {}
93 
101  LocalTransformation(std::vector<GeoNodePathEntry> const& path)
102  : LocalTransformation(path, path.size())
103  {}
104 
114  template <typename ITER>
116  : fGeoMatrix(transformationFromPath<StoredMatrix>(begin, end))
117  {}
118 
138  void LocalToWorld(double const* local, double* world) const;
139 
140  // @{
159  template <typename DestPoint,
160  typename SrcPoint,
162  DestPoint LocalToWorld(SrcPoint const& local) const
163  {
164  return LocalToWorldImpl<DestPoint>(local);
165  }
166  template <typename Point>
167  Point LocalToWorld(Point const& local) const
168  {
169  return LocalToWorldImpl<Point>(local);
170  }
171  // @}
172 
184  void LocalToWorldVect(double const* local, double* world) const;
185 
187 
197  template <typename DestVector,
198  typename SrcVector,
200  DestVector LocalToWorldVect(SrcVector const& local) const
201  {
202  return LocalToWorldVectImpl<DestVector>(local);
203  }
204  template <typename Vector>
205  Vector LocalToWorldVect(Vector const& local) const
206  {
207  return LocalToWorldVectImpl<Vector>(local);
208  }
210 
228  void WorldToLocal(double const* world, double* local) const;
229 
231 
247  template <typename DestPoint,
248  typename SrcPoint,
250  DestPoint WorldToLocal(SrcPoint const& world) const
251  {
252  return WorldToLocalImpl<DestPoint>(world);
253  }
254  template <typename Point>
255  Point WorldToLocal(Point const& world) const
256  {
257  return WorldToLocalImpl<Point>(world);
258  }
260 
272  void WorldToLocalVect(const double* world, double* local) const;
273 
275 
285  template <typename DestVector,
286  typename SrcVector,
288  DestVector WorldToLocalVect(SrcVector const& world) const
289  {
290  return WorldToLocalVectImpl<DestVector>(world);
291  }
292  template <typename Vector>
293  Vector WorldToLocalVect(Vector const& world) const
294  {
295  return WorldToLocalVectImpl<Vector>(world);
296  }
298 
300  TransformationMatrix_t const& Matrix() const { return fGeoMatrix; }
301 
302  protected:
304 
305  template <typename DestPoint, typename SrcPoint>
306  DestPoint LocalToWorldImpl(SrcPoint const& local) const;
307 
308  template <typename DestVector, typename SrcVector>
309  DestVector LocalToWorldVectImpl(SrcVector const& local) const;
310 
311  template <typename DestPoint, typename SrcPoint>
312  DestPoint WorldToLocalImpl(SrcPoint const& world) const;
313 
314  template <typename DestVector, typename SrcVector>
315  DestVector WorldToLocalVectImpl(SrcVector const& world) const;
316 
317  }; // class LocalTransformation<>
318 
320  template <typename Dest, typename Src>
321  decltype(auto) convertTransformationMatrix(Src&& trans)
322  {
323  return details::TransformationMatrixConverter<std::decay_t<Dest>, std::decay_t<Src>>::convert(
324  std::forward<Src>(trans));
325  }
326 
327 } // namespace geo
328 
329 //------------------------------------------------------------------------------
330 // template implementation
331 
332 #include "LocalTransformation.tcc"
333 
334 //------------------------------------------------------------------------------
335 
336 #endif // LARCOREALG_GEOMETRY_LOCALTRANSFORMATION_H
DestPoint WorldToLocal(SrcPoint const &world) const
Transforms a point from world frame to local frame.
decltype(auto) convertTransformationMatrix(Src &&trans)
Converts a transformation matrix into Dest format.
ROOT::Math::Transform3D TransformationMatrix_t
Type of transformation matrix.
TransformationMatrix_t const & Matrix() const
Direct access to the transformation matrix.
STL namespace.
DestVector LocalToWorldVect(SrcVector const &local) const
Transforms a vector from local frame to world frame.
intermediate_table::const_iterator const_iterator
Vector LocalToWorldVect(Vector const &local) const
Transforms a vector from local frame to world frame.
DestVector WorldToLocalVect(SrcVector const &world) const
Transforms a vector from world frame to local frame.
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
Class to transform between world and local coordinates.
TransformationMatrix_t fGeoMatrix
local to world transform
LocalTransformation(TransformationMatrix_t const &matrix)
Constructor: uses the specified local-to-world transformation.
LocalTransformation(ITER begin, ITER end)
Constructor: sequence of transformations from a node path.
LocalTransformation(std::vector< GeoNodePathEntry > const &path)
Constructor: chains the transformations from all specified nodes.
double value
Definition: spectrum.C:18
static StoredMatrix transformationFromPath(ITER begin, ITER end)
Builds a matrix to go from local to world coordinates in one step.
LocalTransformation(std::vector< GeoNodePathEntry > const &path, size_t depth)
Constructor: chains the transformations from the specified nodes.
DestPoint LocalToWorld(SrcPoint const &local) const
Transforms a point from local frame to world frame.
Vector WorldToLocalVect(Vector const &world) const
Transforms a vector from world frame to local frame.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:42
Point LocalToWorld(Point const &local) const
Transforms a point from local frame to world frame.
Point WorldToLocal(Point const &world) const
Transforms a point from world frame to local frame.
std::vector< GeoNodePathEntry >::const_iterator GeoNodeIterator_t
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69
LocalTransformation(TransformationMatrix_t &&matrix)
Constructor: uses the specified local-to-world transformation.
ROOT libraries.