File indexing completed on 2025-01-30 10:09:32
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include <G4AffineTransform.hh>
0011 #include <G4RotationMatrix.hh>
0012 #include <G4ThreeVector.hh>
0013 #include <VecGeom/base/Transformation3D.h>
0014
0015 #include "Scaler.hh"
0016
0017 namespace celeritas
0018 {
0019 namespace g4vg
0020 {
0021
0022
0023
0024
0025 class Transformer
0026 {
0027 public:
0028
0029
0030 using result_type = vecgeom::Transformation3D;
0031
0032
0033 public:
0034
0035 inline explicit Transformer(Scaler const& convert_scale_);
0036
0037
0038 inline result_type operator()(G4ThreeVector const& t) const;
0039
0040
0041 inline result_type
0042 operator()(G4ThreeVector const& t, G4RotationMatrix const& rot) const;
0043
0044
0045 inline result_type
0046 operator()(G4ThreeVector const& t, G4RotationMatrix const* rot) const;
0047
0048
0049 inline result_type operator()(G4AffineTransform const& at) const;
0050
0051 private:
0052
0053
0054 Scaler const& convert_scale_;
0055 };
0056
0057
0058
0059
0060
0061
0062
0063 Transformer::Transformer(Scaler const& convert_scale)
0064 : convert_scale_{convert_scale}
0065 {
0066 }
0067
0068
0069
0070
0071
0072 auto Transformer::operator()(G4ThreeVector const& t) const -> result_type
0073 {
0074 return {convert_scale_(t[0]), convert_scale_(t[1]), convert_scale_(t[2])};
0075 }
0076
0077
0078
0079
0080
0081 auto Transformer::operator()(G4ThreeVector const& t,
0082 G4RotationMatrix const& rot) const -> result_type
0083 {
0084 return {convert_scale_(t[0]),
0085 convert_scale_(t[1]),
0086 convert_scale_(t[2]),
0087 rot.xx(),
0088 rot.yx(),
0089 rot.zx(),
0090 rot.xy(),
0091 rot.yy(),
0092 rot.zy(),
0093 rot.xz(),
0094 rot.yz(),
0095 rot.zz()};
0096 }
0097
0098
0099
0100
0101
0102 auto Transformer::operator()(G4ThreeVector const& t,
0103 G4RotationMatrix const* rot) const -> result_type
0104 {
0105 if (rot)
0106 {
0107 return (*this)(t, *rot);
0108 }
0109 else
0110 {
0111 return (*this)(t);
0112 }
0113 }
0114
0115
0116
0117
0118
0119 auto Transformer::operator()(G4AffineTransform const& affine) const -> result_type
0120 {
0121 return (*this)(affine.NetTranslation(), affine.NetRotation());
0122 }
0123
0124
0125 }
0126 }