From a18d82f77c335f962475ce65008c697756293320 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 18 Sep 2010 17:29:27 +0200 Subject: cubeit: Fix interpolation --- src/cubeit.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/cubeit.c') diff --git a/src/cubeit.c b/src/cubeit.c index e82bbb8e..49cf27cd 100644 --- a/src/cubeit.c +++ b/src/cubeit.c @@ -84,11 +84,11 @@ static void interpolate_linear(double *vals, double v, double val1, val2; float f, c; - c = (zv+0.5)*(float)zs; + c = (zv+0.5)*(float)(zs-1); k = (int)c; f = c - (float)k; assert(f >= 0.0); - assert(k < zs); + assert(k+1 < zs); val1 = v*(1.0-f); val2 = v*f; @@ -106,11 +106,11 @@ static void interpolate_bilinear(double *vals, double v, double val1, val2; float f, c; - c = (yv+0.5)*(float)ys; + c = (yv+0.5)*(float)(ys-1); k = (int)c; f = c - (float)k; assert(f >= 0.0); - assert(k < ys); + assert(k+1 < ys); val1 = v*(1.0-f); val2 = v*f; @@ -128,11 +128,11 @@ static void interpolate_onto_grid(double *vals, double v, double val1, val2; float f, c; - c = (xv+0.5)*(float)xs; + c = (xv+0.5)*(float)(xs-1); k = (int)c; f = c - (float)k; assert(f >= 0.0); - assert(k < xs); + assert(k+1 < xs); val1 = v*(1.0-f); val2 = v*f; -- cgit v1.2.3