CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
StraightTrajectory.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/PhysicalGeometry.hpp>
13 #include <corsika/framework/geometry/BaseTrajectory.hpp>
14 
15 namespace corsika {
16 
28 
29  public:
30  StraightTrajectory() = delete;
31  StraightTrajectory(StraightTrajectory const&) = default;
33  StraightTrajectory& operator=(StraightTrajectory const&) = delete;
34 
42  StraightTrajectory(Line const& theLine, TimeType timeLength)
43  : line_(theLine)
44  , timeLength_(timeLength)
45  , timeStep_(timeLength)
46  , initialVelocity_(theLine.getVelocity(TimeType::zero()))
47  , finalVelocity_(theLine.getVelocity(timeLength)) {}
48 
64  StraightTrajectory(Line const& theLine,
65  TimeType const timeLength, // length of theLine (straight)
66  TimeType const timeStep, // length of bend step (curved)
67  VelocityVector const& initialV, VelocityVector const& finalV)
68  : line_(theLine)
69  , timeLength_(timeLength)
70  , timeStep_(timeStep)
71  , initialVelocity_(initialV)
72  , finalVelocity_(finalV) {}
73 
74  Line const& getLine() const { return line_; }
75 
76  Point getPosition(double const u) const { return line_.getPosition(timeLength_ * u); }
77 
78  VelocityVector getVelocity(double const u) const;
79 
80  DirectionVector getDirection(double const u) const {
81  return getVelocity(u).normalized();
82  }
83 
85  TimeType getDuration(double const u = 1) const;
86 
88  template <typename Particle>
89  TimeType getTime(Particle const& particle, double const u) const;
90 
92  LengthType getLength(double const u = 1) const;
93 
95  void setLength(LengthType const limit);
96 
98  // Scale other properties by "limit/timeLength_"
99  void setDuration(TimeType const limit);
100 
101  protected:
103  LengthType getDistance(double const u) const;
104 
105  void setFinalVelocity(VelocityVector const& v) { finalVelocity_ = v; }
106 
107  private:
108  Line line_;
109  TimeType timeLength_;
110  TimeType timeStep_;
111  VelocityVector initialVelocity_;
112  VelocityVector finalVelocity_;
113  };
114 
115 } // namespace corsika
116 
117 #include <corsika/detail/framework/geometry/StraightTrajectory.inl>
LengthType getDistance(double const u) const
! total length along straight trajectory
Import and extend the phys::units package.
TimeType getTime(Particle const &particle, double const u) const
! time at the start (u=0) or at the end (u=1) of the track of a particle
A Line describes a movement in three dimensional space.
Definition: Line.hpp:27
StraightTrajectory(Line const &theLine, TimeType timeLength)
`, since they are used everywhere as integral part of the framework.
TimeType getDuration(double const u=1) const
! duration along potentially bend trajectory
void setDuration(TimeType const limit)
! set new duration along potentially bend trajectory.
void setLength(LengthType const limit)
! set new duration along potentially bend trajectory.
LengthType getLength(double const u=1) const
! total length along potentially bend trajectory
StraightTrajectory(Line const &theLine, TimeType const timeLength, TimeType const timeStep, VelocityVector const &initialV, VelocityVector const &finalV)
A Trajectory is a description of a momvement of an object in three-dimensional space that describes t...
This implements a straight trajectory between two points.