140 double x = point[0]+ fXoffset;
146 double xfraction = (x - minx) / dx;
147 double yfraction = (y - miny) / dy;
148 double zfraction = (z - minz) / dz;
150 if (invertX) { xfraction = 1 - xfraction;}
151 if (invertY) { yfraction = 1 - yfraction;}
152 if (invertZ) { zfraction = 1 - zfraction;}
156 double xdindex, ydindex, zdindex;
160 double xlocal = ( std::modf(xfraction*(nx-1), &xdindex));
161 double ylocal = ( std::modf(yfraction*(ny-1), &ydindex));
162 double zlocal = ( std::modf(zfraction*(nz-1), &zdindex));
166 int xindex =
static_cast<int>(std::floor(xdindex));
167 int yindex =
static_cast<int>(std::floor(ydindex));
168 int zindex =
static_cast<int>(std::floor(zdindex));
171 if ((xindex < 0) || (xindex >= nx - 1) ||
172 (yindex < 0) || (yindex >= ny - 1) ||
173 (zindex < 0) || (zindex >= nz - 1))
182 #ifdef DEBUG_INTERPOLATING_FIELD
183 G4cout <<
"Local x,y,z: " << xlocal <<
" " << ylocal <<
" " << zlocal << endl;
184 G4cout <<
"Index x,y,z: " << xindex <<
" " << yindex <<
" " << zindex << endl;
185 double valx0z0, mulx0z0, valx1z0, mulx1z0;
186 double valx0z1, mulx0z1, valx1z1, mulx1z1;
187 valx0z0= table[xindex ][0][zindex]; mulx0z0= (1-xlocal) * (1-zlocal);
188 valx1z0= table[xindex+1][0][zindex]; mulx1z0= xlocal * (1-zlocal);
189 valx0z1= table[xindex ][0][zindex+1]; mulx0z1= (1-xlocal) * zlocal;
190 valx1z1= table[xindex+1][0][zindex+1]; mulx1z1= xlocal * zlocal;
195 xField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
196 xField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
197 xField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
198 xField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
199 xField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
200 xField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
201 xField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
202 xField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
205 yField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
206 yField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
207 yField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
208 yField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
209 yField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
210 yField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
211 yField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
212 yField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
215 zField[xindex ][yindex ][zindex ] * (1-xlocal) * (1-ylocal) * (1-zlocal) +
216 zField[xindex ][yindex ][zindex+1] * (1-xlocal) * (1-ylocal) * zlocal +
217 zField[xindex ][yindex+1][zindex ] * (1-xlocal) * ylocal * (1-zlocal) +
218 zField[xindex ][yindex+1][zindex+1] * (1-xlocal) * ylocal * zlocal +
219 zField[xindex+1][yindex ][zindex ] * xlocal * (1-ylocal) * (1-zlocal) +
220 zField[xindex+1][yindex ][zindex+1] * xlocal * (1-ylocal) * zlocal +
221 zField[xindex+1][yindex+1][zindex ] * xlocal * ylocal * (1-zlocal) +
222 zField[xindex+1][yindex+1][zindex+1] * xlocal * ylocal * zlocal ;
G4GLOB_DLL std::ostream G4cout