CORSIKA8  0.0.0
The framework to simulate particle cascades for astroparticle physics
Vector.hpp
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 
12 #include <corsika/framework/geometry/BaseVector.hpp>
13 #include <corsika/framework/geometry/QuantityVector.hpp>
14 
15 namespace corsika {
16 
29  template <typename TDimension>
30  class Vector : public BaseVector<TDimension> {
31  public:
32  using quantity_type = phys::units::quantity<TDimension, double>;
33  using quantity_square_type =
34  decltype(std::declval<quantity_type>() * std::declval<quantity_type>());
35 
36  Vector(CoordinateSystemPtr const& pCS, QuantityVector<TDimension> const& pQVector)
37  : BaseVector<TDimension>(pCS, pQVector) {}
38 
39  Vector(CoordinateSystemPtr const& cs, quantity_type const x, quantity_type const y,
40  quantity_type const z)
41  : BaseVector<TDimension>(cs, QuantityVector<TDimension>(x, y, z)) {}
42 
50  QuantityVector<TDimension> const& getComponents() const;
51  QuantityVector<TDimension>& getComponents();
52 
57  QuantityVector<TDimension> getComponents(CoordinateSystemPtr const& pCS) const;
58 
66  QuantityVector<TDimension>& getComponents(CoordinateSystemPtr const& pCS);
67 
79  quantity_type getX(CoordinateSystemPtr const& pCS) const;
80  quantity_type getY(CoordinateSystemPtr const& pCS) const;
81  quantity_type getZ(CoordinateSystemPtr const& pCS) const;
88  void rebase(CoordinateSystemPtr const& pCS);
89 
94  quantity_type getNorm() const;
95 
100  quantity_square_type getSquaredNorm() const;
101 
109  template <typename TDimension2>
110  auto getParallelProjectionOnto(Vector<TDimension2> const& pVec,
111  CoordinateSystemPtr const& pCS) const;
112  template <typename TDimension2>
113  auto getParallelProjectionOnto(Vector<TDimension2> const& pVec) const;
114 
115  Vector operator+(Vector<TDimension> const& pVec) const;
116 
117  Vector operator-(Vector<TDimension> const& pVec) const;
118 
119  auto& operator*=(double const p);
120 
121  template <typename TScalarDim>
122  auto operator*(phys::units::quantity<TScalarDim, double> const p) const;
123  template <typename TScalarDim>
124  auto operator/(phys::units::quantity<TScalarDim, double> const p) const;
125 
126  auto operator*(double const p) const;
127 
128  auto operator/(double const p) const;
129 
130  auto& operator+=(Vector<TDimension> const& pVec);
131 
132  auto& operator-=(Vector<TDimension> const& pVec);
133 
134  auto operator-() const;
135 
136  auto normalized() const;
137 
138  template <typename TDimension2>
139  auto cross(Vector<TDimension2> const& pV) const;
140 
141  template <typename TDimension2>
142  auto dot(Vector<TDimension2> const& pV) const;
143  };
144 
145 } // namespace corsika
146 
147 #include <corsika/detail/framework/geometry/Vector.inl>
void rebase(CoordinateSystemPtr const &pCS)
Import and extend the phys::units package.
class "quantity" is the heart of the library.
Definition: quantity.hpp:54
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.
quantity_type getNorm() const
auto getParallelProjectionOnto(Vector< TDimension2 > const &pVec, CoordinateSystemPtr const &pCS) const
QuantityVector< TDimension > const & getComponents() const
quantity_square_type getSquaredNorm() const