aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2016-11-10 10:47:55 +0100
committerThomas White <taw@physics.org>2016-11-10 10:50:25 +0100
commit6f2696f7a15a3b2f0a8ed39ce23e77123b85d904 (patch)
tree63b04018ceb794e311327f3b7d3c4c824e7824b8
parent3a5eacd9262964210d44118a407e30b21157dfa2 (diff)
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.
-rw-r--r--libcrystfel/src/geometry.c7
1 files changed, 3 insertions, 4 deletions
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 */