IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 41c1d3ad authored by Nikos Karastathis's avatar Nikos Karastathis :ocean:
Browse files

Added and tested distance_to() method

parent 18d16d1c
No related branches found
No related tags found
1 merge request!313Resolve "Geometry and environment feature updates - merge to refactored version"
......@@ -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
inline QuantityVector<length_d> Point::getCoordinates(
CoordinateSystemPtr const& pCS) const {
......
......@@ -65,6 +65,11 @@ namespace corsika {
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
* coordinates interally
......
......@@ -312,3 +312,23 @@ TEST_CASE("Geometry Trajectories") {
.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