IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 18, 2005, 6:16:02 PM (21 years ago)
Author:
gusciora
Message:

Created tests for inverting linear psPlaneTransforms. Fixed a bug with the
linear transform inversion code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/astronomy/tst_psAstrometry01.c

    r3710 r3714  
    55*  @author GLG, MHPCC
    66*
    7 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    8 *  @date $Date: 2005-04-19 01:22:23 $
     7*  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2005-04-19 04:16:02 $
    99*
    1010* XXX: Must test
     
    828828
    829829/******************************************************************************
    830 XXX: This is only a rudimentary test of the psPlaneTransform()
     830XXX: This is only a rudimentary test of the psPlaneTransformInvert()
    831831function.  It tests a few NULL input parameter conditions.
    832832 
     
    844844    //
    845845    trans->x->coeff[0][0] = 1.0;
    846     trans->x->coeff[0][1] = 1.0;
    847     trans->x->coeff[1][0] = 1.0;
     846    trans->x->coeff[0][1] = 3.0;
     847    trans->x->coeff[1][0] = 2.0;
    848848    trans->x->coeff[1][1] = 1.0;
    849     trans->y->coeff[0][0] = 1.0;
    850     trans->y->coeff[0][1] = 1.0;
    851     trans->y->coeff[1][0] = 1.0;
     849    trans->y->coeff[0][0] = 4.0;
     850    trans->y->coeff[0][1] = 6.0;
     851    trans->y->coeff[1][0] = 5.0;
    852852    trans->y->coeff[1][1] = 1.0;
    853853
     
    878878    }
    879879
    880     printf("----------------------------------------------------------------------------------\n");
    881     printf("Calling psPlaneTransformInvert with acceptable data.\n");
    882     transOut = psPlaneTransformInvert(NULL, trans, myRegion, 10);
    883     if (transOut == NULL) {
    884         printf("TEST ERROR: psPlaneTransformInvert() returned a NULL psPlaneTransform.\n");
    885         testStatus = false;
     880    printf("Calling psPlaneTransformInvert with an acceptable linear transformation.\n");
     881    for (psS32 n = 0 ; n < 100 ; n++) {
     882        //
     883        // We create a random linear transformation and hope it is invertible.
     884        //
     885        trans->x->coeff[0][0] = ((psF32) (random() % 1000000)) / 100000.0;
     886        trans->x->coeff[0][1] = ((psF32) (random() % 1000000)) / 100000.0;
     887        trans->x->coeff[1][0] = ((psF32) (random() % 1000000)) / 100000.0;
     888        trans->x->coeff[1][1] = 0.1;
     889        trans->y->coeff[0][0] = ((psF32) (random() % 1000000)) / 100000.0;
     890        trans->y->coeff[0][1] = ((psF32) (random() % 1000000)) / 100000.0;
     891        trans->y->coeff[1][0] = ((psF32) (random() % 1000000)) / 100000.0;
     892        trans->y->coeff[1][1] = 0.1;
     893
     894        transOut = psPlaneTransformInvert(NULL, trans, myRegion, 10);
     895        if (transOut == NULL) {
     896            printf("TEST ERROR: psPlaneTransformInvert() returned a NULL psPlaneTransform.\n");
     897            testStatus = false;
     898        }
     899        psPlane *in = psPlaneAlloc();
     900        in->x = 2.0;
     901        in->y = 3.0;
     902
     903        psPlane *mid = psPlaneTransformApply(NULL, trans, in);
     904        psPlane *out = psPlaneTransformApply(NULL, transOut, mid);
     905
     906        if (((fabs(in->x - out->x) > FLT_EPSILON)) ||
     907                ((fabs(in->y - out->y) > FLT_EPSILON))) {
     908            printf("TEST ERROR: in coords were (%f, %f), out coords were (%f, %f).\n",
     909                   in->x, in->y, out->x, out->y);
     910            testStatus = false;
     911        }
     912
     913        psFree(in);
     914        psFree(mid);
     915        psFree(out);
     916        psFree(transOut);
    886917    }
    887918
    888919    psFree(trans);
    889     psFree(transOut);
    890920    psFree(myRegion);
    891921
    892922    return(!testStatus);
    893923}
     924//This code will
Note: See TracChangeset for help on using the changeset viewer.