18 #ifdef DD4HEP_USE_GEANT4_UNITS
25 #include <TGeoMatrix.h>
32 if ( matrix->IsScale() ) {
33 const Double_t* mat_scale = matrix->GetScale();
34 return ROOT::Math::XYZVector(mat_scale[0],mat_scale[1],mat_scale[2]);
36 return ROOT::Math::XYZVector(1e0,1e0,1e0);
44 if ( matrix->IsTranslation() ) {
45 const Double_t* trans = matrix->GetTranslation();
56 return new TGeoTranslation(
"", pos.X(), pos.Y(), pos.Z());
70 if ( matrix->IsRotation() ) {
71 const Double_t* rot = matrix->GetRotationMatrix();
74 rot[6],rot[7],rot[8]);
97 pos.GetCoordinates(t);
106 Double_t* r = tr.GetRotationMatrix();
107 rot.GetComponents(r);
115 trans.GetDecomposition(rot, pos);
126 return &
_transform(*(
new TGeoHMatrix()), pos);
131 return &
_transform(*(
new TGeoHMatrix()), rot);
136 return &
_transform(*(
new TGeoHMatrix()), rot);
141 return &
_transform(*(
new TGeoHMatrix()), trans);
146 return &
_transform(*(
new TGeoHMatrix()), pos, rot);
151 const Double_t* t = matrix->GetTranslation();
152 if ( matrix->IsRotation() ) {
153 const Double_t* rot = matrix->GetRotationMatrix();
155 rot[3],rot[4],rot[5],t[1]*
MM_2_CM,
156 rot[6],rot[7],rot[8],t[2]*
MM_2_CM);
165 const Double_t* t = matrix.GetTranslation();
166 if ( matrix.IsRotation() ) {
167 const Double_t* r = matrix.GetRotationMatrix();
196 Double_t cosb = std::sqrt(rot[0]*rot[0] + rot[1]*rot[1]);
197 if (cosb > 0.00001) {
198 return XYZAngles(atan2(rot[5], rot[8]), atan2(-rot[2], cosb), atan2(rot[1], rot[0]));
200 return XYZAngles(atan2(-rot[7], rot[4]),atan2(-rot[2], cosb),0);
216 trafo.GetDecomposition(rot, pos);
220 rot.GetComponents(x,y,z);
224 trafo.GetDecomposition(rot, pos);
229 trafo.GetDecomposition(r,pos);
230 rot.SetXYZ(r.Psi(),r.Theta(),r.Phi());
234 trafo.GetDecomposition(rot,pos);
239 trafo.GetDecomposition(r,pos);
240 rot.SetXYZ(r.Psi(),r.Theta(),r.Phi());
250 const double* r = matrix.GetRotationMatrix();
253 r[0]*r[4]*r[8] + r[3]*r[7]*r[2] + r[6]*r[1]*r[5] -
254 r[2]*r[4]*r[6] - r[5]*r[7]*r[0] - r[8]*r[1]*r[3];
264 tr.GetDecomposition(r, p);
271 rot.GetComponents(x,y,z);
272 double det = (x.Cross(y)).Dot(z);
278 static constexpr
double epsilon = 1e-12;
280 const Double_t* t1 = left.GetTranslation();
281 const Double_t* t2 = right.GetTranslation();
282 for(
int i=0; i<3; ++i) {
283 if ( std::fabs(t1[i]-t2[i]) >
epsilon ) {
288 const Double_t* r1 = left.GetRotationMatrix();
289 const Double_t* r2 = right.GetRotationMatrix();
290 for(
int i=0; i<9; ++i) {
291 if ( std::fabs(r1[i]-r2[i]) >
epsilon ) {