diff --git a/src/domain.cpp b/src/domain.cpp index 5f52528f6d..bc5e283e5f 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -653,19 +653,19 @@ void Domain::minimum_image(double *delta) } /* ---------------------------------------------------------------------- - find Xj image = periodic image of Xj that is closest to Xi - for triclinic, also add/subtract tilt factors in other dims as needed + find and return Xj image = periodic image of Xj that is closest to Xi + for triclinic, add/subtract tilt factors in other dims as needed ------------------------------------------------------------------------- */ -void Domain::closest_image(const double * const xi, - const double * const xj, +void Domain::closest_image(const double * const xi, const double * const xj, double * const xjimage) { - double dx,dy,dz; + double dx = xj[0] - xi[0]; + double dy = xj[1] - xi[1]; + double dz = xj[2] - xi[2]; if (triclinic == 0) { if (xperiodic) { - dx = xj[0] - xi[0]; if (dx < 0.0) { while (dx < 0.0) dx += xprd; if (dx > xprd_half) dx -= xprd; @@ -673,10 +673,8 @@ void Domain::closest_image(const double * const xi, while (dx > 0.0) dx -= xprd; if (dx < -xprd_half) dx += xprd; } - xjimage[0] = xi[0] + dx; } if (yperiodic) { - dy = xj[1] - xi[1]; if (dy < 0.0) { while (dy < 0.0) dy += yprd; if (dy > yprd_half) dy -= yprd; @@ -684,10 +682,8 @@ void Domain::closest_image(const double * const xi, while (dy > 0.0) dy -= yprd; if (dy < -yprd_half) dy += yprd; } - xjimage[1] = xi[1] + dy; } if (zperiodic) { - dz = xj[2] - xi[2]; if (dz < 0.0) { while (dz < 0.0) dz += zprd; if (dz > zprd_half) dz -= zprd; @@ -695,14 +691,9 @@ void Domain::closest_image(const double * const xi, while (dz > 0.0) dz -= zprd; if (dz < -zprd_half) dz += zprd; } - xjimage[2] = xi[2] + dz; } } else { - dx = xj[0] - xi[0]; - dy = xj[1] - xi[1]; - dz = xj[2] - xi[2]; - if (zperiodic) { if (dz < 0.0) { while (dz < 0.0) { @@ -758,11 +749,11 @@ void Domain::closest_image(const double * const xi, if (dx < -xprd_half) dx += xprd; } } - - xjimage[0] = xi[0] + dx; - xjimage[1] = xi[1] + dy; - xjimage[2] = xi[2] + dz; } + + xjimage[0] = xi[0] + dx; + xjimage[1] = xi[1] + dy; + xjimage[2] = xi[2] + dz; } /* ---------------------------------------------------------------------- diff --git a/src/lattice.cpp b/src/lattice.cpp index 3f7e7bf33b..1eac7d2da2 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -313,15 +313,6 @@ Lattice::~Lattice() int Lattice::orthogonal() { - double a = orientx[0]*orienty[0] + orientx[1]*orienty[1] + - orientx[2]*orienty[2]; - double b = orienty[0]*orientz[0] + orienty[1]*orientz[1] + - orienty[2]*orientz[2]; - double c = orientx[0]*orientz[0] + orientx[1]*orientz[1] + - orientx[2]*orientz[2]; - - printf("ABC %g %g %g\n",a,b,c); - if (orientx[0]*orienty[0] + orientx[1]*orienty[1] + orientx[2]*orienty[2]) return 0; if (orienty[0]*orientz[0] + orienty[1]*orientz[1] +