Skip to content

Commit 977444a

Browse files
committed
Tweak the box test to avoid numerical errors.
1 parent 41b34a4 commit 977444a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tests/classes/box.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ void testBasicOperations(Box &box)
6464
// Determine central coordinate from full axes matrix
6565
auto centroid = box.axes() * Vector3(0.5, 0.5, 0.5);
6666

67-
// For each corner, determine correct coordinates from full axes matrix, then test optimised imaging / vector functions
67+
// For each corner, determine correct coordinates from full axes matrix, then test optimised imaging / vector functions.
68+
// If we sit perfectly on the corner vertex we risk numerical errors breaking the tests, so step inside by a small delta.
69+
const auto delta = 1.0e-5;
6870
for (auto n = 0; n < 8; ++n)
6971
{
70-
auto corner = box.axes() * Vector3((n & 1) ? 1.0 : 0.0, (n & 2) ? 1.0 : 0.0, (n & 4) ? 1.0 : 0.0);
72+
auto corner =
73+
box.axes() * Vector3((n & 1) ? 1.0 - delta : delta, (n & 2) ? 1.0 - delta : delta, (n & 4) ? 1.0 - delta : delta);
7174

7275
// Calculate manual minimum image vector
7376
auto mimCorner = manualMim(box, corner, centroid);

0 commit comments

Comments
 (0)