LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geo::LocalTransformation< StoredMatrix > Class Template Reference

Class to transform between world and local coordinates. More...

#include "LocalTransformation.h"

Inheritance diagram for geo::LocalTransformation< StoredMatrix >:
geo::LocalTransformationGeo< StoredMatrix, LocalPoint, LocalVector >

Public Types

using TransformationMatrix_t = StoredMatrix
 Type of transformation matrix. More...
 

Public Member Functions

 LocalTransformation (std::vector< TGeoNode const * > const &path, size_t depth)
 Constructor: chains the transformations from the specified nodes. More...
 
 LocalTransformation (std::vector< TGeoNode const * > const &path)
 Constructor: chains the transformations from all specified nodes. More...
 
template<typename ITER >
 LocalTransformation (ITER begin, ITER end)
 Constructor: sequence of transformations from a node path. More...
 
void LocalToWorld (double const *local, double *world) const
 Transforms a point from local frame to world frame. More...
 
void LocalToWorldVect (double const *local, double *world) const
 Transforms a vector from local frame to world frame. More...
 
void WorldToLocal (double const *world, double *local) const
 Transforms a point from world frame to local frame. More...
 
void WorldToLocalVect (const double *world, double *local) const
 Transforms a vector from world frame to local frame. More...
 
TransformationMatrix_t const & Matrix () const
 Direct access to the transformation matrix. More...
 
template<>
void LocalToWorld (double const *local, double *world) const
 
template<>
void LocalToWorldVect (double const *local, double *world) const
 
template<>
void WorldToLocal (double const *world, double *local) const
 
template<>
void WorldToLocalVect (const double *world, double *local) const
 
template<>
void LocalToWorld (double const *local, double *world) const
 
template<>
void LocalToWorldVect (double const *local, double *world) const
 
template<>
void WorldToLocal (double const *world, double *local) const
 
template<>
void WorldToLocalVect (const double *world, double *local) const
 
 LocalTransformation (TransformationMatrix_t const &matrix)
 Constructor: uses the specified local-to-world transformation. More...
 
 LocalTransformation (TransformationMatrix_t &&matrix)
 Constructor: uses the specified local-to-world transformation. More...
 
template<typename DestPoint , typename SrcPoint , typename = std::enable_if_t<!std::is_same<SrcPoint, DestPoint>::value>>
DestPoint LocalToWorld (SrcPoint const &local) const
 Transforms a point from local frame to world frame. More...
 
template<typename Point >
Point LocalToWorld (Point const &local) const
 Transforms a point from local frame to world frame. More...
 
template<typename DestVector , typename SrcVector , typename = std::enable_if_t<!std::is_same<SrcVector, DestVector>::value>>
DestVector LocalToWorldVect (SrcVector const &local) const
 Transforms a vector from local frame to world frame. More...
 
template<typename Vector >
Vector LocalToWorldVect (Vector const &local) const
 Transforms a vector from local frame to world frame. More...
 
template<typename DestPoint , typename SrcPoint , typename = std::enable_if_t<!std::is_same<SrcPoint, DestPoint>::value>>
DestPoint WorldToLocal (SrcPoint const &world) const
 Transforms a point from world frame to local frame. More...
 
template<typename Point >
Point WorldToLocal (Point const &world) const
 Transforms a point from world frame to local frame. More...
 
template<typename DestVector , typename SrcVector , typename = std::enable_if_t<!std::is_same<SrcVector, DestVector>::value>>
DestVector WorldToLocalVect (SrcVector const &world) const
 Transforms a vector from world frame to local frame. More...
 
template<typename Vector >
Vector WorldToLocalVect (Vector const &world) const
 Transforms a vector from world frame to local frame. More...
 

Protected Member Functions

template<typename DestPoint , typename SrcPoint >
DestPoint LocalToWorldImpl (SrcPoint const &local) const
 
template<typename DestVector , typename SrcVector >
DestVector LocalToWorldVectImpl (SrcVector const &local) const
 
template<typename DestPoint , typename SrcPoint >
DestPoint WorldToLocalImpl (SrcPoint const &world) const
 
template<typename DestVector , typename SrcVector >
DestVector WorldToLocalVectImpl (SrcVector const &world) const
 
