IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 1, 2005, 3:07:25 PM (21 years ago)
Author:
drobbin
Message:

updated tests, function spec's and verified files. resolved some existing issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psEarthOrientation.c

    r5450 r5455  
    99*  @author Robert Daniel DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-10-28 02:25:22 $
     11*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-11-02 01:07:25 $
    1313*
    1414*  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    5454static bool eocInit()
    5555{
    56     int nFail = 0;
     56    unsigned int nFail = 0;
    5757
    5858    // Read config file
     
    158158}
    159159
    160 psSphere *psAberration(psSphere *actual,
    161                        const psSphere *apparent,
     160psSphere *psAberration(psSphere *apparent,
     161                       const psSphere *actual,
    162162                       const psSphere *direction,
    163163                       double speed)
    164164{
    165     PS_ASSERT_PTR_NON_NULL(apparent, NULL);
     165    PS_ASSERT_PTR_NON_NULL(actual, NULL);
    166166    PS_ASSERT_PTR_NON_NULL(direction, NULL);
    167167    if (fabs(speed) < DBL_EPSILON) {
     
    171171    }
    172172
    173     if (actual == NULL) {
    174         actual = psSphereAlloc();
     173    if (apparent == NULL) {
     174        apparent = psSphereAlloc();
    175175    } else {
    176         actual->r = 0.0;
    177         actual->d = 0.0;
    178         actual->rErr = 0.0;
    179         actual->dErr = 0.0;
     176        apparent->r = 0.0;
     177        apparent->d = 0.0;
     178        apparent->rErr = 0.0;
     179        apparent->dErr = 0.0;
    180180    }
    181181    psSphere *rp = psSphereAlloc();
     
    188188    //    mu = apparent->r * direction->r + apparent->d * direction->d;
    189189    psCube* directionVector = psSphereToCube(direction);
    190     psCube* apparentVector = psSphereToCube(apparent);
    191     mu = acos(directionVector->x*apparentVector->x +
    192               directionVector->y*apparentVector->y +
    193               directionVector->z*apparentVector->z);
     190    psCube* actualVector = psSphereToCube(actual);
     191    mu = acos(directionVector->x*actualVector->x +
     192              directionVector->y*actualVector->y +
     193              directionVector->z*actualVector->z);
    194194
    195195    //rp = apparent - mu * direction;
    196     rp->r = apparent->r - mu * direction->r;
    197     rp->d = apparent->d - mu * direction->d;
     196    rp->r = actual->r - mu * direction->r;
     197    rp->d = actual->d - mu * direction->d;
    198198
    199199    mu_p = mu + speed * ((mu * mu - 1.0) / (1.0 - speed * mu));
     
    210210    r_p->d = mu_p * direction->d + a * rp->d;
    211211
    212     *actual = *r_p;
     212    *apparent = *r_p;
    213213    /*
    214214        psSphereRot *rot = NULL;
     
    218218        double sinD = sin(direction->d);
    219219        rot = psSphereRotQuat(cosR*cosD, sinR*cosD, sinD, speed);
    220      
     220
    221221        actual = psSphereRotApply(actual, rot, apparent);
    222222    */
     
    224224    psFree(r_p);
    225225    psFree(directionVector);
    226     psFree(apparentVector);
     226    psFree(actualVector);
    227227    psFree(rpVector);
    228     return actual;
    229 }
    230 
    231 psSphere *psGravityDeflection(psSphere *actual,
    232                               psSphere *apparent,
     228    return apparent;
     229}
     230
     231psSphere *psGravityDeflection(psSphere *apparent,
     232                              psSphere *actual,
    233233                              psSphere *sun)
    234234{
    235     PS_ASSERT_PTR_NON_NULL(apparent, NULL);
     235    PS_ASSERT_PTR_NON_NULL(actual, NULL);
    236236    PS_ASSERT_PTR_NON_NULL(sun, NULL);
    237237
    238     // calculating the actual angle from the apparent angle and the sun position
    239 
    240     // first, calculate the angle between the sun vector and the apparent vector
     238    // calculating the apparent angle from the actual angle and the sun position
     239
     240    // first, calculate the angle between the sun vector and the actual vector
    241241
    242242    // Moving to cartesian first:  XXX -- is this required?
    243243    psCube* sunVector = psSphereToCube(sun);
    244     psCube* apparentVector = psSphereToCube(apparent);
     244    psCube* actualVector = psSphereToCube(actual);
    245245
    246246    // use dot product to calculate the angle of separation
    247247    // N.B., assuming the psSphereToCube function returns a unit vector.
    248     double theta = acos(sunVector->x*apparentVector->x +
    249                         sunVector->y*apparentVector->y +
    250                         sunVector->z*apparentVector->z);
     248    double theta = acos(sunVector->x*actualVector->x +
     249                        sunVector->y*actualVector->y +
     250                        sunVector->z*actualVector->z);
    251251
    252252    double r0 = PS_AU * tan(theta);
     
    259259        //if deflection is greater than limit, the light rays will hit the sun
    260260        psWarning("Invalid positions.  Light ray will not be seen on earth.\n");
    261         psFree(apparentVector);
     261        psFree(actualVector);
    262262        psFree(sunVector);
    263         return actual;
    264     }
    265 
    266     if (actual == NULL) {
    267         actual = psSphereAlloc();
     263        return apparent;
     264    }
     265
     266    if (apparent == NULL) {
     267        apparent = psSphereAlloc();
    268268    } else {
    269         actual->r = 0.0;
    270         actual->d = 0.0;
    271         actual->rErr = 0.0;
    272         actual->dErr = 0.0;
    273     }
    274 
    275     // bend the apparent vector away from the sun vector by deflection angle.
     269        apparent->r = 0.0;
     270        apparent->d = 0.0;
     271        apparent->rErr = 0.0;
     272        apparent->dErr = 0.0;
     273    }
     274
     275    // bend the actual vector away from the sun vector by deflection angle.
    276276    // XXX: Not sure how to do this.  Dave thinks the formula should be:
    277277    //      theta = atan(r0/d)*tan(deflection), phi = thete/tan(deflection)
     
    281281    theta = atan(r0/PS_AU) * tan(deflection);
    282282    phi = sqrt( deflection*deflection - theta*theta );
    283     actual->r = theta;
    284     actual->d = phi;
    285     psFree(apparentVector);
     283    apparent->r = theta;
     284    apparent->d = phi;
     285    psFree(actualVector);
    286286    psFree(sunVector);
    287     return actual;
     287    return apparent;
    288288}
    289289
Note: See TracChangeset for help on using the changeset viewer.