ATLAS Offline Software
Loading...
Searching...
No Matches
CLHEPtoEigenConverter.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
19
20#ifndef GEOPRIMITIVES_CLHEPTOEIGENCONVERTER_H_
21#define GEOPRIMITIVES_CLHEPTOEIGENCONVERTER_H_
22
25
26#include "CLHEP/Geometry/Transform3D.h"
27#include "CLHEP/Geometry/Point3D.h"
28#include "CLHEP/Vector/Rotation.h"
29#include "CLHEP/Vector/ThreeVector.h"
30
31namespace Amg {
32
40 const HepGeom::Transform3D& CLHEPtransf) {
41 Amg::Isometry3D t{Amg::Isometry3D::Identity()};
42 auto rotation{t.linear()};
43 auto translation{t.translation()};
44 //loop unrolled for performance
45 rotation(0, 0) = CLHEPtransf(0, 0);
46 rotation(0, 1) = CLHEPtransf(0, 1);
47 rotation(0, 2) = CLHEPtransf(0, 2);
48 rotation(1, 0) = CLHEPtransf(1, 0);
49 rotation(1, 1) = CLHEPtransf(1, 1);
50 rotation(1, 2) = CLHEPtransf(1, 2);
51 rotation(2, 0) = CLHEPtransf(2, 0);
52 rotation(2, 1) = CLHEPtransf(2, 1);
53 rotation(2, 2) = CLHEPtransf(2, 2);
54 translation[0] = CLHEPtransf(0, 3);
55 translation[1] = CLHEPtransf(1, 3);
56 translation[2] = CLHEPtransf(2, 3);
57 assert( (t.linear() * t.linear().transpose() -
58 Amg::RotationMatrix3D::Identity()).cwiseAbs().maxCoeff() < 1.e-9);
59 return t;
60 }
61
69 const CLHEP::HepRotation& CLHEProtation) {
71
72 t(0, 0) = CLHEProtation(0, 0);
73 t(0, 1) = CLHEProtation(0, 1);
74 t(0, 2) = CLHEProtation(0, 2);
75 t(1, 0) = CLHEProtation(1, 0);
76 t(1, 1) = CLHEProtation(1, 1);
77 t(1, 2) = CLHEProtation(1, 2);
78 t(2, 0) = CLHEProtation(2, 0);
79 t(2, 1) = CLHEProtation(2, 1);
80 t(2, 2) = CLHEProtation(2, 2);
81 return t;
82 }
83
91 const HepGeom::Translate3D& CLHEPtranslate3D) {
92 return getTranslate3D(CLHEPtranslate3D(0, 3),
93 CLHEPtranslate3D(1, 3),
94 CLHEPtranslate3D(2, 3));
95 }
96
103 inline HepGeom::Transform3D EigenTransformToCLHEP(
104 const Amg::Transform3D& eigenTransf) {
105 CLHEP::HepRotation rotation(
106 CLHEP::Hep3Vector(eigenTransf(0, 0), eigenTransf(1, 0), eigenTransf(2, 0)),
107 CLHEP::Hep3Vector(eigenTransf(0, 1), eigenTransf(1, 1), eigenTransf(2, 1)),
108 CLHEP::Hep3Vector(eigenTransf(0, 2), eigenTransf(1, 2), eigenTransf(2, 2)));
109 CLHEP::Hep3Vector translation(eigenTransf(0, 3), eigenTransf(1, 3), eigenTransf(2, 3));
110 HepGeom::Transform3D t(rotation, translation);
111 return t;
112 }
113
120 inline Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector& CLHEPvector) {
121 return Amg::Vector3D{CLHEPvector[0], CLHEPvector[1], CLHEPvector[2]};
122 }
123
130 inline CLHEP::Hep3Vector EigenToHep3Vector(const Amg::Vector3D& eigenvector) {
131 return CLHEP::Hep3Vector{eigenvector[0], eigenvector[1], eigenvector[2]};
132 }
133}
134
135#endif
Definition of ATLAS Math & Geometry primitives (Amg).
Amg::Isometry3D CLHEPTransformToEigen(const HepGeom::Transform3D &CLHEPtransf)
Converts a CLHEP-based HepGeom::Transform3D into an Eigen Amg::Transform3D.
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Eigen::Isometry3d Isometry3D
Amg::Isometry3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis
Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector &CLHEPvector)
Converts a CLHEP-based CLHEP::Hep3Vector into an Eigen-based Amg::Vector3D.
RotationMatrix3D CLHEPRotationToEigen(const CLHEP::HepRotation &CLHEProtation)
Converts a CLHEP::HepRotation into an Eigen-based Amg::RotationMatrix3D.
Eigen::Affine3d Transform3D
CLHEP::Hep3Vector EigenToHep3Vector(const Amg::Vector3D &eigenvector)
Converts an Eigen-based Amg::Vector3D into a CLHEP-based CLHEP::Hep3Vector.
Amg::Isometry3D CLHEPTranslate3DToEigen(const HepGeom::Translate3D &CLHEPtranslate3D)
Converts a CLHEP-based HepGeom::Translate3 into an Eigen-based Amg::Transform3D.
Eigen::Matrix< double, 3, 1 > Vector3D