CORSIKA  @c8_version@
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 
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&) = delete;
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:
138 
140  QuantityVector<length_d> const& vector);
141  template <typename TDim>
143  Vector<TDim> const& vVec);
144  template <typename TDim>
146  QuantityVector<TDim> const& axis,
147  double const angle);
148  template <typename TDim>
150  CoordinateSystemPtr const& cs, QuantityVector<length_d> const& translation,
151  QuantityVector<TDim> const& axis, double const angle);
152 
155  private:
156  CoordinateSystemPtr referenceCS_;
157  EigenTransform transf_;
158  };
159 
171  EigenTransform get_transformation(CoordinateSystem const& c1,
172  CoordinateSystem const& c2);
173 
174 } // namespace corsika
175 
176 #include <corsika/detail/framework/geometry/CoordinateSystem.inl>
friend CoordinateSystemPtr const & get_root_CoordinateSystem()
this is the only way to create ONE unique root CS
Import and extend the phys::units package.
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.
CoordinateSystemPtr const & get_root_CoordinateSystem()
this is the only way to create ONE unique root CS
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.
`, since they are used everywhere as integral part of the framework.
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.