template<>
DestPoint WorldToLocalImpl (SrcPoint const &world) const
 
template<>
DestVector WorldToLocalVectImpl (SrcVector const &world) const
 
template<>
DestPoint LocalToWorldImpl (SrcPoint const &local) const
 
template<>
DestVector LocalToWorldVectImpl (SrcVector const &local) const
 

Protected Attributes

TransformationMatrix_t fGeoMatrix
 local to world transform More...
 

Detailed Description

template<typename StoredMatrix>
class geo::LocalTransformation< StoredMatrix >

Class to transform between world and local coordinates.

Template Parameters
StoredMatrixtype of transformation matrix internally stored

This class provides two directions of transformations (world to local and the other way around), for points and for vectors. The vector version of the transformation does not apply translation.

Note
In the class method examples, the following definition is assumed:
using LocalTransformation_t = geo::LocalTransformation<TGeoHMatrix>;

Definition at line 59 of file LocalTransformation.h.

Member Typedef Documentation

template<typename StoredMatrix>
using geo::LocalTransformation< StoredMatrix >::TransformationMatrix_t = StoredMatrix

Type of transformation matrix.

Definition at line 62 of file LocalTransformation.h.

Constructor & Destructor Documentation

template<typename StoredMatrix>
geo::LocalTransformation< StoredMatrix >::LocalTransformation ( TransformationMatrix_t const &  matrix)
inline

Constructor: uses the specified local-to-world transformation.

Parameters
matrixthe transformation matrix to be used

The transformation matrix is used to transform vectors from the "local" to the "world" frame, while its inverse is used for transformations from the "world" to the "local" frame.

The specified matrix is copied into a local copy unless a R-value reference argument is specified (e.g. with std::move()).

Definition at line 76 of file LocalTransformation.h.

76 : fGeoMatrix(matrix) {}
TransformationMatrix_t fGeoMatrix
local to world transform
template<typename StoredMatrix>
geo::LocalTransformation< StoredMatrix >::LocalTransformation ( TransformationMatrix_t &&  matrix)
inline

Constructor: uses the specified local-to-world transformation.

Parameters
matrixthe transformation matrix to be used

The transformation matrix is used to transform vectors from the "local" to the "world" frame, while its inverse is used for transformations from the "world" to the "local" frame.

The specified matrix is copied into a local copy unless a R-value reference argument is specified (e.g. with std::move()).

Definition at line 77 of file LocalTransformation.h.

77 : fGeoMatrix(std::move(matrix)) {}
TransformationMatrix_t fGeoMatrix
local to world transform
template<typename StoredMatrix>
geo::LocalTransformation< StoredMatrix >::LocalTransformation ( std::vector< TGeoNode const * > const &  path,
size_t  depth 
)
inline

Constructor: chains the transformations from the specified nodes.

Parameters
paththe path of ROOT geometry nodes
depththe index in the path of the last node to be considered

The resulting transformation is the sequence of transformations from depth nodes from the first on.

Definition at line 88 of file LocalTransformation.h.

89  : fGeoMatrix(transformationFromPath<StoredMatrix>(path.begin(), path.begin() + depth + 1))
90  {}
TransformationMatrix_t fGeoMatrix
local to world transform
template<typename StoredMatrix>
geo::LocalTransformation< StoredMatrix >::LocalTransformation ( std::vector< TGeoNode const * > const &  path)
inline

Constructor: chains the transformations from all specified nodes.

Parameters
paththe path of ROOT geometry nodes

The resulting transformation is the sequence of transformations from the first to the last node of the path.

Definition at line 99 of file LocalTransformation.h.

100  : LocalTransformation(path, path.size())
101  {}
LocalTransformation(TransformationMatrix_t const &matrix)
Constructor: uses the specified local-to-world transformation.
template<typename StoredMatrix>
template<typename ITER >
geo::LocalTransformation< StoredMatrix >::LocalTransformation ( ITER  begin,
ITER  end 
)
inline

Constructor: sequence of transformations from a node path.

Template Parameters
ITERtype of iterator to node pointers
Parameters
beginthe begin iterator of the path of ROOT geometry nodes
endthe end iterator of the path of ROOT geometry nodes

