LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
GeoVectorLocalTransformation.cxx
Go to the documentation of this file.
1 
12 // LArSoft libraries
14 
15 // ROOT libraries
16 #include "TGeoMatrix.h"
17 
18 // C++ standard library
19 #include <stdexcept> // std::runtime_error
20 
21 //------------------------------------------------------------------------------
22 template <>
24  double* world) const
25 {
26  details::checkVectorBufferOverlap(local, world);
27 
28  // need direct transformation
29  auto const local_v = geo::vect::makeFromCoords<typename TransformationMatrix_t::Point>(local);
30  auto const world_v = fGeoMatrix(local_v);
31  geo::vect::fillCoords(world, world_v);
32 
33 } // geo::LocalTransformation::LocalToWorld()
34 
35 //------------------------------------------------------------------------------
36 template <>
38  double* world) const
39 {
40  details::checkVectorBufferOverlap(local, world);
41 
42  // need direct transformation
43  auto const local_v = geo::vect::makeFromCoords<typename TransformationMatrix_t::Vector>(local);
44  auto const world_v = fGeoMatrix(local_v);
45  geo::vect::fillCoords(world, world_v);
46 
47 } // geo::LocalTransformation::LocalToWorldVect()
48 
49 //------------------------------------------------------------------------------
50 template <>
52  double* local) const
53 {
54  details::checkVectorBufferOverlap(local, world);
55 
56  // need inverse transformation
57  auto const world_v = geo::vect::makeFromCoords<typename TransformationMatrix_t::Point>(world);
58  auto const local_v = fGeoMatrix.ApplyInverse(world_v);
59  geo::vect::fillCoords(local, local_v);
60 
61 } // geo::LocalTransformation::WorldToLocal()
62 
63 //------------------------------------------------------------------------------
64 template <>
66  double* local) const
67 {
68  details::checkVectorBufferOverlap(local, world);
69 
70  // need inverse transformation
71  auto const world_v = geo::vect::makeFromCoords<typename TransformationMatrix_t::Vector>(world);
72  auto const local_v = fGeoMatrix.ApplyInverse(world_v);
73  geo::vect::fillCoords(local, local_v);
74 
75 } // geo::LocalTransformation::WorldToLocalVect()
76 
77 //------------------------------------------------------------------------------
78 ROOT::Math::Transform3D
80  TGeoMatrix const& trans)
81 {
82  double const* rot = trans.GetRotationMatrix();
83  double const* transl = trans.GetTranslation();
84  double const* scale = trans.GetScale();
85 
86  for (auto ptr = scale; ptr != scale + 3; ++ptr)
87  if (*ptr != 1.0)
88  throw std::runtime_error("Matrix with scaling can't be converted to Transform3D");
89 
90  return {rot[0],
91  rot[1],
92  rot[2],
93  transl[0],
94  rot[3],
95  rot[4],
96  rot[5],
97  transl[1],
98  rot[6],
99  rot[7],
100  rot[8],
101  transl[2]};
102 
103 } // geo::details::TransformationMatrixConverter<TGeoMatrix, Transform3D>::convert()
104 
105 //------------------------------------------------------------------------------
void LocalToWorld(double const *local, double *world) const
Transforms a point from local frame to world frame.
void LocalToWorldVect(double const *local, double *world) const
Transforms a vector from local frame to world frame.
unsigned int fillCoords(Coords &dest, Vector const &src)
Fills a coordinate array with the coordinates of a vector.
Double_t scale
Definition: plot.C:24
void WorldToLocal(double const *world, double *local) const
Transforms a point from world frame to local frame.
void WorldToLocalVect(const double *world, double *local) const
Transforms a vector from world frame to local frame.
Specialization of local-to-world transformations for ROOT GenVector.