-S with -C: the cell goes onto the given axes by the nearest relabelling

CellMappingOperators admits every relabelling within 5% / 3 deg of the given cell, so on a
cell with two lengths that close more than one maps; ops.front() took the first in
enumeration order (the identity where it qualifies) even where another put the cell on the
typed axes better, e.g. a pure 2-fold given on the shorter of two near-equal axes. The
nearest one is now taken (the OnGivenAxes distance), the identity on a tie.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UqXYdJDrM65gxsCn2PrbfK
This commit is contained in:
leonarski_fandClaude Opus 5.5 committed 2026-11-16 07:48:55 +01:00
1 parent 6f6e57b364
commit d3f537aac6
1 file changed
+16 -3
+16 -3
View File
@@ -1200,11 +1200,24 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) {
for (const auto &[hkl, sum] : summed)
axial.push_back({hkl, sum.first / std::sqrt(sum.second)});
// With the cell given too, the setting is the user's: the cell goes onto the given cell's axes.
// Where two lengths are within the 5% CellsCorrespond allows, more than one relabelling maps the
// cell onto the given one, and the given axes are those of the nearest (the identity on a tie).
gemmi::Op cob = gemmi::Op::identity();
if (user_cell_) {
const auto ops = CellMappingOperators(gemmi::UnitCell(*result.consensus_cell), gemmi::UnitCell(*user_cell_));
if (!ops.empty())
cob = ops.front();
const UnitCell &given = *user_cell_;
double best = std::numeric_limits<double>::infinity();
for (const gemmi::Op &op : CellMappingOperators(gemmi::UnitCell(*result.consensus_cell),
gemmi::UnitCell(given))) {
const UnitCell m = CellInBasis(*result.consensus_cell, op);
const double d = std::fabs(m.alpha - given.alpha) + std::fabs(m.beta - given.beta)
+ std::fabs(m.gamma - given.gamma)
+ 100.0 * (std::fabs(m.a - given.a) / given.a + std::fabs(m.b - given.b) / given.b
+ std::fabs(m.c - given.c) / given.c);
if (d < best) {
best = d;
cob = op;
}
}
} else
cob = SeatGroupByAbsences(*result.consensus_cell, *user_fixed_sg_, axial);
if (!(cob == gemmi::Op::identity())) {