IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 4, 2005, 11:37:01 AM (21 years ago)
Author:
Paul Price
Message:

Updated to psLib rel5alpha1

File:
1 edited

Legend:

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

    r2897 r3375  
    11#include <stdio.h>
     2#include <assert.h>
    23#include "pslib.h"
    34#include "stac.h"
     
    2425        psPlaneTransform *oldMap = (psPlaneTransform*)maps->data[mapNum]; // Uninverted map
    2526        // Check input
    26         if (oldMap->x->nX != oldMap->x->nY) {
    27             psError("stac.invertMaps", "Polynomial order in x and y don't match for map %d\n", mapNum);
    28             return NULL;
    29         }
    30         if (oldMap->y->nX != oldMap->y->nY) {
    31             psError("stac.invertMaps", "Polynomial order in x and y don't match for map %d\n", mapNum);
    32             return NULL;
    33         }
    34         if (oldMap->x->nX != oldMap->y->nX) {
    35             psError("stac.invertMaps", "Polynomial order in x and y don't match for map %d\n", mapNum);
    36             return NULL;
    37         }
     27        assert(oldMap->x->nX == oldMap->x->nY && oldMap->y->nX == oldMap->y->nY &&
     28               oldMap->x->nX == oldMap->y->nX);
    3829        int order = oldMap->x->nX;      // Polynomial order
    3930        psTrace("stac.invertMaps", 4, "Generating order %d polynomial inverse transformation.\n", order);
     
    9182
    9283                    fakePoly->mask[i][j] = 0;
    93                     double ijPoly = psDPolynomial2DEval(xIn->data.F32[g], yIn->data.F32[g], fakePoly);
     84                    double ijPoly = psDPolynomial2DEval(fakePoly, xIn->data.F32[g], yIn->data.F32[g]);
    9485                    fakePoly->mask[i][j] = 1;
    9586
     
    9889                           
    9990                            fakePoly->mask[m][n] = 0;
    100                             double mnPoly = psDPolynomial2DEval(xIn->data.F32[g], yIn->data.F32[g], fakePoly);
     91                            double mnPoly = psDPolynomial2DEval(fakePoly, xIn->data.F32[g], yIn->data.F32[g]);
    10192                            fakePoly->mask[m][n] = 1;
    10293
     
    113104        // Solution via LU Decomposition
    114105        psVector *permutation = psVectorAlloc(nCoeff, PS_TYPE_F64); // Permutation vector for LU Decomposition
    115         psImage *luMatrix = psMatrixLUD(NULL, permutation, matrix); // LU decomposed matrix
     106        psImage *luMatrix = psMatrixLUD(NULL, &permutation, matrix); // LU decomposed matrix
    116107        psVector *xSolution = psMatrixLUSolve(NULL, luMatrix, xVector, permutation); // Solution in x
    117108        psVector *ySolution = psMatrixLUSolve(NULL, luMatrix, yVector, permutation); // Solution in y
     
    178169#if 0
    179170        // Can't handle higher order than linear yet
    180         if (((psPlaneTransform*)maps->data[i])->x->nX != 2 ||
    181             ((psPlaneTransform*)maps->data[i])->x->nY != 2 ||
    182             ((psPlaneTransform*)maps->data[i])->y->nX != 2 ||
    183             ((psPlaneTransform*)maps->data[i])->y->nY != 2) {
    184             psError("stac.invertMaps",
    185                     "STAC cannot currently support orders other than linear.\n");
    186             psFree(inverted);
    187             return NULL;
    188         }
    189 
     171        assert(((psPlaneTransform*)maps->data[i])->x->nX == 2 &&
     172               ((psPlaneTransform*)maps->data[i])->x->nY == 2 &&
     173               ((psPlaneTransform*)maps->data[i])->y->nX == 2 &&
     174               ((psPlaneTransform*)maps->data[i])->y->nY == 2);
    190175        psPlaneTransform *newMap = psPlaneTransformAlloc(2, 2); // Inverted map
    191176        psPlaneTransform *oldMap = (psPlaneTransform*)maps->data[i]; // Uninverted map
Note: See TracChangeset for help on using the changeset viewer.