From 19ef22337eb31c423c471de1fd90cee13964fde7 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 4 Mar 2011 19:01:01 +0100 Subject: Fix silly mistakes --- src/diffraction.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3