IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 7, 2005, 4:04:22 PM (21 years ago)
Author:
Paul Price
Message:

Using autoconf; some bug fixes to the polynomial order

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/stac/src/stacWrite.c

    r5743 r5745  
    44#include "stac.h"
    55
    6 bool stacWriteMap(const char *mapName,  // Filename to write to
    7                   psPlaneTransform *map // Map to write
     6bool stacWriteMap(const char *mapName,  // Filename to write to
     7                  psPlaneTransform *map // Map to write
    88    )
    99{
     
    1212    FILE *mapFile = fopen(mapName, "w");
    1313    if (!mapFile) {
    14         fprintf(stderr, "Unable to open map file: %s\n", mapName);
    15         return false;
     14        fprintf(stderr, "Unable to open map file: %s\n", mapName);
     15        return false;
    1616    }
    1717
    18     psPolynomial2D *xMap = map->x;      // x transform
    19     psPolynomial2D *yMap = map->y;      // y transform
     18    psPolynomial2D *xMap = map->x;      // x transform
     19    psPolynomial2D *yMap = map->y;      // y transform
    2020
    2121    // A crucial limitation of the current system --- the order of each polynomial must be the same
    2222    assert(xMap->nX == xMap->nY && yMap->nX == yMap->nY && xMap->nX == yMap->nX);
    23     int order = xMap->nX;       // The polynomial order
     23    int order = xMap->nX;       // The polynomial order
    2424    fprintf(mapFile, "%d\n", order);
    25    
     25
    2626    // x coefficients
    27     for (int k = 0; k < order + 1; k++) {
    28         for (int j = 0; j < k + 1; j++) {
    29             int i = k - j;
    30             if (xMap->mask[i][j]) {
    31                 fprintf(mapFile, "0.0 ");
    32             } else {
    33                 fprintf(mapFile, "%g ", xMap->coeff[i][j]);
    34             }
    35         }
     27    for (int k = 0; k <= order; k++) {
     28        for (int j = 0; j <= k; j++) {
     29            int i = k - j;
     30            if (xMap->mask[i][j]) {
     31                fprintf(mapFile, "0.0 ");
     32            } else {
     33                fprintf(mapFile, "%g ", xMap->coeff[i][j]);
     34            }
     35        }
    3636    }
    3737    fprintf(mapFile, "\n");
    3838
    3939    // y coefficients
    40     for (int k = 0; k < order + 1; k++) {
    41         for (int j = 0; j < k + 1; j++) {
    42             int i = k - j;
    43             if (yMap->mask[i][j]) {
    44                 fprintf(mapFile, "0.0 ");
    45             } else {
    46                 fprintf(mapFile, "%g ", yMap->coeff[i][j]);
    47             }
    48         }
     40    for (int k = 0; k <= order; k++) {
     41        for (int j = 0; j <= k; j++) {
     42            int i = k - j;
     43            if (yMap->mask[i][j]) {
     44                fprintf(mapFile, "0.0 ");
     45            } else {
     46                fprintf(mapFile, "%g ", yMap->coeff[i][j]);
     47            }
     48        }
    4949    }
    5050    fprintf(mapFile, "\n");
    51    
     51
    5252    fclose(mapFile);
    5353
     
    5757
    5858bool stacWriteMaps(const psArray *names, // Filenames of the input images (will add ".map")
    59                    const psArray *maps  // Maps to write
     59                   const psArray *maps  // Maps to write
    6060    )
    6161{
     
    6565
    6666    for (int i = 0; i < names->n; i++) {
    67         char mapName[MAXCHAR];          // Filename of error image
    68         sprintf(mapName, "%s.map", names->data[i]);
    69         if (!stacWriteMap(mapName, maps->data[i])) {
    70             return false;
    71         }
     67        char mapName[MAXCHAR];          // Filename of error image
     68        sprintf(mapName, "%s.map", (const char*)names->data[i]);
     69        if (!stacWriteMap(mapName, maps->data[i])) {
     70            return false;
     71        }
    7272    }
    7373
Note: See TracChangeset for help on using the changeset viewer.