Files
pplus-library/modules/md/pair-distance/routine.pseudo
T
alexm 568474d52f
Test (in pplus-core) / in-core (push) Failing after 28m44s
Initial commit
2026-11-12 22:23:48 -05:00

12 lines
599 B
Plaintext

// PairDistance: the distance between two points in a cubic periodic box of
// side Box, each coordinate difference taken by the minimum image
// convention. HYPOT adds the squares without overflowing on the way.
USE md.MinimumImage
FUNCTION PairDistance(A : LIST OF FLOAT, B : LIST OF FLOAT, Box : FLOAT) RETURNS FLOAT
REQUIRE LENGTH(A) == 3 AND LENGTH(B) == 3 AND Box > 0.0
DECLARE Dx : FLOAT <- MinimumImage(A[0] - B[0], Box)
DECLARE Dy : FLOAT <- MinimumImage(A[1] - B[1], Box)
DECLARE Dz : FLOAT <- MinimumImage(A[2] - B[2], Box)
RETURN HYPOT(HYPOT(Dx, Dy), Dz)
ENDFUNCTION