// MinimumImage: the displacement Dx brought to its nearest periodic image in // a box of length Box, the minimum image convention: Dx minus the whole // number of box lengths that brings it into [-Box / 2, Box / 2). FLOOR of // Dx / Box + 0.5 rounds halves upward, so exactly half a box maps to -Box / 2. FUNCTION MinimumImage(Dx : FLOAT, Box : FLOAT) RETURNS FLOAT REQUIRE Box > 0.0 RETURN Dx - Box * FLOOR(Dx / Box + 0.5) ENDFUNCTION