00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <math.h>
00020
00021 static void ccker (double *u, double s) {
00022 double s2, s3;
00023
00024 s2= s * s;
00025 s3= s2 * s;
00026 u[0] = s2 - 0.5 * (s3 + s);
00027 u[1] = 1.5*s3 - 2.5*s2 + 1.0;
00028 u[2] = -1.5*s3 + 2.0*s2 + 0.5*s;
00029 u[3] = 0.5 * (s3 - s2);
00030 }
00031
00032 float ccint2 (float *f, int nx, int ny, double x, double y) {
00033 double ux[4], uy[4];
00034 double sum;
00035 int ix, iy, ix1, iy1, i, j;
00036
00037 if (x < 1. || x >= (float)(nx-2) || y < 1. || y >= (float)(ny-2))
00038 return 0.0/ 0.0;
00039
00040 ix = (int)x;
00041 ccker (ux, x - (double)ix);
00042 iy = (int)y;
00043 ccker (uy, y - (double)iy);
00044
00045 ix1 = ix - 1;
00046 iy1 = iy - 1;
00047 sum = 0.;
00048 for (i = 0; i < 4; i++)
00049 for (j = 0; j < 4; j++)
00050 sum = sum + f[(iy1+i) * nx + ix1 + j] * uy[i] * ux[j];
00051 return (float)sum;
00052 }
00053
00054 double ccint2d (double *f, int nx, int ny, double x, double y) {
00055 double ux[4], uy[4];
00056 double sum;
00057 int ix, iy, ix1, iy1, i, j;
00058
00059 if (x < 1. || x >= (float)(nx-2) || y < 1. || y >= (float)(ny-2))
00060 return 0.0/ 0.0;
00061
00062 ix = (int)x;
00063 ccker (ux, x - (double)ix);
00064 iy = (int)y;
00065 ccker (uy, y - (double)iy);
00066
00067 ix1 = ix - 1;
00068 iy1 = iy - 1;
00069 sum = 0.;
00070 for (i = 0; i < 4; i++)
00071 for (j = 0; j < 4; j++)
00072 sum = sum + f[(iy1+i) * nx + ix1 + j] * uy[i] * ux[j];
00073 return sum;
00074 }