IAP GITLAB

Helix.hpp 2.16 KB
Newer Older
Ralf Ulrich's avatar
style  
Ralf Ulrich committed
1
/*
Ralf Ulrich's avatar
Ralf Ulrich committed
2
 * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
3 4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * This software is distributed under the terms of the GNU General Public
 * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
 * the license.
 */

#pragma once

#include <cmath>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/geometry/Point.hpp>
#include <corsika/framework/geometry/Vector.hpp>

namespace corsika {
Ralf Ulrich's avatar
Ralf Ulrich committed
17

18
  /*!
Ralf Ulrich's avatar
Ralf Ulrich committed
19
   * Defines a helical path
Ralf Ulrich's avatar
Ralf Ulrich committed
20
   *
21 22 23 24 25 26 27 28 29 30 31 32 33
   * A Helix is defined by the cyclotron frequency \f$ \omega_c \f$, the initial
   * Point r0 and
   * the velocity vectors \f$ \vec{v}_{\parallel} \f$ and \f$ \vec{v}_{\perp} \f$
   * denoting the projections of the initial velocity \f$ \vec{v}_0 \f$ parallel
   * and perpendicular to the axis \f$ \vec{B} \f$, respectively, i.e.
   * \f{align*}{
        \vec{v}_{\parallel} &= \frac{\vec{v}_0 \cdot \vec{B}}{\vec{B}^2} \vec{B} \\
        \vec{v}_{\perp} &= \vec{v}_0 - \vec{v}_{\parallel}
     \f}
   */

  class Helix {

Ralf Ulrich's avatar
Ralf Ulrich committed
34 35
    ///! \todo move VelocityVec into PhysicalUnits
    using VelocityVec = Vector<SpeedType::dimension_type>;
36 37

  public:
Ralf Ulrich's avatar
Ralf Ulrich committed
38
    Helix(Point const& pR0, FrequencyType pOmegaC, VelocityVec const& pvPar,
Ralf Ulrich's avatar
Ralf Ulrich committed
39
          VelocityVec const& pvPerp)
Ralf Ulrich's avatar
Ralf Ulrich committed
40 41 42 43 44
        : r0_(pR0)
        , omegaC_(pOmegaC)
        , vPar_(pvPar)
        , vPerp_(pvPerp)
        , uPerp_(vPerp_.cross(vPar_.normalized()))
45
        , radius_(pvPar.getNorm() / abs(pOmegaC)) {}
46

47
    LengthType getRadius() const;
48

49
    Point getPosition(TimeType const t) const;
50

Ralf Ulrich's avatar
Ralf Ulrich committed
51
    VelocityVec getVelocity(TimeType const t) const;
52

53
    Point getPositionFromArclength(LengthType const l) const;
54

55
    LengthType getArcLength(TimeType const t1, TimeType const t2) const;
56

57
    TimeType getTimeFromArclength(LengthType const l) const;
58

Ralf Ulrich's avatar
Ralf Ulrich committed
59 60 61 62 63
  private:
    Point r0_;             ///! origin of helix, but this is in the center of the
                           ///! "cylinder" on which the helix rotates
    FrequencyType omegaC_; ///! speed of angular rotation
    VelocityVec vPar_;     ///! speed along direction of "cylinder"
64
    VelocityVec vPerp_, uPerp_;
Ralf Ulrich's avatar
Ralf Ulrich committed
65
    LengthType radius_;
66 67 68 69 70
  };

} // namespace corsika

#include <corsika/detail/framework/geometry/Helix.inl>