IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5559


Ignore:
Timestamp:
Nov 21, 2005, 9:53:01 AM (21 years ago)
Author:
gusciora
Message:

I added a psProject->psDeproject test which seems to demonstrate a bug here.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/astro/tst_psCoord01.c

    r5095 r5559  
    66*    @author Eric Van Alst, MHPCC
    77*
    8 *    @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *    @date  $Date: 2005-09-22 22:24:58 $
     8*    @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9*    @date  $Date: 2005-11-21 19:53:01 $
    1010*
    1111*    Copyright 2005 Maui High Performance Computing Center, Univ. of Hawaii
     
    3030static psS32 testGetOffsetSphere(void);
    3131static psS32 testGetOffsetLinear(void);
     32static psS32 testProjectTanDeProjectTan(void);
    3233
    3334testDescription tests[] = {
     
    4748                              {testGetOffsetSphere, 0000, "psSphereGetOffset",0,false},
    4849                              {testGetOffsetLinear, 0000, "psSphereGetOffset",0,false},
     50                              {testProjectTanDeProjectTan, 0000, "psProject(TAN) -> psDeproject(TAN)",0,false},
    4951                              {NULL}
    5052                          };
     
    198200    return 0;
    199201}
    200 
     202//HEY
    201203psS32 testProjectTan(void)
    202204{
    203205    psPlane*       out = NULL;
    204206    psSphere*      in = psSphereAlloc();
     207    psSphere*      inTest = NULL;
    205208    psProjection*  myProjection = psProjectionAlloc(0.0,0.0,1.0,1.0,PS_PROJ_TAN);
    206209
     
    218221        // Perform projection
    219222        out = psProject(in, myProjection);
     223        inTest = psDeproject(out, myProjection);
    220224
    221225        // Verify output not NULL
     
    236240            return i*10+2;
    237241        }
     242
     243        // Verify output is as expected
     244        if(fabs(in->r - inTest->r) > ERROR_TOL) {
     245            printf("TEST ER (in->r, inTest->r) (%.2f %.2f)\n", in->r, inTest->r);
     246            return i*10+1;
     247        }
     248        if(fabs(in->d - inTest->d) > ERROR_TOL) {
     249            printf("TEST ERROR: (in->d, inTest->d) (%.2f %.2f)\n", in->d, inTest->d);
     250            return i*10+1;
     251        }
     252
     253        psFree(inTest);
    238254        psFree(out);
    239255    }
     
    916932}
    917933
    918 
     934#define DEG_INC2 15.0
     935#define VERBOSE 0
     936psS32 testProjectTanDeProjectTan()
     937{
     938    psS32 rc = 0;
     939    //
     940    // I'm not convinced that the p_psProject() and p_psDeproject() functions work
     941    // correctly.  If we project a set of coordinates over a wide range of (R, D)
     942    // values, then deproject them, the original (R, D) values are only produced
     943    // when D is larger than 0.  This code demonstrates that.
     944    //
     945    psProjection *tmpProj = psProjectionAlloc(0.0,0.0,10.0,10.0,PS_PROJ_TAN);
     946    if (1) { //HEY
     947        psPlane planeCoord01;
     948        psSphere skyCoord01;
     949        psSphere skyCoord02;
     950        for (psF32 R = -90.0 ; R <= 90.0 ; R+= DEG_INC2) {
     951            for (psF32 D = -90.0 ; D <= 90.0 ; D+= DEG_INC2) {
     952                if ((fabs(R) != 90.0) && (fabs(D) != 90.0)) {
     953                    skyCoord01.r = DEG_TO_RAD(R);
     954                    skyCoord01.d = DEG_TO_RAD(D);
     955                    p_psProject(&planeCoord01, &skyCoord01, tmpProj);
     956                    p_psDeproject(&skyCoord02, &planeCoord01, tmpProj);
     957                    if ((fabs(skyCoord01.r - skyCoord02.r) < FLT_EPSILON) &&
     958                            (fabs(skyCoord01.d - skyCoord02.d) < FLT_EPSILON)) {
     959                        if (VERBOSE) {
     960                            printf("CORRECT: (%.2fr %.2fd) (%.2fr %.2fd) -> (%.2f %.2f) -> (%.2fr %.2fd)\n", R, D,
     961                                   skyCoord01.r, skyCoord01.d,
     962                                   planeCoord01.x, planeCoord01.y,
     963                                   skyCoord02.r, skyCoord02.d);
     964                        }
     965                        rc = 1;
     966                    } else {
     967                        printf("TEST ERROR: (%.2fr %.2fd) (%.2fr %.2fd) -> (%.2f %.2f) -> (%.2fr %.2fd)\n", R, D,
     968                               skyCoord01.r, skyCoord01.d,
     969                               planeCoord01.x, planeCoord01.y,
     970                               skyCoord02.r, skyCoord02.d);
     971                        rc = 1;
     972                    }
     973                }
     974            }
     975        }
     976    }
     977    return(rc);
     978}
     979
     980
     981
Note: See TracChangeset for help on using the changeset viewer.