The resulting transformation is the sequence of transformations from the one pointed by begin to the one before end.

Definition at line 113 of file LocalTransformation.h.

114  : fGeoMatrix(transformationFromPath<StoredMatrix>(begin, end))
115  {}
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
TransformationMatrix_t fGeoMatrix
local to world transform
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:69

Member Function Documentation

template<>
void geo::LocalTransformation< ROOT::Math::Transform3D >::LocalToWorld ( double const *  local,
double *  world 
) const

Definition at line 23 of file GeoVectorLocalTransformation.cxx.

References geo::vect::fillCoords().

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()
unsigned int fillCoords(Coords &dest, Vector const &src)
Fills a coordinate array with the coordinates of a vector.
TransformationMatrix_t fGeoMatrix
local to world transform
template<>
void geo::LocalTransformation< ROOT::Math::Transform3D >::LocalToWorld ( double const *  local,
double *  world 
) const
template<typename StoredMatrix>
void geo::LocalTransformation< StoredMatrix >::LocalToWorld ( double const *  local,
double *  world 
) const

Transforms a point from local frame to world frame.

Parameters
locallocal coordinates: [0] x, [1] y, [2] z [cm]
world(output) corresponding world coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
std::array<double, 3U> origin, center;
origin.fill(0.);
trans.LocalToWorld(origin.data(), center.data());

center will contain the world coordinates of the center of the volume, which is usually represented by the origin in the local coordinates.

In-place replacement is not supported: world and local buffers are assumed not to, and must not, overlap.

Referenced by geo::GeometryCore::DetectorEnclosureBox().

template<typename StoredMatrix>
template<typename DestPoint , typename SrcPoint , typename = std::enable_if_t<!std::is_same<SrcPoint, DestPoint>::value>>
DestPoint geo::LocalTransformation< StoredMatrix >::LocalToWorld ( SrcPoint const &  local) const
inline

Transforms a point from local frame to world frame.

Template Parameters
SrcPointtype of the input (local) vector
DestPointtype of the output (world) vector (default: as Point)
Parameters
locallocal coordinates [cm]
Returns
corresponding world coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
auto center = trans.LocalToWorld(TVector3());

center will be a TVector3 containing the world coordinates of the center of the volume, which is usually represented by the origin in the local coordinates (a TVector3 is by default constructed to point to the origin).

Definition at line 160 of file LocalTransformation.h.

161  {
162  return LocalToWorldImpl<DestPoint>(local);
163  }
template<typename StoredMatrix>
template<typename Point >
Point geo::LocalTransformation< StoredMatrix >::LocalToWorld ( Point const &  local) const
inline

Transforms a point from local frame to world frame.

Template Parameters
SrcPointtype of the input (local) vector
DestPointtype of the output (world) vector (default: as Point)
Parameters
locallocal coordinates [cm]
Returns
corresponding world coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
auto center = trans.LocalToWorld(TVector3());

center will be a TVector3 containing the world coordinates of the center of the volume, which is usually represented by the origin in the local coordinates (a TVector3 is by default constructed to point to the origin).

Definition at line 165 of file LocalTransformation.h.

166  {
167  return LocalToWorldImpl<Point>(local);
168  }
template<>
DestPoint geo::LocalTransformation< ROOT::Math::Transform3D >::LocalToWorldImpl ( SrcPoint const &  local) const
protected
template<typename StoredMatrix>
template<typename DestPoint , typename SrcPoint >
DestPoint geo::LocalTransformation< StoredMatrix >::LocalToWorldImpl ( SrcPoint const &  local) const
protected
template<>
void geo::LocalTransformation< ROOT::Math::Transform3D >::LocalToWorldVect ( double const *  local,
double *  world 
) const

Definition at line 37 of file GeoVectorLocalTransformation.cxx.

References geo::vect::fillCoords().

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()
unsigned int fillCoords(Coords &dest, Vector const &src)
Fills a coordinate array with the coordinates of a vector.
TransformationMatrix_t fGeoMatrix
local to world transform
template<>
void geo::LocalTransformation< ROOT::Math::Transform3D >::LocalToWorldVect ( double const *  local,
double *  world 
) const
template<typename StoredMatrix>
void geo::LocalTransformation< StoredMatrix >::LocalToWorldVect ( double const *  local,
double *  world 
) const

