diff options
Diffstat (limited to 'src/reproject.c')
-rw-r--r-- | src/reproject.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/reproject.c b/src/reproject.c index 439c2f7..e1ce13e 100644 --- a/src/reproject.c +++ b/src/reproject.c @@ -85,7 +85,7 @@ ImageFeatureList *reproject_get_reflections(ImageRecord *image, ReflectionList * double xl, yl, zl; double a, b, c; - double A1, A2, s1, s2, s, temp; + double A1, A2, s1, s2, s; /* Get the coordinates of the reciprocal lattice point */ xl = reflection->x; @@ -95,11 +95,9 @@ ImageFeatureList *reproject_get_reflections(ImageRecord *image, ReflectionList * /* Next, solve the relrod equation to calculate the excitation error */ a = 1.0; b = -2.0*(xl*nx + yl*ny + zl*nz); - c = xl*xl + yl*yl + zl*zl - 1.0/(image->lambda*image->lambda); /* FIXME: Don't think this is stable */ - /* Solve the quadratic equation */ - temp = -0.5 * (b + sign(b)*sqrt(b*b - 4*a*c)); - A1 = temp / a; - A2 = c / temp; + c = xl*xl + yl*yl + zl*zl - 1.0/(image->lambda*image->lambda); + A1 = (-b + sqrt(b*b-4.0*a*c))/(2.0*a); + A2 = (-b - sqrt(b*b-4.0*a*c))/(2.0*a); s1 = 1.0/image->lambda - A1; s2 = 1.0/image->lambda - A2; if ( fabs(s1) < fabs(s2) ) s = s1; else s = s2; |