diff --git a/Environment/HomogeneousMedium.h b/Environment/HomogeneousMedium.h index 60800a97789abcad1d0c54276d7c70609b82e822..dcb9a464206db8ff83294099b3aaae8fb6812711 100644 --- a/Environment/HomogeneousMedium.h +++ b/Environment/HomogeneousMedium.h @@ -1,11 +1,22 @@ +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * 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. + */ + #ifndef _include_HomogeneousMedium_h_ #define _include_HomogeneousMedium_h_ #include <corsika/environment/NuclearComposition.h> -#include <corsika/geometry/BaseTrajectory.h> -#include <corsika/geometry/Point.h> #include <corsika/particles/ParticleProperties.h> #include <corsika/units/PhysicalUnits.h> +#include <corsika/geometry/Trajectory.h> +#include <corsika/geometry/Line.h> +#include <corsika/geometry/Point.h> /** * a homogeneous medium @@ -31,14 +42,14 @@ namespace corsika::environment { NuclearComposition const& GetNuclearComposition() const override { return fNuclComp; } corsika::units::si::GrammageType IntegratedGrammage( - corsika::geometry::BaseTrajectory const& pTraj, + corsika::geometry::Trajectory<corsika::geometry::Line> const& pTraj, corsika::units::si::TimeType pTo) const override { using namespace corsika::units::si; - return pTraj.DistanceBetween(0_s, pTo) * fDensity; + return pTraj.ArcLength(0_s, pTo) * fDensity; } corsika::units::si::TimeType FromGrammage( - corsika::geometry::BaseTrajectory const& pTraj, + corsika::geometry::Trajectory<corsika::geometry::Line> const& pTraj, corsika::units::si::GrammageType pGrammage) const override { return pTraj.TimeFromArclength(pGrammage / fDensity); } diff --git a/Environment/IMediumModel.h b/Environment/IMediumModel.h index 8b4548ae764b91ad3be4672ca200dad41b17863a..74fc5161f8c397f1d4e1e9144b46eaa817db6495 100644 --- a/Environment/IMediumModel.h +++ b/Environment/IMediumModel.h @@ -1,12 +1,10 @@ #ifndef _include_IMediumModel_h -#define _include_IMediumModels_h +#define _include_IMediumModel_h #include <corsika/environment/NuclearComposition.h> -#include <corsika/geometry/BaseTrajectory.h> +#include <corsika/geometry/Trajectory.h> #include <corsika/geometry/Point.h> #include <corsika/units/PhysicalUnits.h> -#include <tuple> -#include <vector> namespace corsika::environment { @@ -16,11 +14,16 @@ namespace corsika::environment { virtual corsika::units::si::MassDensityType GetMassDensity( corsika::geometry::Point const&) const = 0; + + // todo: think about the mixin inheritance of the trajectory vs the BaseTrajectory approach + // for now, only lines are supported virtual corsika::units::si::GrammageType IntegratedGrammage( - corsika::geometry::BaseTrajectory const&, corsika::units::si::TimeType) const = 0; + corsika::geometry::Trajectory<corsika::geometry::Line> const&, corsika::units::si::TimeType) const = 0; + virtual corsika::units::si::TimeType FromGrammage( - corsika::geometry::BaseTrajectory const&, + corsika::geometry::Trajectory<corsika::geometry::Line> const&, corsika::units::si::GrammageType) const = 0; + virtual NuclearComposition const& GetNuclearComposition() const = 0; }; diff --git a/Environment/VolumeTreeNode.h b/Environment/VolumeTreeNode.h index a1f70554233318d296b89b93afbe0fb46ff69eef..7bf7b87dc26d3897f927f89b45964ef399e7d2f4 100644 --- a/Environment/VolumeTreeNode.h +++ b/Environment/VolumeTreeNode.h @@ -1,3 +1,13 @@ +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * 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. + */ + #ifndef _include_VolumeTreeNode_H #define _include_VolumeTreeNode_H diff --git a/Framework/Geometry/BaseTrajectory.h b/Framework/Geometry/BaseTrajectory.h index 718ed3f7f66e943d808c48d0207bdffcd614962c..feedace208c89eefc0ecd02cd066e0dc5eadf1a4 100644 --- a/Framework/Geometry/BaseTrajectory.h +++ b/Framework/Geometry/BaseTrajectory.h @@ -45,7 +45,7 @@ namespace corsika::geometry { virtual corsika::units::si::TimeType TimeFromArclength( corsika::units::si::LengthType) const = 0; - virtual LengthType GetDistance(corsika::units::si::TimeType t1, + virtual LengthType ArcLength(corsika::units::si::TimeType t1, corsika::units::si::TimeType t2) const = 0; virtual corsika::units::si::TimeType GetDuration( diff --git a/Framework/Geometry/Helix.h b/Framework/Geometry/Helix.h index e93fb51ccf29cf23ef7cff91e15f51726c967cef..0fa07e64277f534a815e7e067c08e88e0901d783 100644 --- a/Framework/Geometry/Helix.h +++ b/Framework/Geometry/Helix.h @@ -58,7 +58,7 @@ namespace corsika::geometry { auto GetRadius() const { return radius; } - corsika::units::si::LengthType DistanceBetween( + corsika::units::si::LengthType ArcLength( corsika::units::si::TimeType t1, corsika::units::si::TimeType t2) const { return (vPar + vPerp).norm() * (t2 - t1); } diff --git a/Framework/Geometry/Line.h b/Framework/Geometry/Line.h index ece78080f55e97e487119a49ac45b57e370611a1..80f6c16bf83e77cc1fb830612ba5b852f1414ab1 100644 --- a/Framework/Geometry/Line.h +++ b/Framework/Geometry/Line.h @@ -32,7 +32,7 @@ namespace corsika::geometry { Point GetPosition(corsika::units::si::TimeType t) const { return r0 + v0 * t; } - LengthType DistanceBetween(corsika::units::si::TimeType t1, + LengthType ArcLength(corsika::units::si::TimeType t1, corsika::units::si::TimeType t2) const { return v0.norm() * (t2 - t1); } diff --git a/Framework/Geometry/Trajectory.h b/Framework/Geometry/Trajectory.h index 686799756504138e349aacfa428b325166ef1e23..f3cabbac7886225846fd8cae1ca7079237812749 100644 --- a/Framework/Geometry/Trajectory.h +++ b/Framework/Geometry/Trajectory.h @@ -13,6 +13,7 @@ #define _include_TRAJECTORY_H #include <corsika/units/PhysicalUnits.h> +#include <corsika/geometry/Point.h> using corsika::units::si::LengthType; using corsika::units::si::TimeType; @@ -25,7 +26,7 @@ namespace corsika::geometry { corsika::units::si::TimeType fTimeLength; public: - using T::GetDistanceBetween; + using T::ArcLength; using T::GetPosition; Trajectory(T const& theT, corsika::units::si::TimeType timeLength) @@ -36,14 +37,14 @@ namespace corsika::geometry { return fTraj.GetPosition(t + fTStart); }*/ - Point GetPosition(const double u) const { return T::GetPosition(fTimeLength * u); } + Point GetPosition(double u) const { return T::GetPosition(fTimeLength * u); } TimeType GetDuration() const { return fTimeLength; } - LengthType GetDistance(const corsika::units::si::TimeType t) const { + LengthType GetDistance(corsika::units::si::TimeType t) const { assert(t > fTimeLength); assert(t >= 0 * corsika::units::si::second); - return T::DistanceBetween(0, t); + return T::ArcLength(0, t); } }; diff --git a/Framework/Geometry/testGeometry.cc b/Framework/Geometry/testGeometry.cc index 9e3be3310bbaf3ed6c9ae22bb6faa67701f20687..63f119fc04f971e3a50fcc14a2faa6e2950fa92a 100644 --- a/Framework/Geometry/testGeometry.cc +++ b/Framework/Geometry/testGeometry.cc @@ -152,11 +152,12 @@ TEST_CASE("Trajectories") { .norm() .magnitude() == Approx(0).margin(absMargin)); - Trajectory<Line> base(line, 1_s); - CHECK(line.GetPosition(2_s).GetCoordinates() == - base.GetPosition(2_s).GetCoordinates()); + auto const t = 1_s; + Trajectory<Line> base(line, t); + CHECK(line.GetPosition(t).GetCoordinates() == + base.GetPosition(1.).GetCoordinates()); - CHECK(base.GetDistanceBetween(1_s, 2_s) / 1_m == Approx(1)); + CHECK(base.ArcLength(1_s, 2_s) / 1_m == Approx(1)); } SECTION("Helix") { @@ -180,10 +181,11 @@ TEST_CASE("Trajectories") { .norm() .magnitude() == Approx(0).margin(absMargin)); - Trajectory<Helix> const base(helix, 1_s); - CHECK(helix.GetPosition(1234_s).GetCoordinates() == - base.GetPosition(1234_s).GetCoordinates()); + auto const t = 1234_s; + Trajectory<Helix> const base(helix, t); + CHECK(helix.GetPosition(t).GetCoordinates() == + base.GetPosition(1.).GetCoordinates()); - CHECK(base.GetDistanceBetween(1_s, 2_s) / 1_m == Approx(5)); + CHECK(base.ArcLength(1_s, 2_s) / 1_m == Approx(5)); } }