IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 25, 2005, 3:20:15 PM (21 years ago)
Author:
drobbin
Message:

Finished and tested psGravityDeflection function

File:
1 edited

Legend:

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

    r5235 r5446  
    66*  @ingroup EarthOrientation
    77*
     8*  @author Dave Robbins, MHPCC
    89*  @author Robert Daniel DeSonia, MHPCC
    910*
    10 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-10-07 21:27:49 $
     11*  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-10-26 01:20:15 $
    1213*
    1314*  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    166167psSphere *psGravityDeflection(psSphere *apparent, psSphere *actual, psSphere *sun)
    167168{
    168     // calculating the apparent angle from the actual angle and the sun position
    169 
    170     // first, calculate the angle between the sun vector and the actual vector
     169    PS_ASSERT_PTR_NON_NULL(apparent, NULL);
     170    PS_ASSERT_PTR_NON_NULL(sun, NULL);
     171
     172    // calculating the actual angle from the apparent angle and the sun position
     173
     174    // first, calculate the angle between the sun vector and the apparent vector
    171175
    172176    // Moving to cartesian first:  XXX -- is this required?
    173177    psCube* sunVector = psSphereToCube(sun);
    174     psCube* actualVector = psSphereToCube(actual);
     178    psCube* apparentVector = psSphereToCube(apparent);
    175179
    176180    // use dot product to calculate the angle of separation
    177181    // N.B., assuming the psSphereToCube function returns a unit vector.
    178     double theta = acos(sunVector->x*actualVector->x +
    179                         sunVector->y*actualVector->y +
    180                         sunVector->z*actualVector->z);
     182    double theta = acos(sunVector->x*apparentVector->x +
     183                        sunVector->y*apparentVector->y +
     184                        sunVector->z*apparentVector->z);
    181185
    182186    double r0 = PS_AU * tan(theta);
    183 
    184187    double deflection = 4.0*PS_G*PS_M/(PS_C0*PS_C0*r0);
    185188
     
    187190    double limit = SEC_TO_RAD(1.75);
    188191    if (deflection > limit) {
    189         deflection = limit;
    190     }
    191 
    192     // bend the actual vector away from the sun vector by deflection angle.
     192        //       deflection = limit;
     193        //if deflection is greater than limit, the light rays will hit the sun
     194        psWarning("Invalid positions.  Light ray will not be seen on earth.\n");
     195        psFree(apparentVector);
     196        psFree(sunVector);
     197        return actual;
     198    }
     199
     200    if (actual == NULL) {
     201        actual = psSphereAlloc();
     202    } else {
     203        actual->r = 0.0;
     204        actual->d = 0.0;
     205        actual->rErr = 0.0;
     206        actual->dErr = 0.0;
     207    }
     208
     209    // bend the apparent vector away from the sun vector by deflection angle.
    193210    // XXX: Not sure how to do this.  Dave thinks the formula should be:
    194211    //      theta = atan(r0/d)*tan(deflection), phi = thete/tan(deflection)
    195 
    196     return NULL;
     212    theta = 0.0;
     213    double phi = 0.0;
     214    deflection = SEC_TO_RAD(deflection);
     215    theta = atan(r0/PS_AU) * tan(deflection);
     216    phi = sqrt( deflection*deflection - theta*theta );
     217    actual->r = theta;
     218    actual->d = phi;
     219    psFree(apparentVector);
     220    psFree(sunVector);
     221    return actual;
    197222}
    198223
Note: See TracChangeset for help on using the changeset viewer.