IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2984


Ignore:
Timestamp:
Jan 13, 2005, 12:53:37 PM (22 years ago)
Author:
gusciora
Message:

Improving tests for psCoord.c

File:
1 edited

Legend:

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

    r2983 r2984  
    66*  @author GLG, MHPCC
    77*
    8 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-01-13 22:45:40 $
     8*  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-01-13 22:53:37 $
    1010*
    1111*  XXX: Must test psSpherePrecess.
     
    6060                          };
    6161
    62 #define ARCSEC_TO_RAD (M_PI / (180.0 * 60.0 * 60.0))
    63 #define ARCMIN_TO_RAD (M_PI / (180.0 * 60.0))
    64 #define MY_DEG_TO_RAD (M_PI / 180.0)
    65 #define MY_RAD_TO_DEG (180.0 / M_PI)
    66 #define RAD_TO_ARCMIN ((180.0 * 60.0) / M_PI)
    67 #define RAD_TO_ARCSEC ((180.0 * 60.0 * 60.0) / M_PI)
    68 
    69 
    7062psS32 main( psS32 argc, char* argv[] )
    7163{
     
    10261018            offset = psSphereGetOffset(&position1, &position2,
    10271019                                       PS_SPHERICAL, PS_ARCMIN);
    1028             offset->r = offset->r * ARCMIN_TO_RAD;
    1029             offset->d = offset->d * ARCMIN_TO_RAD;
     1020            offset->r = MIN_TO_RAD(offset->r);
     1021            offset->d = MIN_TO_RAD(offset->d);
    10301022            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2.r - position1.r), 2);
    10311023            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2.d - position1.d), 3);
     
    10341026            offset = psSphereGetOffset(&position1, &position2,
    10351027                                       PS_SPHERICAL, PS_ARCSEC);
    1036             offset->r = offset->r * ARCSEC_TO_RAD;
    1037             offset->d = offset->d * ARCSEC_TO_RAD;
     1028            offset->r = SEC_TO_RAD(offset->r);
     1029            offset->d = SEC_TO_RAD(offset->d);
    10381030            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->r, (position2.r - position1.r), 2);
    10391031            PS_COMPARE_TINY_THEN_PRINT_ERROR(offset->d, (position2.d - position1.d), 3);
     
    11301122            psFree(position2);
    11311123
    1132             tmpOffset.r = offset.r * RAD_TO_ARCMIN;
    1133             tmpOffset.d = offset.d * RAD_TO_ARCMIN;
     1124            tmpOffset.r = RAD_TO_MIN(offset.r);
     1125            tmpOffset.d = RAD_TO_MIN(offset.d);
    11341126            tmpOffset.rErr = 0.0;
    11351127            tmpOffset.dErr = 0.0;
     
    11401132            psFree(position2);
    11411133
    1142             tmpOffset.r = offset.r * RAD_TO_ARCSEC;
    1143             tmpOffset.d = offset.d * RAD_TO_ARCSEC;
     1134            tmpOffset.r = RAD_TO_SEC(offset.r);
     1135            tmpOffset.d = RAD_TO_SEC(offset.d);
    11441136            tmpOffset.rErr = 0.0;
    11451137            tmpOffset.dErr = 0.0;
     
    12441236}
    12451237
     1238bool testNonEqualF32(psF32 num1, psF32 num2)
     1239{
     1240    if ((fabs(num1) <= FLT_EPSILON) && (fabs(num2) <= FLT_EPSILON)) {
     1241        return(false);
     1242    }
     1243
     1244    if (fabs((num2 - num1) / num1) <= ERROR_PERCENT) {
     1245        return(false);
     1246    }
     1247    return(false);
     1248}
     1249
    12461250#define NUM_DEGREES 5
    12471251/******************************************************************************
     
    12741278
    12751279    #define RADIUS_DEG 30.0
    1276     #define NUM_ANGLES 20
     1280    #define NUM_ANGLES 30
    12771281    #define MY_DEG_INC ((2.0 * RADIUS_DEG) / NUM_ANGLES)
    12781282
     
    12911295            endCoords = psDeproject(planeCoords, &myProj);
    12921296
    1293             if ((fabs((endCoords->r - startCoords.r) / startCoords.r) > ERROR_PERCENT) ||
    1294                     (fabs((endCoords->d - startCoords.d) / startCoords.d) > ERROR_PERCENT)) {
     1297            if (testNonEqualF32(endCoords->r, startCoords.r) ||
     1298                    testNonEqualF32(endCoords->d, startCoords.d)) {
    12951299                printf("ERROR: \n");
    12961300                printf("    startCoords (R, D) is (%f, %f)\n", startCoords.r, startCoords.d);
     
    13071311
    13081312// This code will ...
     1313
Note: See TracChangeset for help on using the changeset viewer.