diff options
author | Thomas White <taw@bitwiz.org.uk> | 2010-09-18 17:29:27 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:26:58 +0100 |
commit | a18d82f77c335f962475ce65008c697756293320 (patch) | |
tree | 07524e0a53601922fe43806c3359bd029ba9ca70 /src/cubeit.c | |
parent | e893ef14d77ff4a16151ee8c8807a156d4b657b8 (diff) |
cubeit: Fix interpolation
Diffstat (limited to 'src/cubeit.c')
-rw-r--r-- | src/cubeit.c | 12 |
1 files changed, 6 insertions, 6 deletions
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; |