From 6f2696f7a15a3b2f0a8ed39ce23e77123b85d904 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 10 Nov 2016 10:47:55 +0100 Subject: Fix 2theta calculation in locate_peak_on_panel() The "improved" version of this, added by 9b1374999 along with the new spot position calculation for out-of-plane panels, actually assumes that the reflection is at the exact Bragg condition. This is not a valid assumption here. The difference is small (<0.5 px), but made the prediction refinement gradients completely wrong. --- libcrystfel/src/geometry.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libcrystfel/src/geometry.c') diff --git a/libcrystfel/src/geometry.c b/libcrystfel/src/geometry.c index 266d6267..5403325f 100644 --- a/libcrystfel/src/geometry.c +++ b/libcrystfel/src/geometry.c @@ -52,16 +52,15 @@ static int locate_peak_on_panel(double x, double y, double z, double k, struct panel *p, double *pfs, double *pss) { - double r2, ctt, tta, phi; + double ctt, tta, phi; gsl_vector *v; gsl_vector *t; gsl_matrix *M; double fs, ss, one_over_mu; /* Calculate 2theta (scattering angle) and azimuth (phi) */ - r2 = x*x + y*y + z*z; - ctt = 1.0 - r2 / (2.0*k*k); /* cos(2theta) */ - tta = acos(ctt); + tta = atan2(sqrt(x*x+y*y), k+z); + ctt = cos(tta); phi = atan2(y, x); /* Set up matrix equation */ -- cgit v1.2.3