IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 7, 2005, 5:51:20 PM (21 years ago)
Author:
drobbin
Message:

Implemented and fixed/tested ImageGrowMask

File:
1 edited

Legend:

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

    r5235 r5254  
    66*  @author GLG, MHPCC
    77*
    8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-10-07 21:27:50 $
     8*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-10-08 03:51:20 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4848#define ERROR_TOL   0.0001
    4949
    50 #define ALPHA_P 1.0
    51 #define DELTA_P 2.0
    52 #define PHI_P 3.0
     50#define ALPHA_P 0.5 * M_PI
     51#define DELTA_P 1.0 * M_PI
     52#define PHI_P 1.5 * M_PI
    5353
    5454psS32 testSphereRotAlloc( void )
     
    6363    }
    6464    // Verify sin member is updated
    65     //    double vx = cos(DELTA_P)*cos(ALPHA_P);
    66     //    double vy = cos(DELTA_P)*sin(ALPHA_P);
    67     //    double vz = sin(DELTA_P);
    68     //    double q0 = vx * sin(PHI_P/2.0);
    69     //    double q1 = vy * sin(PHI_P/2.0);
    70     //    double q2 = vz * sin(PHI_P/2.0);
    71     //    double q3 = cos(PHI_P/2.0);
    72     /*
    73         if (FLT_EPSILON < fabs(q0 - myST->q0)) {
    74             psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0);
    75             return 2;
    76         }
    77         if (FLT_EPSILON < fabs(q1 - myST->q1)) {
    78             psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1);
    79             return 3;
    80         }
    81         if (FLT_EPSILON < fabs(q2 - myST->q2)) {
    82             psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2);
    83             return 4;
    84         }
    85         if (FLT_EPSILON < fabs(q3 - myST->q3)) {
    86             psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3);
    87             return 5;
    88         }
    89     */
     65    double vx = cos(DELTA_P)*cos(ALPHA_P);
     66    double vy = cos(DELTA_P)*sin(ALPHA_P);
     67    double vz = sin(DELTA_P);
     68    double q0 = vx * sin(PHI_P/2.0);
     69    double q1 = vy * sin(PHI_P/2.0);
     70    double q2 = vz * sin(PHI_P/2.0);
     71    double q3 = cos(PHI_P/2.0);
     72    double len = sqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3);
     73    printf("\nvz = %lf\n", vz);
     74    q0 = q0/len;
     75    q1 = q1/len;
     76    q2 = q2/len;
     77    q3 = q3/len;
     78
     79    if (FLT_EPSILON < fabs(q0 - myST->q0)) {
     80        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0);
     81        return 2;
     82    }
     83    if (FLT_EPSILON < fabs(q1 - myST->q1)) {
     84        psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1);
     85        return 3;
     86    }
     87    if (FLT_EPSILON < fabs(q2 - myST->q2)) {
     88        psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2);
     89        return 4;
     90    }
     91    if (FLT_EPSILON < fabs(q3 - myST->q3)) {
     92        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3);
     93        return 5;
     94    }
     95
    9096    // Free data structure
    9197    psFree(myST);
     
    103109        psSphere *rc = NULL;
    104110        psSphereRot *myST = psSphereRotAlloc(0.0, 0.0, 0.0);
    105      
     111
    106112        for (float r=0.0;r<180.0;r+=DEG_INC) {
    107113            for (float d=0.0;d<90.0;d+=DEG_INC) {
     
    110116                in->rErr = 0.0;
    111117                in->dErr = 0.0;
    112      
     118
    113119                if(psSphereRotApply(out, myST, in) != out) {
    114120                    psError(PS_ERR_UNKNOWN,true,"Did not return output pointer.");
     
    125131            }
    126132        }
    127      
     133
    128134        // Verify new sphere object is created if out parameter NULL
    129135        temp = psSphereRotApply(NULL, myST, in);
     
    133139        }
    134140        psFree(temp);
    135      
     141
    136142        // Verify NULL returned if transform structure null
    137143        psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
     
    141147            return 5;
    142148        }
    143      
     149
    144150        // Verify NULL returned when input sphere is NULL
    145151        psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
     
    149155            return 6;
    150156        }
    151      
     157
    152158        psFree(myST);
    153159        psFree(out);
     
    180186        psSphereRot *mySphereRotForward = NULL;
    181187        psSphereRot *mySphereRotReverse = NULL;
    182      
    183      
     188
     189
    184190        mySphereRotForward = psSphereRotAlloc(DEG_TO_RAD(22.0),
    185191                                              0.0,
     
    188194                                              0.0,
    189195                                              0.0);
    190      
     196
    191197        for (float r=0.1;r<180.0;r+=(DEG_INC/5.0)) {
    192198            for (float d=0.1;d<90.0;d+=(DEG_INC/5.0)) {
     
    195201                in.rErr = 0.0;
    196202                in.dErr = 0.0;
    197      
     203
    198204                psSphereRotApply(&out, mySphereRotForward, &in);
    199205                psSphereRotApply(&out2, mySphereRotReverse, &out);
    200      
     206
    201207                if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) ||
    202208                        (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) {
     
    210216        psFree(mySphereRotForward);
    211217        psFree(mySphereRotReverse);
    212      
     218
    213219        mySphereRotForward = psSphereRotAlloc(0.0,
    214220                                              DEG_TO_RAD(33.0),
     
    223229                in.rErr = 0.0;
    224230                in.dErr = 0.0;
    225      
     231
    226232                psSphereRotApply(&out, mySphereRotForward, &in);
    227233                psSphereRotApply(&out2, mySphereRotReverse, &out);
    228      
     234
    229235                if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) ||
    230236                        (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) {
     
    238244        psFree(mySphereRotForward);
    239245        psFree(mySphereRotReverse);
    240      
     246
    241247        return(testStatus);
    242248        */
     
    257263        double l[] =     { 96.337272, 122.93192, 195.639488};
    258264        double b[] =     {-60.188553,  27.12825,  78.353806};
    259      
     265
    260266        double t[] =     {  MJD_2000,  MJD_2000,   MJD_2100};
    261      
     267
    262268        double TOLERANCE = 0.001;
    263      
    264      
    265      
     269
     270
     271
    266272        for (int x = 0; x < numTestPoints; x++) {
    267      
     273
    268274            psTime* time = psTimeFromMJD(t[x]);
    269275            psSphereRot* toEcliptic = psSphereRotICRSToEcliptic(time);
     
    272278            psSphereRot* fromGalactic = psSphereRotGalacticToICRS();
    273279            psFree(time);
    274      
     280
    275281            // set the ICRS coordinate
    276282            psSphere* icrs = psSphereAlloc();
    277283            icrs->r = DEG_TO_RAD(alpha[x]);
    278284            icrs->d = DEG_TO_RAD(delta[x]);
    279      
     285
    280286            // apply/unapply Ecliptic
    281287            psSphere* ecliptic = psSphereRotApply(NULL, toEcliptic, icrs);
    282288            psSphere* icrsFromEcliptic = psSphereRotApply(NULL, fromEcliptic, ecliptic);
    283      
     289
    284290            // check ecliptic transforms for correctness
    285291            if (abs(RAD_TO_DEG(ecliptic->r) - lambda[x]) > TOLERANCE ||
     
    301307            psFree(ecliptic);
    302308            psFree(icrsFromEcliptic);
    303      
     309
    304310            // apply/unapply Galactic
    305311            psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs);
    306312            psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic);
    307      
     313
    308314            // check ecliptic transforms for correctness
    309315            if (abs(RAD_TO_DEG(galactic->r) - l[x]) > TOLERANCE ||
     
    325331            psFree(galactic);
    326332            psFree(icrsFromGalactic);
    327      
     333
    328334            psFree(toEcliptic);
    329335            psFree(fromEcliptic);
    330336            psFree(toGalactic);
    331337            psFree(fromGalactic);
    332      
     338
    333339        }
    334340    */
     
    356362        psTime*       fromTime    = psTimeFromMJD(MJD_2100);
    357363        psTime*       toTime      = psTimeFromMJD(MJD_1900);
    358      
     364
    359365        // Set input coordinate
    360366        inputCoord->r = SPHERE_PRECESS_TP1_R;
     
    362368        inputCoord->rErr = 0.0;
    363369        inputCoord->dErr = 0.0;
    364      
     370
    365371        // Calculate precess
    366372        outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
     
    382388        }
    383389        psFree(outputCoord);
    384      
     390
    385391        // Set input coordinate
    386392        inputCoord->r = SPHERE_PRECESS_TP2_R;
     
    388394        inputCoord->rErr = 0.0;
    389395        inputCoord->dErr = 0.0;
    390      
     396
    391397        // Calculate precess
    392398        outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
     
    408414        }
    409415        psFree(outputCoord);
    410      
     416
    411417        // Set input coordinate
    412418        inputCoord->r = SPHERE_PRECESS_TP3_R;
     
    414420        inputCoord->rErr = 0.0;
    415421        inputCoord->dErr = 0.0;
    416      
     422
    417423        // Calculate precess
    418424        outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
     
    434440        }
    435441        psFree(outputCoord);
    436      
     442
    437443        // Invoke precess with invalid parameter
    438444        psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     
    442448            return 10;
    443449        }
    444      
     450
    445451        // Invoke precess with invalid parameter
    446452        psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     
    450456            return 11;
    451457        }
    452      
     458
    453459        // Invoke precess with invalid parameter
    454460        psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
     
    458464            return 12;
    459465        }
    460      
     466
    461467        // Free objects
    462468        psFree(fromTime);
Note: See TracChangeset for help on using the changeset viewer.