IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

Added test for PlaneTransformDeriv in Coord02

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.