IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6253


Ignore:
Timestamp:
Jan 30, 2006, 12:56:01 PM (20 years ago)
Author:
drobbin
Message:

Added test for PlaneTransformDeriv in Coord02

Location:
trunk/psLib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psCoord.c

    r6251 r6253  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.103 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-01-30 20:28:33 $
     12*  @version $Revision: 1.104 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-01-30 22:56:01 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    10881088        //XXX: Should the length (nalloc) be 1 and append be used everytime a pixel is added?
    10891089        //        out = psPixelsAlloc(input->nalloc);
    1090         out = psPixelsAlloc(1);
     1090        out = psPixelsAlloc(0);
    10911091    }
    10921092    psPlane *coord = psPlaneAlloc();
  • trunk/psLib/test/astro/tst_psCoord.c

    r6251 r6253  
    66*  @author GLG, MHPCC
    77*
    8 *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2006-01-30 20:28:34 $
     8*  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2006-01-30 22:56:01 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    396396    }
    397397
    398     input = psPixelsAlloc(5);
     398    input = psPixelsAlloc(1);
    399399    /*    for (int i = 0; i < 2; i++) {
    400400            input->data[i].x = i*1.0;
     
    403403    */
    404404    input->data[0].x = 1.0;
    405     input->data[0].y = 2.0;
    406     input->data[1].x = 1.0;
    407     input->data[1].y = 3.0;
    408     trans->x->nX = 1;
     405    input->data[0].y = 1.0;
     406    //    input->data[1].x = 1.0;
     407    //    input->data[1].y = 6.0;
     408    trans->x->nX = 2;
    409409    trans->x->nY = 0;
    410     trans->y->nX = 1;
    411     trans->y->nY = 0;
     410    trans->y->nX = 0;
     411    trans->y->nY = 2;
    412412    trans->x->coeff[0][0] = 0;
    413     trans->x->coeff[1][0] = 1;
     413    trans->x->coeff[1][0] = 1.0;
    414414    trans->y->coeff[0][0] = 0;
    415     trans->y->coeff[1][0] = 2;
     415    trans->y->coeff[0][0] = 0;
     416    trans->y->coeff[0][2] = 0.5;
    416417
    417418    //Verify that the output pixels are what we expected
    418419    output = psPixelsTransform(output, input, trans);
    419     printf("\n output return %ld pixels\n\n", output->n);
    420     int nExpected = 1;
     420    printf("\n output returned with %ld pixels\n\n", output->n);
     421    int nExpected = 9;
    421422    if (output->n != nExpected) {
    422423        psError(PS_ERR_BAD_PARAMETER_SIZE, false,
    423424                "psPixelsTransform failed to return the expected number of pixels.\n");
     425        for (int i = 0; i < output->n; i++) {
     426            printf("  (%6.2lf, %6.2lf) pixel %d\n", output->data[i].x, output->data[i].y, i);
     427        }
    424428        return 3;
    425429    }
    426430
     431    psFree(trans);
    427432    psFree(input);
    428433    psFree(output);
    429     psFree(trans);
    430434
    431435    return 0;
  • trunk/psLib/test/astro/tst_psCoord02.c

    r5580 r6253  
    66*  @author GLG, MHPCC
    77*
    8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-11-23 01:03:18 $
     8*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2006-01-30 22:56:01 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1818static psS32 test05( void );
    1919static psS32 test06( void );
     20static psS32 test07( void );
    2021
    2122testDescription tests[] = {
    22                               {test04, 0000, "psPlaneTransformCombine()", 0, false},
    23                               {test05, 0000, "psPlaneTransformFit()", 0, false},
    24                               {test06, 0000, "psPlaneTransformInvert()", 0, false},
     23                              {test04, 660, "psPlaneTransformCombine()", 0, false},
     24                              {test05, 662, "psPlaneTransformFit()", 0, false},
     25                              {test06, 663, "psPlaneTransformInvert()", 0, false},
     26                              {test07, 666, "psPlaneTransformDeriv()", 0, false},
    2527                              {NULL}
    2628                          };
     
    505507}
    506508
    507 
     509psS32 test07( void )
     510{
     511    psPlane *coord = psPlaneAlloc();
     512    psPlane *deriv = NULL;
     513    psPlaneTransform *trans = NULL;
     514
     515    //Set fxn values for evaluation
     516    coord->x = 1.0;
     517    coord->y = 1.0;
     518
     519    //Return NULL for NULL input plane transform
     520    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     521    deriv = psPlaneTransformDeriv(NULL, trans, coord);
     522    if (deriv != NULL) {
     523        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     524                "psPlaneTransformDeriv failed to return NULL for NULL plane transform input.\n");
     525        return 1;
     526    }
     527
     528    trans = psPlaneTransformAlloc(1, 2);
     529
     530    //Set Polynomials.  f(x) = x, f(y) = 0.5*y^2  -->  f'(x) = 1, f'(y) = y
     531    //So for 1,1  -> f'(1) = 1, f'(1) = 1
     532    trans->x->nX = 1;
     533    trans->x->nY = 0;
     534    trans->y->nX = 0;
     535    trans->y->nY = 2;
     536
     537    trans->x->coeff[0][0] = 0.0;
     538    trans->x->coeff[1][0] = 1.0;
     539
     540    trans->y->coeff[0][0] = 0.0;
     541    trans->y->coeff[0][1] = 0.0;
     542    trans->y->coeff[0][2] = 0.5;
     543
     544    //Return NULL for NULL input plane
     545    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     546    deriv = psPlaneTransformDeriv(NULL, trans, NULL);
     547    if (deriv != NULL) {
     548        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     549                "psPlaneTransformDeriv failed to return NULL for NULL plane input.\n");
     550        return 2;
     551    }
     552
     553    //Return correct values.  Should have x=1.0, y=1.0.
     554    deriv = psPlaneTransformDeriv(NULL, trans, coord);
     555    if (deriv->x != 1.0 || deriv->y != 1.0) {
     556        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     557                "psPlaneTransformDeriv failed to return the correct values.\n");
     558        printf("\n f' values are = %lf, %lf \n", deriv->x, deriv->y);
     559        //        return 3;
     560    }
     561
     562    psFree(trans);
     563    psFree(deriv);
     564    psFree(coord);
     565
     566    return 0;
     567}
     568
Note: See TracChangeset for help on using the changeset viewer.