00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <math.h>
00030 #include "jsoc_main.h"
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 static void ccker (double *u, double s) {
00052 double s2, s3;
00053
00054 s2= s * s;
00055 s3= s2 * s;
00056 u[0] = s2 - 0.5 * (s3 + s);
00057 u[1] = 1.5*s3 - 2.5*s2 + 1.0;
00058 u[2] = -1.5*s3 + 2.0*s2 + 0.5*s;
00059 u[3] = 0.5 * (s3 - s2);
00060 }
00061
00062
00063 float ccint2 (float *f, int nx, int ny, double x, double y) {
00064 double ux[4], uy[4];
00065 double sum;
00066 int ix, iy, ix1, iy1, i, j;
00067
00068 if (x < 1. || x >= (float)(nx-2) || y < 1. || y >= (float)(ny-2))
00069 return DRMS_MISSING_FLOAT;
00070
00071 ix = (int)x;
00072 ccker (ux, x - (double)ix);
00073 iy = (int)y;
00074 ccker (uy, y - (double)iy);
00075
00076 ix1 = ix - 1;
00077 iy1 = iy - 1;
00078 sum = 0.;
00079 for (i = 0; i < 4; i++)
00080 for (j = 0; j < 4; j++)
00081 sum = sum + f[(iy1+i) * nx + ix1 + j] * uy[i] * ux[j];
00082 return (float)sum;
00083 }
00084
00085 double ccint2d (double *f, int nx, int ny, double x, double y) {
00086 double ux[4], uy[4];
00087 double sum;
00088 int ix, iy, ix1, iy1, i, j;
00089
00090 if (x < 1. || x >= (float)(nx-2) || y < 1. || y >= (float)(ny-2))
00091 return DRMS_MISSING_FLOAT;
00092
00093 ix = (int)x;
00094 ccker (ux, x - (double)ix);
00095 iy = (int)y;
00096 ccker (uy, y - (double)iy);
00097
00098 ix1 = ix - 1;
00099 iy1 = iy - 1;
00100 sum = 0.;
00101 for (i = 0; i < 4; i++)
00102 for (j = 0; j < 4; j++)
00103 sum = sum + f[(iy1+i) * nx + ix1 + j] * uy[i] * ux[j];
00104 return sum;
00105 }
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 float linint2 (float *f, int nx, int ny, double x, double y) {
00121
00122 double p0, p1, q0, q1;
00123 int ilow, jlow;
00124 float *fptr;
00125 double u;
00126
00127 ilow = floor (x);
00128 jlow = floor (y);
00129 if (ilow < 0) ilow = 0;
00130 if (ilow+1 >= nx) ilow -= 1;
00131 if (jlow < 0) jlow = 0;
00132 if (jlow+1 >= ny) jlow -= 1;
00133 p1 = x - ilow;
00134 p0 = 1.0 - p1;
00135 q1 = y - jlow;
00136 q0 = 1.0 - q1;
00137
00138 u = 0.0;
00139 fptr = f + jlow*nx + ilow;
00140 u += p0 * q0 * *fptr++;
00141 u += p1 * q0 * *fptr;
00142 fptr += nx - 1;
00143 u += p0 * q1 * *fptr++;
00144 u += p1 * q1 * *fptr;
00145 return (float)u;
00146 }
00147
00148 double linint2d (double *f, int nx, int ny, double x, double y) {
00149
00150 double p0, p1, q0, q1;
00151 int ilow, jlow;
00152 double *fptr;
00153 double u;
00154
00155 ilow = floor (x);
00156 jlow = floor (y);
00157 if (ilow < 0) ilow = 0;
00158 if (ilow+1 >= nx) ilow -= 1;
00159 if (jlow < 0) jlow = 0;
00160 if (jlow+1 >= ny) jlow -= 1;
00161 p1 = x - ilow;
00162 p0 = 1.0 - p1;
00163 q1 = y - jlow;
00164 q0 = 1.0 - q1;
00165
00166 u = 0.0;
00167 fptr = f + jlow*nx + ilow;
00168 u += p0 * q0 * *fptr++;
00169 u += p1 * q0 * *fptr;
00170 fptr += nx - 1;
00171 u += p0 * q1 * *fptr++;
00172 u += p1 * q1 * *fptr;
00173 return u;
00174 }
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198