IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 2, 2006, 1:19:58 PM (20 years ago)
Author:
drobbin
Message:

Added comments, removed old code & comments, added NULL checks.

File:
1 edited

Legend:

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

    r6226 r6309  
    55*  @author d-Rob, MHPCC
    66*
    7 *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
    8 *  @date $Date: 2006-01-27 20:08:58 $
     7*  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
     8*  @date $Date: 2006-02-02 23:19:58 $
    99*
    1010*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6464    double a2 = (ALPHA_P + PHI_P)/2.0;
    6565    double a3 = (ALPHA_P + PHI_P)/2.0;
    66 
     66    //From Mathworld, this is another way to calculate the quaternions of a rotation
    6767    double q0 = sin(a0)*sin(DELTA_P/2);
    6868    double q1 = cos(a1)*sin(DELTA_P/2);
    6969    double q2 = sin(a2)*cos(DELTA_P/2);
    7070    double q3 = cos(a3)*cos(DELTA_P/2);
    71 
     71    //Check that the quaternion components all match
    7272    if (DBL_EPSILON < fabs(q0 - myST->q0)) {
    7373        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %lf, should be %lf\n", myST->q0, q0);
     
    9999    double a2 = (ALPHA_P + PHI_P)/2.0;
    100100    double a3 = (ALPHA_P + PHI_P)/2.0;
    101 
     101    //From Mathworld, this is another way to calculate the quaternions of a rotation
    102102    double q0 = sin(a0)*sin(DELTA_P/2);
    103103    double q1 = cos(a1)*sin(DELTA_P/2);
     
    111111        return 1;
    112112    }
    113 
     113    //Check that the quaternion components all match
    114114    if (FLT_EPSILON < fabs(q0 - myST->q0)) {
    115115        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %lf, should be %lf\n", myST->q0, q0);
     
    135135}
    136136
    137 
    138137// We do a simple identity transformation on a few RA, DEC pairs.
    139138psS32 testSphereRotApply1( void )
    140139{
    141 
    142140    psSphere *in = psSphereAlloc();
    143141    psSphere *out = psSphereAlloc();
     
    145143    psSphere *rc = NULL;
    146144    psSphere *temp2 = psSphereAlloc();
    147     //        psSphereRot *myST = psSphereRotAlloc(0.0, 0.0, 0.0);
    148145    psSphereRot *myST = psSphereRotAlloc(ALPHA_P, DELTA_P, PHI_P);
    149146    psSphereRot *yourST =  psSphereRotInvert(ALPHA_P, DELTA_P, PHI_P);
     
    155152            in->rErr = 0.0;
    156153            in->dErr = 0.0;
    157 
     154            //Here we apply the sphere rotation, then the inverse
    158155            temp2 = psSphereRotApply(temp2, myST, in);
    159156            out = psSphereRotApply(out, yourST, temp2);
    160 
     157            //Check that out matches in
    161158            if (ERROR_TOL < fabs(out->r - in->r)) {
    162159                psError(PS_ERR_UNKNOWN,true,"out->r is %f, should be %f\n", out->r, in->r);
     
    206203psS32 testSphereRotApplyCelestial( void)
    207204{
     205    //Test cases below were provided in ADD.
    208206    int numTestPoints = 3;
    209207    // ICRS coordinates
     
    220218
    221219    for (int x = 0; x < numTestPoints; x++) {
    222 
     220        //Setup the appropriate rotations
    223221        psTime* time = psTimeFromMJD(t[x]);
    224222        psSphereRot* toEcliptic = psSphereRotICRSToEcliptic(time);
     
    246244            return 1;
    247245        }
     246        //The second condition here (d - 90) is used b/c 90 is a pole.
    248247        if ( (fabs(RAD_TO_DEG(icrsFromEcliptic->r) - alpha[x]) > TOLERANCE &&
    249248                fabs(RAD_TO_DEG(icrsFromEcliptic->d) - 90.0) > TOLERANCE ) ||
     
    258257        psFree(icrsFromEcliptic);
    259258
    260         // apply/unapply Galactic
    261         //        if (x == 1){
    262         //             psSphereRot *temp = psSphereRotICRSToGalactic();
    263         //             *fromGalactic = *temp;
    264         //             fromGalactic->q3 *= -1.0;
    265         //             psFree(temp);
    266         //        }
     259        //Setup galactic transformations
    267260        psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs);
    268261        psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic);
     
    277270            return 3;
    278271        }
     272        //The second condition here (d - 90) is used b/c 90 is a pole.
    279273        if ( (fabs(RAD_TO_DEG(icrsFromGalactic->r) - alpha[x]) > TOLERANCE &&
    280274                fabs(RAD_TO_DEG(icrsFromGalactic->d) - 90.0) > TOLERANCE ) ||
     
    306300
    307301    //Test Set for NULL position
     302    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
    308303    output = psSphereSetOffset(empty, offset, PS_SPHERICAL, PS_DEGREE);
    309304    if (output != NULL) {
     
    313308    }
    314309    //Test Set for NULL offset
     310    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
    315311    output = psSphereSetOffset(offset, empty, PS_SPHERICAL, PS_DEGREE);
    316312    if (output != NULL) {
     
    320316    }
    321317    //Test Get for NULL position1
     318    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
    322319    output = psSphereGetOffset(empty, origin, PS_LINEAR, PS_RADIAN);
    323320    if (output != NULL) {
     
    327324    }
    328325    //Test Get for NULL position2
     326    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
    329327    output = psSphereGetOffset(origin, empty, PS_LINEAR, PS_RADIAN);
    330328    if (output != NULL) {
     
    354352    offset->d = 1.0;
    355353    output = psSphereSetOffset(origin, offset, PS_LINEAR, PS_RADIAN);
    356     /*    if ( fabs(output->r - 1.0) > 0.0001 || fabs(output->d - 1.0) > 0.0001 ) {
    357             psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    358                 "psSphereSetOffset failed to return correct linear offset values.\n");
    359         printf("\n SphereSetOffset should be %lf, %lf and is %lf, %lf\n", offset->r, offset->d,
    360             output->r, output->d);
    361             return 6;
    362         }
    363     */
    364     //    output->r *= -1.0;
    365     //    output->d *= -1.0;
     354
    366355    empty = psSphereGetOffset(origin, output, PS_LINEAR, PS_RADIAN);
    367356    if ( fabs(offset->r - empty->r) > 0.0001 || fabs(offset->d - empty->d) > 0.0001 ) {
Note: See TracChangeset for help on using the changeset viewer.