/* * Initialize single point interpolation mode. This just * does the regridding initialization and initial data analysis. */ void c_nnpntinitd(int n, double x[], double y[], double z[]) { #define NXI 2 #define NYI 2 double xi[NXI], yi[NYI], wtmp; single_point = 1; first_single = 1; asflag = 0; horilap_save = horilap; vertlap_save = vertlap; horilap = -1.; vertlap = -1.; /* * Establish the gridded region to contain all of the input * data points plus an extra 10% space around the border. */ xi[0] = armind(n, x); xi[1] = armaxd(n, x); wtmp = xi[1] - xi[0]; xi[0] -= 0.1*wtmp; xi[1] += 0.1*wtmp; yi[0] = armind(n, y); yi[1] = armaxd(n, y); wtmp = yi[1] - yi[0]; yi[0] -= 0.1*wtmp; yi[1] += 0.1*wtmp; Initialized(n, x, y, NXI, NYI, xi, yi); if (ReadDatad(n,x,y,z) != 0) { ErrorHnd(error_status, "c_nnpntinitd", filee, "\n"); } }
void Initialized(int n, double x[], double y[], int nxi, int nyi, double xi[], double yi[]) { double xil, xir, yib, yit; /* * Reserve memory for returning natural neighbor indices * and associated weights when requested in single point * mode for linear interpolation. */ nbrs = (int *) calloc(n,sizeof(int)); wts = (double *) calloc(n,sizeof(double)); error_status = 0; datcnt = 0; magx_orig = magx; magy_orig = magy; magz_orig = magz; iscale = 0; magx_auto = 1.; magy_auto = 1.; magz_auto = 1.; /* * Find the limits of the output array. */ xstart = armind(nxi, xi); xend = armaxd(nxi, xi); ystart = armind(nyi, yi); yend = armaxd(nyi, yi); /* * Find the limits of the input array. */ xil = armind(n, x); xir = armaxd(n, x); yib = armind(n, y); yit = armaxd(n, y); /* * As the default (that is, unless horizontal and vertical overlaps * have been specifically set by the user) choose the overlap values * as the smallest values that will make all input data points included * in the overlap region. */ if (horilap EQ -1.) { if ( (xstart >= xil) && (xend <= xir) ) { horilap = 1.01 * (((xstart-xil) < (xir-xend)) ? (xir-xend) : (xstart-xil)); } else if ( (xstart >= xil) && (xend >= xir) ) { horilap = 1.01 * (xstart-xil); } else if ( (xstart <= xil) && (xend <= xir) ) { horilap = 1.01 * (xir-xend); } else if ( (xstart <= xil) && (xir <= xend) ) { horilap = 0.; } } if (horilap <= EPSILON) { horilap = 0.01 * (xend - xstart); } if (vertlap EQ -1.) { if ( (yib <= ystart) && (yend <= yit) ) { vertlap = 1.01 * (((ystart-yib) < (yit-yend)) ? (yit-yend) : (ystart-yib)); } else if ( (ystart <= yib) && (yend <= yit) ) { vertlap = 1.01 * (yit-yend); } else if ( (yib <= ystart) && (yit <= yend) ) { vertlap = 1.01 * (ystart-yib); } else if ( (ystart <= yib) && (yit <= yend) ) { vertlap = 0.; } } if (vertlap <= EPSILON) { vertlap = 0.01 * (yend - ystart); } }