diff --git a/common/GoniometerAxis.cpp b/common/GoniometerAxis.cpp index 09467618..b88d8e51 100644 --- a/common/GoniometerAxis.cpp +++ b/common/GoniometerAxis.cpp @@ -120,9 +120,7 @@ std::vector GoniometerAxis::GetAngleContainerEnd(int64_t max_image_numbe return angle_container; } -RotMatrix GoniometerAxis::GetTransformation(int64_t image_number) const { - // Transformation goes back from rotated to "start" - auto angle_deg = GetAngle_deg(image_number); +RotMatrix GoniometerAxis::GetTransformationAngle(float angle_deg) const { auto angle_rad = angle_deg / 180.0f * static_cast(M_PI); return {angle_rad, axis}; -} +} \ No newline at end of file diff --git a/common/GoniometerAxis.h b/common/GoniometerAxis.h index 9d19abeb..f644a40f 100644 --- a/common/GoniometerAxis.h +++ b/common/GoniometerAxis.h @@ -44,7 +44,7 @@ public: [[nodiscard]] std::vector GetAxisVector() const; - [[nodiscard]] RotMatrix GetTransformation(int64_t image_number) const; + [[nodiscard]] RotMatrix GetTransformationAngle(float angle_deg) const; }; diff --git a/image_analysis/IndexAndRefine.cpp b/image_analysis/IndexAndRefine.cpp index 1585685e..891c9e17 100644 --- a/image_analysis/IndexAndRefine.cpp +++ b/image_analysis/IndexAndRefine.cpp @@ -29,8 +29,10 @@ IndexAndRefine::IndexingOutcome IndexAndRefine::DetermineLatticeAndSymmetry(Data // get rotated lattice auto gon = experiment.GetGoniometer(); - if (gon) - outcome.lattice_candidate = result->lattice.Multiply(gon->GetTransformation(-msg.number)); + if (gon) { + const float angle_deg = gon->GetAngle_deg(msg.number) + gon->GetWedge_deg() / 2.0f; + outcome.lattice_candidate = result->lattice.Multiply(gon->GetTransformationAngle(-angle_deg)); + } outcome.experiment.BeamX_pxl(result->geom.GetBeamX_pxl()) .BeamY_pxl(result->geom.GetBeamY_pxl()) diff --git a/image_analysis/RotationIndexer.cpp b/image_analysis/RotationIndexer.cpp index f3ff9372..dc2c1254 100644 --- a/image_analysis/RotationIndexer.cpp +++ b/image_analysis/RotationIndexer.cpp @@ -114,7 +114,8 @@ std::optional RotationIndexer::ProcessImage(int64_t image if (!axis_) return {}; - const auto rot = axis_->GetTransformation(image); + const float angle_deg = axis_->GetAngle_deg(image) + axis_->GetWedge_deg() / 2.0f; + const auto rot = axis_->GetTransformationAngle(angle_deg); if (!indexing_tried && image >= last_accumulated_image + image_stride) { v_.reserve(v_.size() + spots.size()); diff --git a/image_analysis/geom_refinement/XtalOptimizer.cpp b/image_analysis/geom_refinement/XtalOptimizer.cpp index a3e6ac39..f1e775df 100644 --- a/image_analysis/geom_refinement/XtalOptimizer.cpp +++ b/image_analysis/geom_refinement/XtalOptimizer.cpp @@ -429,7 +429,8 @@ bool XtalOptimizerInternal(XtalOptimizerData &data, Coord recip = data.geom.DetectorToRecip(pt.x, pt.y); if (data.axis) { - auto rot = data.axis->GetTransformation(pt.image); + const float angle_deg = data.axis->GetAngle_deg(pt.image) + data.axis->GetWedge_deg() / 2.0f; + auto rot = data.axis->GetTransformationAngle(angle_deg); recip = rot * recip; Eigen::Matrix3d Rg; diff --git a/tests/RotationIndexerTest.cpp b/tests/RotationIndexerTest.cpp index 27d2be44..87f0d7b7 100644 --- a/tests/RotationIndexerTest.cpp +++ b/tests/RotationIndexerTest.cpp @@ -53,7 +53,8 @@ TEST_CASE("RotationIndexer") { for (int img = 0; img < 50; ++img) { std::vector spots; // For a rotated image, per-image lattice is obtained as Multiply(rot.transpose()) - const RotMatrix rot = axis.GetTransformation(img); + const float angle_deg = axis.GetAngle_deg(img) + axis.GetWedge_deg() / 2.0f; + const RotMatrix rot = axis.GetTransformationAngle(angle_deg); const CrystalLattice latt_img = latt_base.Multiply(rot.transpose()); const auto n = prediction.Calc(exp_i, latt_img, prediction_settings); diff --git a/tests/XtalOptimizerTest.cpp b/tests/XtalOptimizerTest.cpp index 031716c8..8503c8b0 100644 --- a/tests/XtalOptimizerTest.cpp +++ b/tests/XtalOptimizerTest.cpp @@ -576,7 +576,8 @@ TEST_CASE("XtalOptimizer_rotation") { // Predict reflections for images at 0-30 deg. for (int img = 0; img < 10; ++img) { // For a rotated image, per-image lattice is obtained as Multiply(rot.transpose()) - const RotMatrix rot = axis.GetTransformation(img); + const float angle_deg = axis.GetAngle_deg(img) + axis.GetWedge_deg() / 2.0f; + const RotMatrix rot = axis.GetTransformationAngle(angle_deg); const CrystalLattice latt_img = latt_base.Multiply(rot.transpose()); const auto n = prediction.Calc(exp_i, latt_img, prediction_settings);