All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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)
 
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
 
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
 
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
 
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
 

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 64 of file LocalTransformation.h.

Member Typedef Documentation

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

Type of transformation matrix.

Definition at line 68 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 82 of file LocalTransformation.h.

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

Definition at line 84 of file LocalTransformation.h.

85  : 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 96 of file LocalTransformation.h.

97  : fGeoMatrix
98  (transformationFromPath<StoredMatrix>(path.begin(), path.begin() + depth + 1))
99  {}
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 109 of file LocalTransformation.h.

110  : LocalTransformation(path, path.size()) {}
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 122 of file LocalTransformation.h.

123  : fGeoMatrix(transformationFromPath<StoredMatrix>(begin, end)) {}
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
TransformationMatrix_t fGeoMatrix
local to world transform
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573

Member Function Documentation

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

Definition at line 25 of file GeoVectorLocalTransformation.cxx.

26 {
27  details::checkVectorBufferOverlap(local, world);
28 
29  // need direct transformation
30  auto const local_v
31  = geo::vect::makeFromCoords<typename TransformationMatrix_t::Point>(local);
32  auto const world_v = fGeoMatrix(local_v);
33  geo::vect::fillCoords(world, world_v);
34 
35 } // geo::LocalTransformation::LocalToWorld()
unsigned int fillCoords(Coords &dest, Vector const &src)
Fills a coordinate array with the coordinates of a vector.
then local
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.

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 171 of file LocalTransformation.h.

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

Definition at line 174 of file LocalTransformation.h.

175  { return LocalToWorldImpl<Point>(local); }
then local
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 41 of file GeoVectorLocalTransformation.cxx.

42 {
43  details::checkVectorBufferOverlap(local, world);
44 
45  // need direct transformation
46  auto const local_v
47  = geo::vect::makeFromCoords<typename TransformationMatrix_t::Vector>(local);
48  auto const world_v = fGeoMatrix(local_v);
49  geo::vect::fillCoords(world, world_v);
50 
51 } // geo::LocalTransformation::LocalToWorldVect()
unsigned int fillCoords(Coords &dest, Vector const &src)
Fills a coordinate array with the coordinates of a vector.
then local
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 206 of file LocalTransformation.h.

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

Definition at line 209 of file LocalTransformation.h.

210  { return LocalToWorldVectImpl<Vector>(local); }
then local
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 299 of file LocalTransformation.h.

299 { 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 57 of file GeoVectorLocalTransformation.cxx.

58 {
59  details::checkVectorBufferOverlap(local, world);
60 
61  // need inverse transformation
62  auto const world_v
63  = geo::vect::makeFromCoords<typename TransformationMatrix_t::Point>(world);
64  auto const local_v = fGeoMatrix.ApplyInverse(world_v);
65  geo::vect::fillCoords(local, local_v);
66 
67 } // geo::LocalTransformation::WorldToLocal()
unsigned int fillCoords(Coords &dest, Vector const &src)
Fills a coordinate array with the coordinates of a vector.
then local
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 254 of file LocalTransformation.h.

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

Definition at line 257 of file LocalTransformation.h.

258  { return WorldToLocalImpl<Point>(world); }
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 73 of file GeoVectorLocalTransformation.cxx.

74 {
75  details::checkVectorBufferOverlap(local, world);
76 
77  // need inverse transformation
78  auto const world_v
79  = geo::vect::makeFromCoords<typename TransformationMatrix_t::Vector>(world);
80  auto const local_v = fGeoMatrix.ApplyInverse(world_v);
81  geo::vect::fillCoords(local, local_v);
82 
83 } // geo::LocalTransformation::WorldToLocalVect()
unsigned int fillCoords(Coords &dest, Vector const &src)
Fills a coordinate array with the coordinates of a vector.
then local
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 290 of file LocalTransformation.h.

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

Definition at line 293 of file LocalTransformation.h.

294  { return WorldToLocalVectImpl<Vector>(world); }
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 303 of file LocalTransformation.h.


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