IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 17, 2006, 2:41:29 PM (21 years ago)
Author:
drobbin
Message:

Updated Table parser, Fixed misc EOC, worked primarily on GravityDeflection

File:
1 edited

Legend:

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

    r5969 r6030  
    88 *  @author Robert Daniel DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2006-01-12 20:40:12 $
     10 *  @version $Revision: 1.27 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2006-01-18 00:41:29 $
    1212 *
    1313 *  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    3939#define PS_AU 149597890000.0 /* meters */
    4040// Modified Julian Day 1/1/2000 00:00:00
    41 #define MJD_2000  51544.0
     41#define MJD_2000  51544.5
    4242// Days in Julian century
    4343#define JULIAN_CENTURY 36525.0
     
    299299    double a = 0.0;
    300300
    301     //mu = apparent * direction;  I believe this should be:
    302     //    mu = apparent->r * direction->r + apparent->d * direction->d;
    303301    psCube* directionVector = psSphereToCube(direction);
    304302    if (directionVector == NULL)
    305303        printf("directionVector is null\n");
    306304    psCube* actualVector = psSphereToCube(actual);
    307     if (directionVector == NULL)
     305    if (actualVector == NULL)
    308306        printf("actualVector is null\n");
    309307    //    mu = acos(directionVector->x*actualVector->x +
     
    311309          directionVector->y*actualVector->y +
    312310          directionVector->z*actualVector->z);
    313 
    314     //    rp = apparent - mu * direction;
    315     //    rp->r = actual->r - mu * direction->r;
    316     //    rp->d = actual->d - mu * direction->d;
    317311    rp->x = actualVector->x - mu * directionVector->x;
    318312    rp->y = actualVector->y - mu * directionVector->y;
    319313    rp->z = actualVector->z - mu * directionVector->z;
    320314
    321     mu_p = mu + speed * ((mu * mu - 1.0) / (1.0 - speed * mu));
     315    mu_p = mu - speed * ((mu * mu - 1.0) / (1.0 - speed * mu));
    322316
    323317    //Not sure if this is right.  ADD gets a scalar from division of rp (a vector)
     
    345339    //XXX: Must be a sign error somewhere above?  Magnitude of change is correct but wrong way...
    346340    //This will fix the problem but is somewhat of a hack.
    347     r_p->x = actualVector->x - (r_p->x - actualVector->x);
    348     r_p->y = actualVector->y - (r_p->y - actualVector->y);
    349     r_p->z = actualVector->z - (r_p->z - actualVector->z);
     341    //    r_p->x = actualVector->x - (r_p->x - actualVector->x);
     342    //    r_p->y = actualVector->y - (r_p->y - actualVector->y);
     343    //    r_p->z = actualVector->z - (r_p->z - actualVector->z);
    350344
    351345    psSphere *r_pSphere = psCubeToSphere(r_p);
     
    370364    PS_ASSERT_PTR_NON_NULL(sun, NULL);
    371365
     366    psSphere *temp = psSphereAlloc();
    372367    // calculating the apparent angle from the actual angle and the sun position
    373368
     
    378373    // N.B., assuming the psSphereToCube function returns a unit vector.
    379374    //    double theta = acos(sunVector->x*actualVector->x +
    380     double theta = (sunVector->x*actualVector->x +
    381                     sunVector->y*actualVector->y +
    382                     sunVector->z*actualVector->z);
    383     printf(" Theta = %lf\n", theta);
     375    double dotProd = (sunVector->x*actualVector->x +
     376                      sunVector->y*actualVector->y + sunVector->z*actualVector->z);
     377    double theta, sunMag, actMag;
     378    sunMag = sqrt(sunVector->x*sunVector->x + sunVector->y*sunVector->y +
     379                  sunVector->z*sunVector->z);
     380    actMag = sqrt(actualVector->x*actualVector->x + actualVector->y*actualVector->y +
     381                  actualVector->z*actualVector->z);
     382    dotProd = dotProd / (sunMag * actMag);
     383    theta = acos(dotProd);
     384
     385    //    theta = acos( cos(sun->d)*cos(actual->d)*cos(sun->r-actual->r) + sin(sun->r)*sin(actual->r) );
     386
     387    printf(" Theta = %.13g\n", theta);
    384388    //    theta = acos(-theta);
    385389    //    printf("\n Theta = %lf\n", theta);
    386390    double r0 = PS_AU * tan(theta);
     391    printf(" r0 = %.19e\n", r0);
    387392    double deflection = 4.0*PS_G*PS_M/(PS_C0*PS_C0*r0);
    388393
     
    390395    double limit = SEC_TO_RAD(1.75);
    391396    printf(" deflection = %.13g\n", deflection);
    392     printf(" limit = %lf\n", limit);
     397    //printf(" limit = %lf\n", limit);
    393398    if (deflection > limit) {
    394399        //       deflection = limit;
     
    400405    }
    401406
    402     if (apparent == NULL) {
    403         apparent = psSphereAlloc();
    404     } else {
    405         apparent->r = 0.0;
    406         apparent->d = 0.0;
    407         apparent->rErr = 0.0;
    408         apparent->dErr = 0.0;
    409     }
    410 
     407    /*    if (apparent == NULL) {
     408            apparent = psSphereAlloc();
     409        } else {
     410            apparent->r = 0.0;
     411            apparent->d = 0.0;
     412            apparent->rErr = 0.0;
     413            apparent->dErr = 0.0;
     414        }
     415    */
     416    if (apparent != NULL) {
     417        psFree(apparent);
     418    }
    411419    // bend the actual vector away from the sun vector by deflection angle.
    412420    // XXX: Not sure how to do this.  Dave thinks the formula should be:
     
    414422    theta = 0.0;
    415423    double phi = 0.0;
    416     //    deflection = SEC_TO_RAD(deflection);
     424    //    deflection = SEC_TO_RAD(deflection) * 1e6;
     425    //    deflection *= M_PI * 1e-2;
    417426    theta = atan(r0/PS_AU) * tan(deflection);
    418     printf(" Theta = %.13g\n", theta);
    419     printf(" deflection = %.13g\n", deflection);
    420427    //    phi = sqrt( deflection*deflection - theta*theta );
    421     phi = deflection * cos(asin(theta/deflection)) * 3e-2;
     428    //    phi = deflection * cos(asin(theta/deflection));
     429
     430    //    phi = sqrt(theta*theta - deflection*deflection);
     431    //    phi = deflection * cos(asin(theta/deflection)) * 3e-2;
    422432    //    phi = cos(asin(theta/deflection));
    423433    //    phi = asin(theta/deflection);
    424     apparent->r = theta;
    425     apparent->d = phi;
     434
     435    //    apparent->r = theta;
     436    //    apparent->d = phi;
     437    /*
     438        actualVector->x += actualVector->x*deflection;
     439        actualVector->y += actualVector->y*deflection;
     440        actualVector->z += actualVector->z*deflection;
     441        apparent = psCubeToSphere(actualVector);
     442    */
     443    theta = tan(sun->r - actual->r) * deflection;
     444    phi = tan(sun->d - actual->d) * deflection;
     445
     446    printf(" Theta = %.13g\n", theta);
     447    printf(" phi = %.13g\n", phi);
     448
     449    temp->r = theta;
     450    temp->d = phi;
     451    apparent = psSphereSetOffset(actual, temp, PS_SPHERICAL, PS_RADIAN);
    426452
    427453    psFree(actualVector);
    428454    psFree(sunVector);
     455    psFree(temp);
     456
    429457    return apparent;
    430458}
     
    807835}
    808836
    809 psSphereRot* psSphereRot_TEOtoCEO(const psTime *time)
     837psSphereRot* psSphereRot_TEOtoCEO(const psTime *time,
     838                                  psEarthPole *tidalCorr)
    810839{
    811840    PS_ASSERT_PTR_NON_NULL(time,NULL);
     
    815844        in = psTimeConvert(in, PS_TIME_UT1);
    816845    }
    817     //    double T = (double)(in->sec) + (double)(in->nsec / 1e9);
     846    if (tidalCorr != NULL && tidalCorr->s != 0.0) {
     847        int nsec = in->nsec + (int)(tidalCorr->s * 1e9);
     848        if (nsec < 0.0) {
     849            in->sec += -1;
     850            in->nsec = (int)(1e9) - nsec;
     851        } else {
     852            in->nsec = nsec;
     853        }
     854    }
    818855    double T = psTimeToJD(in);
    819856    T += -2451545.0;
    820857    double theta = 2.0 * M_PI * (0.7790572732640 + 1.00273781191135448 * T);
    821858    psSphereRot *out = psSphereRotAlloc(theta, 0.0, 0.0);
    822     //    psSphereRot *out = psSphereRotInvert(theta, 0.0, 0.0);
    823859
    824860    psFree(in);
     
    919955    out->x = SEC_TO_RAD(xOut);
    920956    out->y = SEC_TO_RAD(yOut);
     957    //    psEarthPole *polarTideCorr = psEOC_PolarTideCorr(time);
     958    //    out->x += polarTideCorr->x;
     959    //    out->y += polarTideCorr->y;
     960    //    psFree(polarTideCorr);
     961
    921962    //    out->s = SEC_TO_RAD(sOut);
    922963
     
    10341075    CORX = SEC_TO_RAD(CORX);
    10351076    CORY = SEC_TO_RAD(CORY);
    1036     CORZ = SEC_TO_RAD(CORZ);
     1077    //    CORZ = SEC_TO_RAD(CORZ);
    10371078
    10381079    out->x = CORX;
Note: See TracChangeset for help on using the changeset viewer.