IAP GITLAB

Skip to content
Snippets Groups Projects
Commit d75101db authored by Nikos Karastathis's avatar Nikos Karastathis :ocean: Committed by Maximilian Reininghaus
Browse files

clang-format on

(cherry picked from commit 64e63aa0)
parent c1b7e8ce
No related branches found
No related tags found
No related merge requests found
......@@ -13,26 +13,22 @@
namespace corsika {
Path::Path(Point const& point) {
points_.push_front(point);
}
Path::Path(Point const& point) { points_.push_front(point); }
Path::Path(std::deque<Point> const& points)
: points_(points) {
int dequesize_ = points.size();
if (dequesize_ == 0 || dequesize_ == 1) {
length_ = LengthType::zero();
}
else if (dequesize_ == 2) {
length_ = (points.back() - points.front()).getNorm();
}
else {
for (auto point = points.begin(); point != points.end() - 1; ++point) {
auto point_next = *(point+1);
auto point_now = *(point);
length_ += (point_next - point_now).getNorm();
}
: points_(points) {
int dequesize_ = points.size();
if (dequesize_ == 0 || dequesize_ == 1) {
length_ = LengthType::zero();
} else if (dequesize_ == 2) {
length_ = (points.back() - points.front()).getNorm();
} else {
for (auto point = points.begin(); point != points.end() - 1; ++point) {
auto point_next = *(point + 1);
auto point_now = *(point);
length_ += (point_next - point_now).getNorm();
}
}
}
inline void Path::AddToEnd(Point const& point) {
......@@ -46,28 +42,20 @@ namespace corsika {
int dequesize_ = points_.size();
if (dequesize_ == 0 || dequesize_ == 1) {
length_ = LengthType::zero();
}
else if (dequesize_ == 2) {
} else if (dequesize_ == 2) {
length_ = (points_.back() - points_.front()).getNorm();
} else {
length_ -= (lastpoint_ - points_.back()).getNorm();
}
else { length_ -= (lastpoint_ - points_.back()).getNorm(); }
}
inline LengthType Path::GetLength() const {
return length_;
}
inline LengthType Path::GetLength() const { return length_; }
inline Point Path::GetStart() const {
return points_.front();
}
inline Point Path::GetStart() const { return points_.front(); }
inline Point Path::GetEnd() const {
return points_.back();
}
inline Point Path::GetEnd() const { return points_.back(); }
inline Point Path::GetPoint(std::size_t const index) const {
return points_.at(index);
}
inline Point Path::GetPoint(std::size_t const index) const { return points_.at(index); }
inline auto Path::begin() { return points_.begin(); }
......
......@@ -15,17 +15,17 @@ namespace corsika {
template <typename T>
template <typename... Args>
ExponentialRefractiveIndex<T>::ExponentialRefractiveIndex(double const n0,
InverseLengthType const lambda, Args&&... args)
ExponentialRefractiveIndex<T>::ExponentialRefractiveIndex(
double const n0, InverseLengthType const lambda, Args&&... args)
: T(std::forward<Args>(args)...)
, n_0(n0)
, lambda_(lambda) {}
template <typename T>
double ExponentialRefractiveIndex<T>::getRefractiveIndex(Point const& point) const {
//TODO: THIS METHOD CURRENTLY ONLY USES THE Z-COORDINATE.
//NEED TO THINK IT FOR FUTURE WORK ON ARBITRARY GEOMETRIES.
return n_0 * exp((-lambda_) * point.getCoordinates().getZ());
// TODO: THIS METHOD CURRENTLY ONLY USES THE Z-COORDINATE.
// NEED TO THINK IT FOR FUTURE WORK ON ARBITRARY GEOMETRIES.
return n_0 * exp((-lambda_) * point.getCoordinates().getZ());
}
} // namespace corsika
......@@ -18,8 +18,8 @@ namespace corsika {
* points using N >= 1 straight-line segments.
*/
class Path {
std::deque<Point> points_; ///< The points that make up this path.
LengthType length_= LengthType::zero(); ///< The length of the path.
std::deque<Point> points_; ///< The points that make up this path.
LengthType length_ = LengthType::zero(); ///< The length of the path.
public:
/**
* Create a Path with a given starting Point.
......@@ -78,7 +78,7 @@ namespace corsika {
*/
inline int GetNSegments() const;
}; // class Path
}; // class Path
} // namespace corsika
......
......@@ -23,7 +23,7 @@ namespace corsika {
template <typename T>
class ExponentialRefractiveIndex : public T {
double n_0; ///< n0 constant.
double n_0; ///< n0 constant.
InverseLengthType lambda_; ///< lambda parameter.
public:
......@@ -37,8 +37,8 @@ namespace corsika {
* @param field The refractive index to return to a given point.
*/
template <typename... Args>
ExponentialRefractiveIndex(double const n0,
InverseLengthType const lambda, Args&&... args);
ExponentialRefractiveIndex(double const n0, InverseLengthType const lambda,
Args&&... args);
/**
* Evaluate the refractive index at a given location.
......
......@@ -316,12 +316,11 @@ TEST_CASE("Geometry Trajectories") {
}
}
TEST_CASE("Point") {
//define a known CS
// define a known CS
CoordinateSystemPtr root = get_root_CoordinateSystem();
//define known points
// define known points
Point p1(root, {0_m, 0_m, 0_m});
Point p2(root, {0_m, 0_m, 5_m});
Point p3(root, {1_m, 0_m, 0_m});
......@@ -330,68 +329,65 @@ TEST_CASE("Point") {
Point p6(root, {0_m, 5_m, 0_m});
SECTION("Test distance_to() method")
//check distance_to() method
// check distance_to() method
CHECK(p1.distance_to(p2) / 1_m == Approx(5));
CHECK(p3.distance_to(p4) / 1_m == Approx(4));
CHECK(p5.distance_to(p6) / 1_m == Approx(1));
}
TEST_CASE("Path") {
//define a known CS
// define a known CS
CoordinateSystemPtr root = get_root_CoordinateSystem();
//define known points
// define known points
Point p1(root, {0_m, 0_m, 0_m});
Point p2(root, {0_m, 0_m, 1_m});
Point p3(root, {0_m, 0_m, 2_m});
Point p4(root, {0_m, 0_m, 3_m});
Point p5(root, {0_m, 0_m, 4_m});
//define paths
// define paths
Path P1(p1);
Path P2({p1,p2});
Path P2({p1, p2});
Path P3({p1, p2, p3});
//define deque that include point(s)
// define deque that include point(s)
std::deque<Point> l1 = {p1};
std::deque<Point> l2 = {p1, p2};
std::deque<Point> l3 = {p1, p2, p3};
//test the various path constructors
// test the various path constructors
SECTION("Test Constructors") {
//check constructor for one point
CHECK(std::equal(P1.begin(), P1.end(), l1.begin(),[](Point a, Point b)
{ return (a - b).getNorm() / 1_m < 1e-5;}));
//check constructor for collection of points
CHECK(std::equal(P3.begin(), P3.end(), l3.begin(),[](Point a, Point b)
{ return (a - b).getNorm() / 1_m < 1e-5;}));
// check constructor for one point
CHECK(std::equal(P1.begin(), P1.end(), l1.begin(),
[](Point a, Point b) { return (a - b).getNorm() / 1_m < 1e-5; }));
// check constructor for collection of points
CHECK(std::equal(P3.begin(), P3.end(), l3.begin(),
[](Point a, Point b) { return (a - b).getNorm() / 1_m < 1e-5; }));
}
//test the length and access methods
// test the length and access methods
SECTION("Test GetLength() and modifications to Path") {
P1.AddToEnd(p2);
P2.RemoveFromEnd();
//Check modifications to path
CHECK(std::equal(P1.begin(), P1.end(), l2.begin(),[](Point a, Point b)
{ return (a - b).getNorm() / 1_m < 1e-5;}));
CHECK(std::equal(P2.begin(), P2.end(), l1.begin(),[](Point a, Point b)
{ return (a - b).getNorm() / 1_m < 1e-5;}));
//Check GetStart(), GetEnd(), GetPoint()
// Check modifications to path
CHECK(std::equal(P1.begin(), P1.end(), l2.begin(),
[](Point a, Point b) { return (a - b).getNorm() / 1_m < 1e-5; }));
CHECK(std::equal(P2.begin(), P2.end(), l1.begin(),
[](Point a, Point b) { return (a - b).getNorm() / 1_m < 1e-5; }));
// Check GetStart(), GetEnd(), GetPoint()
CHECK((P3.GetEnd() - P3.GetStart()).getNorm() / 1_m == Approx(2));
CHECK((P1.GetPoint(1) - p2).getNorm() / 1_m == Approx(0));
//Check GetLength()
// Check GetLength()
CHECK(P1.GetLength() / 1_m == Approx(1));
CHECK(P2.GetLength() / 1_m == Approx(0));
CHECK(P3.GetLength() / 1_m == Approx(2));
P2.RemoveFromEnd();
CHECK(P2.GetLength() / 1_m == Approx(0)); //Check the length of an empty path
CHECK(P2.GetLength() / 1_m == Approx(0)); // Check the length of an empty path
P3.AddToEnd(p4);
P3.AddToEnd(p5);
CHECK(P3.GetLength() / 1_m == Approx(4));
P3.RemoveFromEnd();
CHECK(P3.GetLength() / 1_m == Approx(3)); //Check RemoveFromEnd() else case
//Check GetNSegments()
CHECK(P3.GetLength() / 1_m == Approx(3)); // Check RemoveFromEnd() else case
// Check GetNSegments()
CHECK(P3.GetNSegments() - 3 == Approx(0));
}
}
......@@ -91,7 +91,6 @@ TEST_CASE("UniformRefractiveIndex w/ Homogeneous") {
CHECK((medium.getArclengthFromGrammage(track, density * 5_m) / 5_m) == Approx(1));
}
TEST_CASE("ExponentialRefractiveIndex w/ Homogeneous medium") {
logging::set_level(logging::level::info);
......@@ -158,8 +157,8 @@ TEST_CASE("ExponentialRefractiveIndex w/ Homogeneous medium") {
// and the associated trajectory
setup::Trajectory const track =
setup::testing::make_track<setup::Trajectory>(line, tEnd);
// // and the associated trajectory
// Trajectory<Line> const trajectory(line, tEnd);
// // and the associated trajectory
// Trajectory<Line> const trajectory(line, tEnd);
// and check the integrated grammage
REQUIRE((medium.getIntegratedGrammage(track, 3_m) / (density * 3_m)) == Approx(1));
......
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