Transforms a vector from local frame to world frame.

Parameters
locallocal coordinates: [0] x, [1] y, [2] z [cm]
world(output) corresponding world coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

In-place replacement is not supported: world and local buffers are assumed not to, and must not, overlap.

template<typename StoredMatrix>
template<typename DestVector , typename SrcVector , typename = std::enable_if_t<!std::is_same<SrcVector, DestVector>::value>>
DestVector geo::LocalTransformation< StoredMatrix >::LocalToWorldVect ( SrcVector const &  local) const
inline

Transforms a vector from local frame to world frame.

Template Parameters
SrcVectortype of the input (local) vector
DestVectortype of output (world) vector (default: as Vector)
Parameters
locallocal coordinates [cm]
Returns
corresponding world coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

Definition at line 198 of file LocalTransformation.h.

199  {
200  return LocalToWorldVectImpl<DestVector>(local);
201  }
template<typename StoredMatrix>
template<typename Vector >
Vector geo::LocalTransformation< StoredMatrix >::LocalToWorldVect ( Vector const &  local) const
inline

Transforms a vector from local frame to world frame.

Template Parameters
SrcVectortype of the input (local) vector
DestVectortype of output (world) vector (default: as Vector)
Parameters
locallocal coordinates [cm]
Returns
corresponding world coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

Definition at line 203 of file LocalTransformation.h.

204  {
205  return LocalToWorldVectImpl<Vector>(local);
206  }
template<>
DestVector geo::LocalTransformation< ROOT::Math::Transform3D >::LocalToWorldVectImpl ( SrcVector const &  local) const
protected
template<typename StoredMatrix>
template<typename DestVector , typename SrcVector >
DestVector geo::LocalTransformation< StoredMatrix >::LocalToWorldVectImpl ( SrcVector const &  local) const
protected
template<typename StoredMatrix>
TransformationMatrix_t const& geo::LocalTransformation< StoredMatrix >::Matrix ( ) const
inline

Direct access to the transformation matrix.

Definition at line 298 of file LocalTransformation.h.

Referenced by geo::AuxDetGeo::AuxDetGeo(), and geo::TPCGeo::TPCGeo().

298 { return fGeoMatrix; }
TransformationMatrix_t fGeoMatrix
local to world transform
template<>
void geo::LocalTransformation< ROOT::Math::Transform3D >::WorldToLocal ( double const *  world,
double *  local 
) const
template<>
void geo::LocalTransformation< ROOT::Math::Transform3D >::WorldToLocal ( double const *  world,
double *  local 
) const

Definition at line 51 of file GeoVectorLocalTransformation.cxx.

References geo::vect::fillCoords().

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()
unsigned int fillCoords(Coords &dest, Vector const &src)
Fills a coordinate array with the coordinates of a vector.
TransformationMatrix_t fGeoMatrix
local to world transform
template<typename StoredMatrix>
void geo::LocalTransformation< StoredMatrix >::WorldToLocal ( double const *  world,
double *  local 
) const

Transforms a point from world frame to local frame.

Parameters
worldworld coordinates: [0] x, [1] y, [2] z [cm]
local(output) corresponding local coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
std::array<double, 3U> world{ 4.0, 5.0, -2.5 }, local;
trans.WorldToLocal(world.data(), local.data());

local will contain the local coordinates of the specified point.

In-place replacement is not supported: world and local buffers are assumed not to, and must not, overlap.

template<typename StoredMatrix>
template<typename DestPoint , typename SrcPoint , typename = std::enable_if_t<!std::is_same<SrcPoint, DestPoint>::value>>
DestPoint geo::LocalTransformation< StoredMatrix >::WorldToLocal ( SrcPoint const &  world) const
inline

Transforms a point from world frame to local frame.

Template Parameters
SrcPointtype of the input (local) vector
DestPointtype of the output (world) vector (default: as Point)
Parameters
worldworld coordinates [cm]
Returns
corresponding local coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
auto local = trans.WorldToLocal(TVector3(4.0, 5.0, -2.5));

local will be a TVector3 containing the local coordinates of the specified point.

