IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 0eb5e670 authored by Ralf Ulrich's avatar Ralf Ulrich
Browse files

Merge branch '44-rename-geometry-basetrajectory-into-something-else-maybe-basetrack' into 'master'

Resolve "Rename geometry::BaseTrajectory into something else, maybe "BaseTrack""

Closes #44

See merge request AirShowerPhysics/corsika!18
parents e60dab45 03c803c6
No related branches found
No related tags found
No related merge requests found
......@@ -12,11 +12,11 @@
#ifndef _include_Cascade_h_
#define _include_Cascade_h_
#include <corsika/geometry/LineTrajectory.h> // to be removed. for dummy trajectory only
#include <corsika/geometry/Point.h> // to be removed. for dummy trajectory only
#include <corsika/process/ProcessReturn.h>
#include <corsika/units/PhysicalUnits.h>
#include <corsika/setup/SetupTrajectory.h>
using namespace corsika::units::si;
namespace corsika::cascade {
......@@ -62,16 +62,17 @@ namespace corsika::cascade {
// DoCascadeEquations(); //
}
}
void Step(Particle& particle) {
[[maybe_unused]] double nextStep = fProcesseList.MinStepLength(particle);
// corsika::utls::ignore(nextStep);
auto const root = corsika::geometry::CoordinateSystem::CreateRootCS();
corsika::geometry::LineTrajectory
corsika::geometry::Trajectory<corsika::geometry::Line>
trajectory( // trajectory is not yet used. this is a dummy.
corsika::geometry::Point(root, {0_m, 0_m, 0_m}),
corsika::geometry::Vector<corsika::units::si::SpeedType::dimension_type>(
root, 0 * 1_m / second, 0 * 1_m / second, 1 * 1_m / second));
corsika::geometry::Line(corsika::geometry::Point(root, {0_m, 0_m, 0_m}),
corsika::geometry::Vector<corsika::units::si::SpeedType::dimension_type>(
root, 0 * 1_m / second, 0 * 1_m / second, 1 * 1_m / second)),
0_s, 1_s);
corsika::process::EProcessReturn status =
fProcesseList.DoContinuous(particle, trajectory, fStack);
if (status == corsika::process::EProcessReturn::eParticleAbsorbed) {
......
......@@ -10,7 +10,6 @@
*/
#include <corsika/cascade/Cascade.h>
#include <corsika/geometry/LineTrajectory.h>
#include <corsika/process/ProcessSequence.h>
#include <corsika/process/stack_inspector/StackInspector.h>
......
......@@ -24,17 +24,37 @@ namespace corsika::geometry {
*/
class BaseTrajectory {
BaseTrajectory() = delete;
public:
BaseTrajectory(corsika::units::si::TimeType start, corsika::units::si::TimeType end)
: fTStart(start)
, fTEnd(end) {}
//!< for \f$ t = 0 \f$, the starting Point shall be returned.
virtual Point GetPosition(corsika::units::si::TimeType) const = 0;
//!< the Point is return from u=0 (start) to u=1 (end)
virtual Point GetPosition(double u) const = 0;
/*!
* returns the arc length between two points of the trajectory
* returns the length between two points of the trajectory
* parameterized by \arg t1 and \arg t2. Requires \arg t2 > \arg t1.
*/
virtual LengthType DistanceBetween(corsika::units::si::TimeType t1,
corsika::units::si::TimeType t2) const = 0;
virtual LengthType GetDistance(corsika::units::si::TimeType t1,
corsika::units::si::TimeType t2) const = 0;
virtual corsika::units::si::TimeType GetDuration(
corsika::units::si::TimeType t1, corsika::units::si::TimeType t2) const {
return t2 - t1;
}
virtual Point GetEndpoint() const { return GetPosition(fTEnd); }
virtual Point GetStartpoint() const { return GetPosition(fTStart); }
protected:
corsika::units::si::TimeType const fTStart, fTEnd;
};
} // namespace corsika::geometry
......
......@@ -8,14 +8,14 @@ set (
GEOMETRY_HEADERS
Vector.h
Point.h
Line.h
Sphere.h
CoordinateSystem.h
Helix.h
BaseVector.h
QuantityVector.h
BaseTrajectory.h
LineTrajectory.h
Trajectory.h
BaseTrajectory.h
)
set (
......
......@@ -12,7 +12,6 @@
#ifndef _include_HELIX_H_
#define _include_HELIX_H_
#include <corsika/geometry/BaseTrajectory.h>
#include <corsika/geometry/Point.h>
#include <corsika/geometry/Vector.h>
#include <corsika/units/PhysicalUnits.h>
......@@ -31,7 +30,8 @@ namespace corsika::geometry {
\f}
*/
class Helix : public BaseTrajectory {
class Helix {
using VelocityVec = Vector<corsika::units::si::SpeedType::dimension_type>;
Point const r0;
......@@ -51,7 +51,7 @@ namespace corsika::geometry {
, uPerp(vPerp.cross(vPar.normalized()))
, radius(pvPar.norm() / abs(pOmegaC)) {}
Point GetPosition(corsika::units::si::TimeType t) const override {
Point GetPosition(corsika::units::si::TimeType t) const {
return r0 + vPar * t +
(vPerp * (cos(omegaC * t) - 1) + uPerp * sin(omegaC * t)) / omegaC;
}
......@@ -59,7 +59,7 @@ namespace corsika::geometry {
auto GetRadius() const { return radius; }
LengthType DistanceBetween(corsika::units::si::TimeType t1,
corsika::units::si::TimeType t2) const override {
corsika::units::si::TimeType t2) const {
return (vPar + vPerp).norm() * (t2 - t1);
}
};
......
......@@ -12,30 +12,30 @@
#ifndef _include_LINETRAJECTORY_H
#define _include_LINETRAJECTORY_H
#include <corsika/geometry/BaseTrajectory.h>
#include <corsika/geometry/Point.h>
#include <corsika/geometry/Vector.h>
#include <corsika/units/PhysicalUnits.h>
namespace corsika::geometry {
class LineTrajectory : public BaseTrajectory {
class Line {
using VelocityVec = Vector<corsika::units::si::SpeedType::dimension_type>;
Point const r0;
VelocityVec const v0;
public:
LineTrajectory(Point const& pR0, VelocityVec const& pV0)
Line(Point const& pR0, VelocityVec const& pV0)
: r0(pR0)
, v0(pV0) {}
Point GetPosition(corsika::units::si::TimeType t) const override {
Point GetPosition(corsika::units::si::TimeType t) const {
return r0 + v0 * t;
}
LengthType DistanceBetween(corsika::units::si::TimeType t1,
corsika::units::si::TimeType t2) const override {
corsika::units::si::TimeType t2) const {
assert(t2 >= t1);
return v0.norm() * (t2 - t1);
}
......
......@@ -17,28 +17,32 @@
namespace corsika::geometry {
class Trajectory {
corsika::units::si::TimeType const fTStart, fTEnd;
BaseTrajectory const& fTrajectory;
template <typename T>
class Trajectory : public BaseTrajectory {
T fTraj;
public:
Trajectory(corsika::units::si::TimeType pTStart, corsika::units::si::TimeType pTEnd,
BaseTrajectory const& pTrajectory)
: fTStart(pTStart)
, fTEnd(pTEnd)
, fTrajectory(pTrajectory) {}
Trajectory(T const& theT, corsika::units::si::TimeType pTStart,
corsika::units::si::TimeType pTEnd)
//: T(theT), fTStart(pTStart), fTEnd(pTEnd) {}
: BaseTrajectory(pTStart, pTEnd)
, fTraj(theT) {}
Point GetPosition(corsika::units::si::TimeType t) const {
return fTrajectory.GetPosition(t + fTStart);
return fTraj.GetPosition(t + fTStart);
}
Point GetPosition(double u) const {
return GetPosition(fTEnd * u + fTStart * (1 - u));
}
LengthType GetDistance(corsika::units::si::TimeType t1,
corsika::units::si::TimeType t2) const {
return fTraj.DistanceBetween(t1, t2);
}
auto GetEndpoint() const { return GetPosition(fTEnd); }
auto GetStartpoint() const { return GetPosition(fTStart); }
};
} // namespace corsika::geometry
......
......@@ -15,7 +15,7 @@
#include <corsika/geometry/CoordinateSystem.h>
#include <corsika/geometry/Helix.h>
#include <corsika/geometry/LineTrajectory.h>
#include <corsika/geometry/Line.h>
#include <corsika/geometry/Point.h>
#include <corsika/geometry/Sphere.h>
#include <corsika/geometry/Trajectory.h>
......@@ -144,17 +144,17 @@ TEST_CASE("Trajectories") {
Vector<SpeedType::dimension_type> v0(rootCS,
{1_m / second, 0_m / second, 0_m / second});
LineTrajectory const lineTrajectory(r0, v0);
CHECK((lineTrajectory.GetPosition(2_s).GetCoordinates() -
Line const line(r0, v0);
CHECK((line.GetPosition(2_s).GetCoordinates() -
QuantityVector<length_d>(2_m, 0_m, 0_m))
.norm()
.magnitude() == Approx(0).margin(absMargin));
BaseTrajectory const* base = &lineTrajectory;
CHECK(lineTrajectory.GetPosition(2_s).GetCoordinates() ==
base->GetPosition(2_s).GetCoordinates());
Trajectory<Line> base(line, 0_s, 1_s);
CHECK(line.GetPosition(2_s).GetCoordinates() ==
base.GetPosition(2_s).GetCoordinates());
CHECK(base->DistanceBetween(1_s, 2_s) / 1_m == Approx(1));
CHECK(base.GetDistance(1_s, 2_s) / 1_m == Approx(1));
}
SECTION("Helix") {
......@@ -178,10 +178,10 @@ TEST_CASE("Trajectories") {
.norm()
.magnitude() == Approx(0).margin(absMargin));
BaseTrajectory const* base = &helix;
Trajectory<Helix> const base(helix, 0_s, 1_s);
CHECK(helix.GetPosition(1234_s).GetCoordinates() ==
base->GetPosition(1234_s).GetCoordinates());
base.GetPosition(1234_s).GetCoordinates());
CHECK(base->DistanceBetween(1_s, 2_s) / 1_m == Approx(5));
CHECK(base.GetDistance(1_s, 2_s) / 1_m == Approx(5));
}
}
......@@ -12,11 +12,12 @@
#ifndef _corsika_setup_setuptrajectory_h_
#define _corsika_setup_setuptrajectory_h_
#include <corsika/geometry/LineTrajectory.h>
#include <corsika/geometry/Line.h>
#include <corsika/geometry/Trajectory.h>
namespace corsika::setup {
typedef corsika::geometry::LineTrajectory Trajectory;
typedef corsika::geometry::Trajectory<corsika::geometry::Line> Trajectory;
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment