CORSIKA8  0.0.0
The framework to simulate particle cascades for astroparticle physics
CoordinateSystem.hpp
Go to the documentation of this file.
1 /*
2  * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
3  *
4  * This software is distributed under the terms of the GNU General Public
5  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6  * the license.
7  */
8 
9 #pragma once
10 
16 #include <corsika/framework/geometry/QuantityVector.hpp>
18 
19 #include <Eigen/Dense>
20 #include <stdexcept>
21 #include <memory>
22 
23 namespace corsika {
24 
25  typedef Eigen::Transform<double, 3, Eigen::Affine> EigenTransform;
26  typedef Eigen::Translation<double, 3> EigenTranslation;
27 
28  template <typename T>
29  class Vector; // fwd decl
30 
31  class CoordinateSystem; // fwd decl
35  using CoordinateSystemPtr = std::shared_ptr<CoordinateSystem const>;
36 
38  static CoordinateSystemPtr& get_root_CoordinateSystem();
39 
44  QuantityVector<length_d> const& vector);
45 
50  template <typename TDim>
52  Vector<TDim> const& vVec);
53 
57  template <typename TDim>
59  QuantityVector<TDim> const& axis, double const angle);
60 
65  template <typename TDim>
67  CoordinateSystemPtr const& cs, QuantityVector<length_d> const& translation,
68  QuantityVector<TDim> const& axis, double const angle);
69 
95 
99  CoordinateSystem(CoordinateSystemPtr const& referenceCS, EigenTransform const& transf)
100  : referenceCS_(referenceCS)
101  , transf_(transf) {}
102 
107  : referenceCS_(nullptr)
108  , transf_(EigenTransform::Identity()) {}
109 
110  public:
111  // default resource allocation
112  CoordinateSystem(CoordinateSystem const&) = default;
113  CoordinateSystem(CoordinateSystem&&) = default;
114  CoordinateSystem& operator=(CoordinateSystem const& pCS) =
115  delete; // avoid making copies
116  ~CoordinateSystem() = default;
117 
121  bool isRoot() const { return !referenceCS_; }
122 
123  CoordinateSystemPtr getReferenceCS() const;
124 
125  EigenTransform const& getTransform() const;
126 
127  bool operator==(CoordinateSystem const&) const;
128  bool operator!=(CoordinateSystem const&) const;
129 
130  protected:
131  static CoordinateSystem createCS() { return CoordinateSystem(); }
132 
140 
142  QuantityVector<length_d> const& vector);
143  template <typename TDim>
145  Vector<TDim> const& vVec);
146  template <typename TDim>
148  QuantityVector<TDim> const& axis,
149  double const angle);
150  template <typename TDim>
152  CoordinateSystemPtr const& cs, QuantityVector<length_d> const& translation,
153  QuantityVector<TDim> const& axis, double const angle);
154 
157  private:
158  CoordinateSystemPtr referenceCS_;
159  EigenTransform transf_;
160  };
161 
173  EigenTransform get_transformation(CoordinateSystem const& c1,
174  CoordinateSystem const& c2);
175 
176 } // namespace corsika
177 
178 #include <corsika/detail/framework/geometry/CoordinateSystem.inl>
Import and extend the phys::units package.
friend CoordinateSystemPtr & get_root_CoordinateSystem()
this is the only way to create ONE unique root CS
CoordinateSystemPtr make_translation(CoordinateSystemPtr const &cs, QuantityVector< length_d > const &vector)
Creates new CoordinateSystemPtr by translation along vector.
friend CoordinateSystemPtr make_rotation(CoordinateSystemPtr const &cs, QuantityVector< TDim > const &axis, double const angle)
creates a new CoordinateSystem, rotated around axis by angle.
friend CoordinateSystemPtr make_translationAndRotation(CoordinateSystemPtr const &cs, QuantityVector< length_d > const &translation, QuantityVector< TDim > const &axis, double const angle)
creates a new CoordinateSystem, translated by translation and rotated around axis by angle...
friend CoordinateSystemPtr make_translation(CoordinateSystemPtr const &cs, QuantityVector< length_d > const &vector)
Creates new CoordinateSystemPtr by translation along vector.
CORSIKA8 logging utilities.
CoordinateSystemPtr make_translationAndRotation(CoordinateSystemPtr const &cs, QuantityVector< length_d > const &translation, QuantityVector< TDim > const &axis, double const angle)
creates a new CoordinateSystem, translated by translation and rotated around axis by angle...
bool isRoot() const
Checks, if this is the unique ROOT CS.
The cascade namespace assembles all objects needed to simulate full particles cascades.
std::shared_ptr< CoordinateSystem const > CoordinateSystemPtr
To refer to CoordinateSystems, only the CoordinateSystemPtr must be used.
A class to store the reference coordinate system for a geometric object.
CoordinateSystemPtr make_rotation(CoordinateSystemPtr const &cs, QuantityVector< TDim > const &axis, double const angle)
creates a new CoordinateSystem, rotated around axis by angle.
friend CoordinateSystemPtr make_rotationToZ(CoordinateSystemPtr const &cs, Vector< TDim > const &vVec)
creates a new CoordinateSystem in which vVec points in direction of the new z-axis, vVec
CoordinateSystemPtr make_rotationToZ(CoordinateSystemPtr const &cs, Vector< TDim > const &vVec)
creates a new CoordinateSystem in which vVec points in direction of the new z-axis, vVec
EigenTransform get_transformation(CoordinateSystem const &c1, CoordinateSystem const &c2)
Transformation matrix from one reference system to another.