Definition at line 248 of file LocalTransformation.h.

249  {
250  return WorldToLocalImpl<DestPoint>(world);
251  }
template<typename StoredMatrix>
template<typename Point >
Point geo::LocalTransformation< StoredMatrix >::WorldToLocal ( Point const &  world) const
inline

Transforms a point from world frame to local frame.

Template Parameters
SrcPointtype of the input (local) vector
DestPointtype of the output (world) vector (default: as Point)
Parameters
worldworld coordinates [cm]
Returns
corresponding local coordinates [cm]

The full transformation is applied. Fox example:

LocalTransformation_t trans( ... ); // with proper initialisation
auto local = trans.WorldToLocal(TVector3(4.0, 5.0, -2.5));

local will be a TVector3 containing the local coordinates of the specified point.

Definition at line 253 of file LocalTransformation.h.

254  {
255  return WorldToLocalImpl<Point>(world);
256  }
template<>
DestPoint geo::LocalTransformation< ROOT::Math::Transform3D >::WorldToLocalImpl ( SrcPoint const &  world) const
protected
template<typename StoredMatrix>
template<typename DestPoint , typename SrcPoint >
DestPoint geo::LocalTransformation< StoredMatrix >::WorldToLocalImpl ( SrcPoint const &  world) const
protected
template<>
void geo::LocalTransformation< ROOT::Math::Transform3D >::WorldToLocalVect ( const double *  world,
double *  local 
) const
template<>
void geo::LocalTransformation< ROOT::Math::Transform3D >::WorldToLocalVect ( const double *  world,
double *  local 
) const

Definition at line 65 of file GeoVectorLocalTransformation.cxx.

References geo::vect::fillCoords(), and scale.

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()
unsigned int fillCoords(Coords &dest, Vector const &src)
Fills a coordinate array with the coordinates of a vector.
TransformationMatrix_t fGeoMatrix
local to world transform
template<typename StoredMatrix>
void geo::LocalTransformation< StoredMatrix >::WorldToLocalVect ( const double *  world,
double *  local 
) const

Transforms a vector from world frame to local frame.

Parameters
worldworld coordinates: [0] x, [1] y, [2] z [cm]
local(output) corresponding local coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

In-place replacement is not supported: world and local buffers are assumed not to, and must not, overlap.

template<typename StoredMatrix>
template<typename DestVector , typename SrcVector , typename = std::enable_if_t<!std::is_same<SrcVector, DestVector>::value>>
DestVector geo::LocalTransformation< StoredMatrix >::WorldToLocalVect ( SrcVector const &  world) const
inline

Transforms a vector from world frame to local frame.

Template Parameters
SrcVectortype of the input (local) vector
DestVectortype of output (world) vector (default: as Vector)
Parameters
worldcoordinates [cm]
Returns
corresponding world coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

Definition at line 286 of file LocalTransformation.h.

287  {
288  return WorldToLocalVectImpl<DestVector>(world);
289  }
template<typename StoredMatrix>
template<typename Vector >
Vector geo::LocalTransformation< StoredMatrix >::WorldToLocalVect ( Vector const &  world) const
inline

Transforms a vector from world frame to local frame.

Template Parameters
SrcVectortype of the input (local) vector
DestVectortype of output (world) vector (default: as Vector)
Parameters
worldcoordinates [cm]
Returns
corresponding world coordinates [cm]

The translation is not applied, since the argument is supposed to be a vector, relative difference between two points.

Definition at line 291 of file LocalTransformation.h.

292  {
293  return WorldToLocalVectImpl<Vector>(world);
294  }
template<>
DestVector geo::LocalTransformation< ROOT::Math::Transform3D >::WorldToLocalVectImpl ( SrcVector const &  world) const
protected
template<typename StoredMatrix>
template<typename DestVector , typename SrcVector >
DestVector geo::LocalTransformation< StoredMatrix >::WorldToLocalVectImpl ( SrcVector const &  world) const
protected

Member Data Documentation

template<typename StoredMatrix>
TransformationMatrix_t geo::LocalTransformation< StoredMatrix >::fGeoMatrix
protected

local to world transform

Definition at line 301 of file LocalTransformation.h.


The documentation for this class was generated from the following file: