GeoModel - GeoModelCore
GeoDefinitions.h
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef GEOMODELKERNEL_GEODEFINITIONS_H
6 #define GEOMODELKERNEL_GEODEFINITIONS_H
7 
8 // for GNU: ignore this specific warning, otherwise just include Eigen/Dense
9 #if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
10 #pragma GCC diagnostic push
11 #pragma GCC diagnostic ignored "-Wmisleading-indentation"
12 #include <Eigen/Dense>
13 #pragma GCC diagnostic pop
14 #else
15 #include <Eigen/Dense>
16 #endif
17 
18 namespace GeoTrf {
19  typedef Eigen::Quaternion<double> Rotation3D;
20  typedef Eigen::Translation<double, 3> Translation3D;
21  typedef Eigen::AngleAxisd AngleAxis3D;
22  typedef Eigen::Affine3d Transform3D;
23  typedef Eigen::Matrix<double, 3, 1> Vector3D;
24  typedef Eigen::Matrix<double, 2, 1> Vector2D;
25  typedef Eigen::Matrix<double, 3, 3> RotationMatrix3D;
26 
28  struct Plane3D {
29  protected:
30  double a_, b_, c_, d_;
31 
32  public:
36  : a_(0.), b_(0.), c_(1.), d_(0.)
37  {}
38 
41  Plane3D(double a1, double b1, double c1, double d1)
42  : a_(a1), b_(b1), c_(c1), d_(d1)
43  {}
44 
47  Plane3D(const Vector3D& n, const Vector3D& p)
48  : a_(n.x()), b_(n.y()), c_(n.z()), d_(-n.dot(p))
49  {}
50 
53  double a() const { return a_; }
56  double b() const { return b_; }
59  double c() const { return c_; }
62  double d() const { return d_; }
63 
66  Vector3D normal() const { return Vector3D(a_,b_,c_); }
67  };
68 
69  class Translate3D : public Transform3D {
70  public:
71  Translate3D(double x, double y, double z)
72  : Transform3D(Translation3D(x,y,z))
73  {}
74  virtual ~Translate3D() {}
75  };
76 
77  class TranslateX3D : public Transform3D {
78  public:
79  TranslateX3D(double x)
80  : Transform3D(Translation3D(x,0,0))
81  {}
82  virtual ~TranslateX3D() {}
83  };
84 
85  class TranslateY3D : public Transform3D {
86  public:
87  TranslateY3D(double y)
88  : Transform3D(Translation3D(0,y,0))
89  {}
90  virtual ~TranslateY3D() {}
91  };
92 
93  class TranslateZ3D : public Transform3D {
94  public:
95  TranslateZ3D(double z)
96  : Transform3D(Translation3D(0,0,z))
97  {}
98  virtual ~TranslateZ3D() {}
99  };
100 
101  class Rotate3D : public Transform3D {
102  public:
103  Rotate3D(double angle, const Vector3D& axis)
104  : Transform3D(AngleAxis3D(angle,axis))
105  {}
106  virtual ~Rotate3D() {}
107  };
108 
109  class RotateX3D : public Transform3D {
110  public:
111  RotateX3D(double angle)
112  : Transform3D(AngleAxis3D(angle,Vector3D::UnitX()))
113  {}
114  virtual ~RotateX3D() {}
115  };
116 
117  class RotateY3D : public Transform3D {
118  public:
119  RotateY3D(double angle)
120  : Transform3D(AngleAxis3D(angle,Vector3D::UnitY()))
121  {}
122  virtual ~RotateY3D() {}
123  };
124 
125  class RotateZ3D : public Transform3D {
126  public:
127  RotateZ3D(double angle)
128  : Transform3D(AngleAxis3D(angle,Vector3D::UnitZ()))
129  {}
130  virtual ~RotateZ3D() {}
131  };
132 
133  class GeoRotation : public RotationMatrix3D {
134  public:
135  GeoRotation(double phi, double theta, double psi);
136  virtual ~GeoRotation() {}
137  };
138 
139  class GeoTransformRT : public Transform3D {
140  public:
141  GeoTransformRT(const GeoRotation& rot, const Vector3D& trans)
142  : Transform3D(Translation3D(trans)*Transform3D(AngleAxis3D(rot)))
143  {}
144  virtual ~GeoTransformRT() {}
145  };
146 }
147 
148 #endif // GEOMODELKERNEL_GEODEFINITIONS_H
Plane3D(const Vector3D &n, const Vector3D &p)
Plane3D(double a1, double b1, double c1, double d1)
double c() const
Vector3D normal() const
double d() const
double a() const
double b() const
check if we can use Eigen Hyperplane for this