IAP GITLAB

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

Added and tested distance_to() method

(cherry picked from commit 41c1d3ad)
parent 11930067
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,10 @@ namespace corsika { ...@@ -59,6 +59,10 @@ namespace corsika {
} }
} }
inline LengthType Point::distance_to(Point const& point) const {
return (*this - point).getNorm();
}
/// this always returns a QuantityVector as triple /// this always returns a QuantityVector as triple
inline QuantityVector<length_d> Point::getCoordinates( inline QuantityVector<length_d> Point::getCoordinates(
CoordinateSystemPtr const& pCS) const { CoordinateSystemPtr const& pCS) const {
......
...@@ -65,6 +65,11 @@ namespace corsika { ...@@ -65,6 +65,11 @@ namespace corsika {
LengthType getZ(CoordinateSystemPtr const& pCS) const; LengthType getZ(CoordinateSystemPtr const& pCS) const;
/** \} **/ /** \} **/
/*
* calculates the distance between two points
*/
inline LengthType distance_to(Point const& point) const;
/*! /*!
* transforms the Point into another CoordinateSystem by changing its * transforms the Point into another CoordinateSystem by changing its
* coordinates interally * coordinates interally
......
...@@ -314,3 +314,23 @@ TEST_CASE("Geometry Trajectories") { ...@@ -314,3 +314,23 @@ TEST_CASE("Geometry Trajectories") {
.magnitude() == Approx(0).margin(absMargin)); .magnitude() == Approx(0).margin(absMargin));
} }
} }
TEST_CASE("Point") {
//define a known CS
CoordinateSystemPtr root = get_root_CoordinateSystem();
//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});
Point p4(root, {5_m, 0_m, 0_m});
Point p5(root, {0_m, 4_m, 0_m});
Point p6(root, {0_m, 5_m, 0_m});
SECTION("Test 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));
}
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