diff --git a/src/Action_Radial.cpp b/src/Action_Radial.cpp index 40aeab9dae..f5eca202e3 100644 --- a/src/Action_Radial.cpp +++ b/src/Action_Radial.cpp @@ -483,6 +483,12 @@ void Action_Radial::calcRDF_singleMask(Frame const& frmIn) { int outer_max = OuterMask_.Nselected(); int idx1; + double boxX = frmIn.BoxCrd().Param(Box::X); + double boxY = frmIn.BoxCrd().Param(Box::Y); + double boxZ = frmIn.BoxCrd().Param(Box::Z); + bool isOrtho = (imageOpt_.ImagingType() == ImageOption::ORTHO && + boxX != 0.0 && boxY != 0.0 && boxZ != 0.0); + long unsigned* myRDF = &RDF_[0]; # ifdef _OPENMP # pragma omp parallel private(idx1, myRDF) @@ -495,7 +501,27 @@ void Action_Radial::calcRDF_singleMask(Frame const& frmIn) { const double* xyz1 = frmIn.XYZ( OuterMask_[idx1] ); for (int idx2 = idx1 + 1; idx2 < outer_max; idx2++) { const double* xyz2 = frmIn.XYZ( OuterMask_[idx2] ); - double D2 = DIST2( imageOpt_.ImagingType(), xyz1, xyz2, frmIn.BoxCrd() ); + double D2; + if (isOrtho) { + double x = xyz1[0] - xyz2[0]; + double y = xyz1[1] - xyz2[1]; + double z = xyz1[2] - xyz2[2]; + x = std::fabs(x); + y = std::fabs(y); + z = std::fabs(z); + while (x > boxX) x -= boxX; + while (y > boxY) y -= boxY; + while (z > boxZ) z -= boxZ; + double D = boxX - x; + if (D < x) x = D; + D = boxY - y; + if (D < y) y = D; + D = boxZ - z; + if (D < z) z = D; + D2 = x*x + y*y + z*z; + } + else + D2 = DIST2(imageOpt_.ImagingType(), xyz1, xyz2, frmIn.BoxCrd()); if (D2 <= maximum2_) { // NOTE: Can we modify the histogram to store D^2? double dist = sqrt(D2);