/* This routine uses the LTV and LTM keyword values to compute the corner location and pixel size. For the MAMA detectors, the corner location and pixel size are in units of high-res pixels, in contrast to the header keywords CENTERA1, SIZAXIS1, etc. ltm[0] and ltm[1] are assumed to be greater than zero. */ # define NINT(x) ((x >= 0.) ? (int) (x + 0.5) : (int) (x - 0.5)) int FromLT (int rsize, double *ltm, double *ltv, int *bin, int *corner) { /* arguments: int rsize i: reference pixel size, 1 or 2 double ltm[2] i: diagonal elements of MWCS matrix double ltv[2] i: MWCS linear transformation vector int bin[2] o: pixel size in X and Y int corner[2] o: corner of subarray in X and Y */ double dbinx, dbiny, dxcorner, dycorner; dbinx = (double)rsize / ltm[0]; dbiny = (double)rsize / ltm[1]; dxcorner = (dbinx - rsize) / 2. - dbinx * ltv[0]; dycorner = (dbiny - rsize) / 2. - dbiny * ltv[1]; /* Round off to the nearest integer. */ corner[0] = NINT (dxcorner); corner[1] = NINT (dycorner); bin[0] = NINT (dbinx); bin[1] = NINT (dbiny); return (0); }