aboutsummaryrefslogtreecommitdiff
path: root/src/diffraction.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2011-03-04 19:01:01 +0100
committerThomas White <taw@physics.org>2012-02-22 15:27:17 +0100
commit19ef22337eb31c423c471de1fd90cee13964fde7 (patch)
tree1f4814bf2eafd8145d0a8d82ebd29c9a9264d963 /src/diffraction.c
parent66a6149fc0b69b1322f2d3f2d162ef5e6ea0882d (diff)
Fix silly mistakes
Diffstat (limited to 'src/diffraction.c')
-rw-r--r--src/diffraction.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/diffraction.c b/src/diffraction.c
index 13a3dd95..6b9daf7f 100644
--- a/src/diffraction.c
+++ b/src/diffraction.c
@@ -61,13 +61,13 @@ static double interpolate_lut(double *lut, double val)
double i, pos, f;
unsigned int low, high;
- pos = SINC_LUT_ELEMENTS * modf(val, &i);
+ pos = SINC_LUT_ELEMENTS * modf(fabs(val), &i);
low = (int)pos; /* Discard fractional part */
high = low + 1;
f = modf(pos, &i); /* Fraction */
if ( high == SINC_LUT_ELEMENTS ) high = 0;
- return (1.0-f)*low + f*high;
+ return (1.0-f)*lut[low] + f*lut[high];
}
@@ -85,8 +85,8 @@ static double lattice_factor(struct rvec q, double ax, double ay, double az,
Udotq.w = cx*q.u + cy*q.v + cz*q.w;
f1 = interpolate_lut(lut_a, Udotq.u);
- f2 = interpolate_lut(lut_b, Udotq.u);
- f3 = interpolate_lut(lut_c, Udotq.u);
+ f2 = interpolate_lut(lut_b, Udotq.v);
+ f3 = interpolate_lut(lut_c, Udotq.w);
return f1 * f2 * f3;
}