IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5446


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

Finished and tested psGravityDeflection function

Location:
trunk/psLib
Files:
5 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
  • trunk/psLib/src/astro/psEarthOrientation.h

    r5306 r5446  
    66*  @ingroup EarthOrientation
    77*
     8*  @author Dave Robbins, MHPCC
    89*  @author Robert Daniel DeSonia, MHPCC
    910*
    10 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2005-10-13 20:23:57 $
     11*  @version $Revision: 1.4 $ $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
     
    5556);
    5657
    57 /**
     58/** Calculates the actual position of a star, given its apparent position and the
     59 *  position of the sun.
    5860 *
     61 *  The actual and apparent positions are represented as psSphere entries, as is
     62 *  position of the sun.  If the value of actual is NULL, a new psSphere is allocated,
     63 *  otherwise the point to actual is used for the result.
    5964 *
    60  *
     65 *  @return psSphere*:      the apparent position of a star.
    6166 */
    6267psSphere *psGravityDeflection(
    63     psSphere *apparent,                ///<
    64     psSphere *actual,                  ///<
    65     psSphere *sun                      ///<
     68    psSphere *apparent,                ///< apparent position of star
     69    psSphere *actual,                  ///< actual position of star
     70    psSphere *sun                      ///< position of the sun
    6671);
    6772
  • trunk/psLib/src/pslib_strict.h

    r5227 r5446  
    99*  @author Eric Van Alst, MHPCC
    1010*
    11 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-10-06 02:41:07 $
     11*  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-10-26 01:20:14 $
    1313*
    1414*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3131#include "psCoord.h"
    3232#include "psSphereOps.h"
     33#include "psEarthOrientation.h"
    3334/// @}
    3435
  • trunk/psLib/test/astro/tst_psEarthOrientation.c

    r5306 r5446  
    66*  @author d-Rob, MHPCC
    77*
    8 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-10-13 20:23:57 $
     8*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-10-26 01:20:15 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    1515#include "pslib_strict.h"
    1616
     17static psS32 testEOCParallax(void);
     18static psS32 testAberration(void);
     19static psS32 testGravityDeflect(void);
     20static psS32 testEOCPrecession(void);
     21static psS32 testEOCPolar(void);
     22static psS32 testEOCNutation(void);
     23static psS32 testSphereRotTransforms(void);
     24
    1725testDescription tests[] = {
     26                              {testEOCParallax, 666, "psEOCParallax()", 0, false},
     27                              {testAberration, 667, "psAberration()", 0, false},
     28                              {testGravityDeflect, 668, "psGravityDeflect()", 0, false},
     29                              {testEOCPrecession, 669, "psEOCPrecession()", 0, false},
     30                              {testEOCPolar, 670, "psEOCPolar()", 0, false},
     31                              {testEOCNutation, 671, "psEOCNutation()", 0, false},
     32                              {testSphereRotTransforms, 672, "psSphereRotTransforms()", 0, false},
    1833                              {NULL}
    1934                          };
     
    2338    psLogSetLevel( PS_LOG_INFO );
    2439
    25     return ( ! runTestSuite( stderr, "psCoord", tests, argc, argv ) );
     40    return ( ! runTestSuite( stderr, "psEarthOrientation", tests, argc, argv ) );
    2641}
    2742
     43psS32 testEOCParallax(void)
     44{
    2845
     46    return 0;
     47}
    2948
     49psS32 testAberration(void)
     50{
     51
     52    return 0;
     53}
     54
     55psS32 testGravityDeflect(void)
     56{
     57
     58    psSphere *actual = NULL;
     59    psSphere *apparent = psSphereAlloc();
     60    psSphere *sun = psSphereAlloc();
     61
     62    sun->r = 0.2;
     63    sun->d = 0.2;
     64    apparent->r = 0.2035;
     65    apparent->d = 0.2035;
     66
     67    actual = psGravityDeflection(apparent, actual, sun);
     68    psSphere *result = psSphereSetOffset(apparent, actual, PS_SPHERICAL, PS_RADIAN);
     69    printf("\nApparent r,d = %.13g,%.13g    Actual r,d = %.13g, %.13g \n",
     70           apparent->r, apparent->d, result->r, result->d);
     71    psFree(result);
     72    psFree(actual);
     73    psFree(apparent);
     74    psFree(sun);
     75
     76    return 0;
     77}
     78
     79psS32 testEOCPrecession(void)
     80{
     81
     82    return 0;
     83}
     84
     85psS32 testEOCPolar(void)
     86{
     87
     88    return 0;
     89}
     90
     91psS32 testEOCNutation(void)
     92{
     93
     94    return 0;
     95}
     96
     97psS32 testSphereRotTransforms(void)
     98{
     99
     100    return 0;
     101}
     102
  • trunk/psLib/test/astro/tst_psSphereOps.c

    r5444 r5446  
    66*  @author d-Rob, MHPCC
    77*
    8 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-10-25 00:38:00 $
     8*  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-10-26 01:20:15 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3535    psLogSetLevel( PS_LOG_INFO );
    3636
    37     return ( ! runTestSuite( stderr, "psCoord", tests, argc, argv ) );
     37    return ( ! runTestSuite( stderr, "psSphereOps", tests, argc, argv ) );
    3838}
    3939
Note: See TracChangeset for help on using the changeset viewer.