CORSIKA  @c8_version@
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::zero(),
40  quantity_type const y = quantity_type::zero(),
41  quantity_type const z = quantity_type::zero())
42  : BaseVector<TDimension>(cs, QuantityVector<TDimension>(x, y, z)) {}
43 
51  QuantityVector<TDimension> const& getComponents() const;
52  QuantityVector<TDimension>& getComponents();
53 
58  QuantityVector<TDimension> getComponents(CoordinateSystemPtr const& pCS) const;
59 
67  QuantityVector<TDimension>& getComponents(CoordinateSystemPtr const& pCS);
68 
80  quantity_type getX(CoordinateSystemPtr const& pCS) const;
81  quantity_type getY(CoordinateSystemPtr const& pCS) const;
82  quantity_type getZ(CoordinateSystemPtr const& pCS) const;
89  void rebase(CoordinateSystemPtr const& pCS);
90 
95  quantity_type getNorm() const;
96 
101  quantity_square_type getSquaredNorm() const;
102 
110  template <typename TDimension2>
111  auto getParallelProjectionOnto(Vector<TDimension2> const& pVec,
112  CoordinateSystemPtr const& pCS) const;
113  template <typename TDimension2>
114  auto getParallelProjectionOnto(Vector<TDimension2> const& pVec) const;
115 
116  Vector operator+(Vector<TDimension> const& pVec) const;
117 
118  Vector operator-(Vector<TDimension> const& pVec) const;
119 
120  auto& operator*=(double const p);
121 
122  template <typename TScalarDim>
123  auto operator*(phys::units::quantity<TScalarDim, double> const p) const;
124  template <typename TScalarDim>
125  auto operator/(phys::units::quantity<TScalarDim, double> const p) const;
126 
127  auto operator*(double const p) const;
128 
129  auto operator/(double const p) const;
130 
131  auto& operator+=(Vector<TDimension> const& pVec);
132 
133  auto& operator-=(Vector<TDimension> const& pVec);
134 
135  auto operator-() const;
136 
137  auto normalized() const;
138 
139  template <typename TDimension2>
140  auto cross(Vector<TDimension2> const& pV) const;
141 
142  template <typename TDimension2>
143  auto dot(Vector<TDimension2> const& pV) const;
144  };
145 
155  template <typename TDimension, typename UDimension>
156  Vector<phys::units::detail::product_d<TDimension, UDimension>> operator*(
157  quantity<UDimension> const n, Vector<TDimension> const& vec);
158 
168  template <typename TDimension>
169  Vector<TDimension> operator*(double const n, Vector<TDimension> const& vec);
170 
171 } // namespace corsika
172 
173 #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
`, since they are used everywhere as integral part of the framework.
static constexpr quantity zero()
We need a "zero" of each type – for comparisons, to initialize running totals, etc.
Definition: quantity.hpp:359
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