From cab566acc59cba6595c3eb6c3c307eb4a2169b15 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 14 Apr 2026 15:26:37 +0200 Subject: [PATCH] DiffractionGeometry: Fix function name --- common/DiffractionGeometry.cpp | 6 +++--- common/DiffractionGeometry.h | 2 +- tests/CalcBraggPredictionTest.cpp | 10 +++++----- tests/DiffractionGeometryTest.cpp | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/common/DiffractionGeometry.cpp b/common/DiffractionGeometry.cpp index 2fc01047..51163a59 100644 --- a/common/DiffractionGeometry.cpp +++ b/common/DiffractionGeometry.cpp @@ -14,7 +14,7 @@ Coord DiffractionGeometry::LabCoord(float x, float y) const { } std::pair DiffractionGeometry::GetDirectBeam_pxl() const { - return RecipToDector({0,0,0}); + return RecipToDetector({0,0,0}); } Coord DiffractionGeometry::GetScatteringVector() const { @@ -25,7 +25,7 @@ Coord DiffractionGeometry::DetectorToRecip(float x, float y) const { return LabCoord(x, y).Normalize() / wavelength_A - GetScatteringVector(); } -std::pair DiffractionGeometry::RecipToDector(const Coord &recip) const { +std::pair DiffractionGeometry::RecipToDetector(const Coord &recip) const { auto S_unrotated = recip + GetScatteringVector(); auto S = poni_rot.transpose() * S_unrotated; if (S.z <= 0) @@ -231,7 +231,7 @@ std::pair DiffractionGeometry::ResPhiToPxl(float d_A, float phi_ra float cphi = cosf(phi_rad); float sphi = sinf(phi_rad); - return RecipToDector(Coord{ k * s2t * cphi,k * s2t * sphi,k * (c2t - 1.0f)}); + return RecipToDetector(Coord{ k * s2t * cphi,k * s2t * sphi,k * (c2t - 1.0f)}); } Coord DiffractionGeometry::ProjectToEwaldSphere(const Coord &p0) const { diff --git a/common/DiffractionGeometry.h b/common/DiffractionGeometry.h index f03c7a42..c56eaf3b 100644 --- a/common/DiffractionGeometry.h +++ b/common/DiffractionGeometry.h @@ -46,7 +46,7 @@ public: [[nodiscard]] Coord LabCoord(float x, float y) const; [[nodiscard]] Coord DetectorToRecip(float x, float y) const; - [[nodiscard]] std::pair RecipToDector(const Coord &recip) const; + [[nodiscard]] std::pair RecipToDetector(const Coord &recip) const; [[nodiscard]] float TwoTheta_rad(float x, float y) const; [[nodiscard]] float Phi_rad(float x, float y) const; [[nodiscard]] float PxlToRes(float x, float y) const; diff --git a/tests/CalcBraggPredictionTest.cpp b/tests/CalcBraggPredictionTest.cpp index 0a49cb25..50b609fd 100644 --- a/tests/CalcBraggPredictionTest.cpp +++ b/tests/CalcBraggPredictionTest.cpp @@ -36,7 +36,7 @@ TEST_CASE("BraggPrediction_11keV") { REQUIRE(r.d >= settings.high_res_A); REQUIRE(r.d == Catch::Approx(1/std::sqrt(recip * recip)).margin(0.01f)); REQUIRE(r.dist_ewald == Catch::Approx(std::abs(geom.DistFromEwaldSphere(recip))).epsilon(1e-5)); - auto [x,y] = geom.RecipToDector(recip); + auto [x,y] = geom.RecipToDetector(recip); REQUIRE(r.predicted_x == Catch::Approx(x).margin(0.01)); REQUIRE(r.predicted_y == Catch::Approx(y).margin(0.01)); } @@ -72,7 +72,7 @@ TEST_CASE("BraggPrediction_15keV") { REQUIRE(r.d >= settings.high_res_A); REQUIRE(r.d == Catch::Approx(1/std::sqrt(recip * recip)).margin(0.01f)); REQUIRE(r.dist_ewald == Catch::Approx(std::abs(geom.DistFromEwaldSphere(recip))).epsilon(1e-5)); - auto [x,y] = geom.RecipToDector(recip); + auto [x,y] = geom.RecipToDetector(recip); REQUIRE(r.predicted_x == Catch::Approx(x).margin(0.01)); REQUIRE(r.predicted_y == Catch::Approx(y).margin(0.01)); } @@ -109,7 +109,7 @@ TEST_CASE("BraggPrediction_Rot1_Rot2") { REQUIRE(r.d >= settings.high_res_A); REQUIRE(r.d == Catch::Approx(1/std::sqrt(recip * recip)).margin(0.01f)); REQUIRE(r.dist_ewald == Catch::Approx(std::abs(geom.DistFromEwaldSphere(recip))).epsilon(1e-5)); - auto [x,y] = geom.RecipToDector(recip); + auto [x,y] = geom.RecipToDetector(recip); REQUIRE(r.predicted_x == Catch::Approx(x).margin(0.01)); REQUIRE(r.predicted_y == Catch::Approx(y).margin(0.01)); } @@ -236,7 +236,7 @@ TEST_CASE("BraggPredictionGPU") { REQUIRE(r.d >= settings.high_res_A); REQUIRE(r.d == Catch::Approx(1/std::sqrt(recip * recip)).margin(0.01f)); REQUIRE(r.dist_ewald == Catch::Approx(std::abs(geom.DistFromEwaldSphere(recip))).epsilon(2e-2)); - auto [x,y] = geom.RecipToDector(recip); + auto [x,y] = geom.RecipToDetector(recip); REQUIRE(r.predicted_x == Catch::Approx(x).margin(0.05)); REQUIRE(r.predicted_y == Catch::Approx(y).margin(0.05)); } @@ -273,7 +273,7 @@ TEST_CASE("BraggPredictionGPU_Rot1_Rot2") { REQUIRE(r.d >= settings.high_res_A); REQUIRE(r.d == Catch::Approx(1/std::sqrt(recip * recip)).margin(0.01f)); REQUIRE(r.dist_ewald == Catch::Approx(std::abs(geom.DistFromEwaldSphere(recip))).epsilon(1e-3)); - auto [x,y] = geom.RecipToDector(recip); + auto [x,y] = geom.RecipToDetector(recip); REQUIRE(r.predicted_x == Catch::Approx(x).margin(0.05)); REQUIRE(r.predicted_y == Catch::Approx(y).margin(0.05)); } diff --git a/tests/DiffractionGeometryTest.cpp b/tests/DiffractionGeometryTest.cpp index ef307613..8b60f95f 100644 --- a/tests/DiffractionGeometryTest.cpp +++ b/tests/DiffractionGeometryTest.cpp @@ -15,7 +15,7 @@ TEST_CASE("RecipToDetector_1", "[LinearAlgebra][Coord]") { float pos_x = 512, pos_y = 512; auto recip = geom.DetectorToRecip(pos_x, pos_y); - auto [proj_x, proj_y] = geom.RecipToDector(recip); + auto [proj_x, proj_y] = geom.RecipToDetector(recip); REQUIRE(proj_x == Catch::Approx(pos_x)); REQUIRE(proj_y == Catch::Approx(pos_y)); REQUIRE((recip - geom.DetectorToRecip(proj_x, proj_y)).Length() < 0.00000001f); @@ -29,7 +29,7 @@ TEST_CASE("RecipToDetector_2", "[LinearAlgebra][Coord]") { DiffractionGeometry geom = x.GetDiffractionGeometry(); auto recip = geom.DetectorToRecip(pos_x, pos_y); - auto [proj_x, proj_y] = geom.RecipToDector(recip); + auto [proj_x, proj_y] = geom.RecipToDetector(recip); REQUIRE(proj_x == Catch::Approx(pos_x)); REQUIRE(proj_y == Catch::Approx(pos_y)); REQUIRE((recip - geom.DetectorToRecip(proj_x, proj_y)).Length() < 0.00000001f); @@ -43,7 +43,7 @@ TEST_CASE("RecipToDetector_3", "[LinearAlgebra][Coord]") { DiffractionGeometry geom = x.GetDiffractionGeometry(); auto recip = geom.DetectorToRecip(pos_x, pos_y); - auto [proj_x, proj_y] = geom.RecipToDector(recip); + auto [proj_x, proj_y] = geom.RecipToDetector(recip); REQUIRE(proj_x == Catch::Approx(pos_x)); REQUIRE(proj_y == Catch::Approx(pos_y)); REQUIRE((recip - geom.DetectorToRecip(proj_x, proj_y)).Length() < 0.00000001f); @@ -488,7 +488,7 @@ TEST_CASE("DiffractionGeometry_DetectorToRecip_RecipToDetector_tilted") { for (const auto& [x, y] : test_points) { Coord recip = geom.DetectorToRecip(x, y); - auto [proj_x, proj_y] = geom.RecipToDector(recip); + auto [proj_x, proj_y] = geom.RecipToDetector(recip); CHECK(proj_x == Catch::Approx(x).margin(0.001)); CHECK(proj_y == Catch::Approx(y).margin(0.001));