IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5450


Ignore:
Timestamp:
Oct 27, 2005, 4:25:22 PM (21 years ago)
Author:
drobbin
Message:

Implemented and tested psAberration, but results have not been verified.

Location:
trunk/psLib
Files:
6 edited

Legend:

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

    r5447 r5450  
    99*  @author Robert Daniel DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-10-27 20:38:18 $
     11*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-10-28 02:25:22 $
    1313*
    1414*  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    1919
    2020#include "psEarthOrientation.h"
    21 #include "psTime.h"
     21//#include "psTime.h"
    2222#include "psArray.h"
    2323#include "psPolynomial.h"
     
    163163                       double speed)
    164164{
    165 
    166 
    167     return NULL;
     165    PS_ASSERT_PTR_NON_NULL(apparent, NULL);
     166    PS_ASSERT_PTR_NON_NULL(direction, NULL);
     167    if (fabs(speed) < DBL_EPSILON) {
     168        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     169                "Aberration speed should not be equal to 0.\n");
     170        return NULL;
     171    }
     172
     173    if (actual == NULL) {
     174        actual = psSphereAlloc();
     175    } else {
     176        actual->r = 0.0;
     177        actual->d = 0.0;
     178        actual->rErr = 0.0;
     179        actual->dErr = 0.0;
     180    }
     181    psSphere *rp = psSphereAlloc();
     182    psSphere *r_p = psSphereAlloc();
     183    double mu = 0.0;
     184    double mu_p = 0.0;
     185    double a = 0.0;
     186
     187    //mu = apparent * direction;  I believe this should be:
     188    //    mu = apparent->r * direction->r + apparent->d * direction->d;
     189    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);
     194
     195    //rp = apparent - mu * direction;
     196    rp->r = apparent->r - mu * direction->r;
     197    rp->d = apparent->d - mu * direction->d;
     198
     199    mu_p = mu + speed * ((mu * mu - 1.0) / (1.0 - speed * mu));
     200
     201    //Not sure if this is right.  ADD gets a scalar from division of rp (a vector)
     202    psCube* rpVector = psSphereToCube(rp);
     203    a = sqrt( (1.0 - mu_p * mu_p) /
     204              (sqrt(rpVector->x*rpVector->x
     205                    + rpVector->y*rpVector->y
     206                    + rpVector->z*rpVector->z)) );
     207
     208    //r_p = mu_p * direction + a * rp;
     209    r_p->r = mu_p * direction->r + a * rp->r;
     210    r_p->d = mu_p * direction->d + a * rp->d;
     211
     212    *actual = *r_p;
     213    /*
     214        psSphereRot *rot = NULL;
     215        double cosR = cos(direction->r);
     216        double cosD = cos(direction->d);
     217        double sinR = sin(direction->r);
     218        double sinD = sin(direction->d);
     219        rot = psSphereRotQuat(cosR*cosD, sinR*cosD, sinD, speed);
     220     
     221        actual = psSphereRotApply(actual, rot, apparent);
     222    */
     223    psFree(rp);
     224    psFree(r_p);
     225    psFree(directionVector);
     226    psFree(apparentVector);
     227    psFree(rpVector);
     228    return actual;
    168229}
    169230
  • trunk/psLib/src/astro/psEarthOrientation.h

    r5447 r5450  
    99*  @author Robert Daniel DeSonia, MHPCC
    1010*
    11 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    12 *  @date $Date: 2005-10-27 20:38:18 $
     11*  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     12*  @date $Date: 2005-10-28 02:25:22 $
    1313*
    1414*  Copyright 2005 Maui High Performance Computing Center, University of Hawaii
     
    4242    PS_PRECESS_COMPLETE,               ///< complete level of detail
    4343    PS_PRECESS_IAU2000A,               ///< highest level of detail
    44 } psPrecessMethod;
     44}
     45psPrecessMethod;
    4546
    4647/** Calculates the actual position of a star, given its apparent position and the
  • trunk/psLib/test/astro/tst_psEarthOrientation.c

    r5447 r5450  
    66*  @author d-Rob, MHPCC
    77*
    8 *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-10-27 20:38:19 $
     8*  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-10-28 02:25:22 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2424
    2525testDescription tests[] = {
    26                               {testEOCParallax, 666, "psEOCParallax()", 0, false},
    27                               {testAberration, 667, "psAberration()", 0, false},
    28                               {testGravityDeflect, 668, "psGravityDeflect()", 0, false},
     26                              {testAberration, 666, "psAberration()", 0, false},
     27                              {testGravityDeflect, 667, "psGravityDeflect()", 0, false},
     28                              {testEOCParallax, 668, "psEOCParallax()", 0, false},
    2929                              {testEOCPrecession, 669, "psEOCPrecession()", 0, false},
    3030                              {testEOCPolar, 670, "psEOCPolar()", 0, false},
     
    4141}
    4242
    43 psS32 testEOCParallax(void)
    44 {
    45 
    46     return 0;
    47 }
    48 
    4943psS32 testAberration(void)
    5044{
     45    psSphere *actual = NULL;
     46    psSphere *apparent = psSphereAlloc();
     47    psSphere *direction = psSphereAlloc();
     48    psSphere *empty = NULL;
     49
     50    apparent->r = 0.2;
     51    apparent->d = 0.2;
     52    direction->r = 0.2035;
     53    direction->d = 0.2035;
     54
     55    empty = psAberration(empty, actual, direction, 0.1);
     56    if (empty != NULL) {
     57        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     58                "psAberration failed to return NULL for NULL apparent input.\n");
     59        return 1;
     60    }
     61    empty = psAberration(empty, apparent, actual, 0.1);
     62    if (empty != NULL) {
     63        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     64                "psAberration failed to return NULL for NULL direction input.\n");
     65        return 2;
     66    }
     67
     68    actual = psAberration(actual, apparent, direction, 0.4);
     69    printf("\nactual = r,d  = %.8g, %.8g\n", actual->r, actual->d);
     70
     71    psFree(actual);
     72    psFree(apparent);
     73    psFree(direction);
    5174
    5275    return 0;
     
    79102    }
    80103
    81 
    82104    actual = psGravityDeflection(actual, apparent, sun);
    83105    psSphere *result = psSphereSetOffset(apparent, actual, PS_SPHERICAL, PS_RADIAN);
     
    88110    psFree(apparent);
    89111    psFree(sun);
     112
     113    return 0;
     114}
     115
     116psS32 testEOCParallax(void)
     117{
    90118
    91119    return 0;
  • trunk/psLib/test/astro/tst_psSphereOps.c

    r5446 r5450  
    66*  @author d-Rob, MHPCC
    77*
    8 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    9 *  @date $Date: 2005-10-26 01:20:15 $
     8*  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     9*  @date $Date: 2005-10-28 02:25:22 $
    1010*
    1111*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7171    double q3 = cos(a3)*cos(DELTA_P/2);
    7272
    73     if (FLT_EPSILON < fabs(q0 - myST->q0)) {
     73    if (DBL_EPSILON < fabs(q0 - myST->q0)) {
    7474        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %lf, should be %lf\n", myST->q0, q0);
    7575        return 2;
    7676    }
    77     if (FLT_EPSILON < fabs(q1 - myST->q1)) {
     77    if (DBL_EPSILON < fabs(q1 - myST->q1)) {
    7878        psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1);
    7979        return 3;
    8080    }
    81     if (FLT_EPSILON < fabs(q2 - myST->q2)) {
     81    if (DBL_EPSILON < fabs(q2 - myST->q2)) {
    8282        psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2);
    8383        return 4;
    8484    }
    85     if (FLT_EPSILON < fabs(q3 - myST->q3)) {
     85    if (DBL_EPSILON < fabs(q3 - myST->q3)) {
    8686        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3);
    8787        return 5;
     
    239239
    240240        // check ecliptic transforms for correctness
    241         if (abs(RAD_TO_DEG(ecliptic->r) - lambda[x]) > TOLERANCE ||
    242                 abs(RAD_TO_DEG(ecliptic->d) - beta[x]) > TOLERANCE) {
     241        if (fabs(RAD_TO_DEG(ecliptic->r) - lambda[x]) > TOLERANCE ||
     242                fabs(RAD_TO_DEG(ecliptic->d) - beta[x]) > TOLERANCE) {
    243243            psError(PS_ERR_UNKNOWN, false,
    244244                    "Ecliptic tranformation incorrect.  Result is (%g,%g), expected (%g,%g)",
     
    247247            return 1;
    248248        }
    249         if (abs(RAD_TO_DEG(icrsFromEcliptic->r) - alpha[x]) > TOLERANCE ||
    250                 abs(RAD_TO_DEG(icrsFromEcliptic->d) - delta[x]) > TOLERANCE) {
     249        if (fabs(RAD_TO_DEG(icrsFromEcliptic->r) - alpha[x]) > TOLERANCE ||
     250                fabs(RAD_TO_DEG(icrsFromEcliptic->d) - delta[x]) > TOLERANCE) {
    251251            psError(PS_ERR_UNKNOWN, false,
    252252                    "ICRS for Ecliptic tranformation incorrect.  Result is (%g,%g), expected (%g,%g)",
     
    269269
    270270        // check ecliptic transforms for correctness
    271         if (abs(RAD_TO_DEG(galactic->r) - l[x]) > TOLERANCE ||
    272                 abs(RAD_TO_DEG(galactic->d) - b[x]) > TOLERANCE) {
     271        if (fabs(RAD_TO_DEG(galactic->r) - l[x]) > TOLERANCE ||
     272                fabs(RAD_TO_DEG(galactic->d) - b[x]) > TOLERANCE) {
    273273            psError(PS_ERR_UNKNOWN, false,
    274274                    "Galactic tranformation incorrect.  Result is (%g,%g), expected (%g,%g)",
     
    280280            return 3;
    281281        }
    282         if (abs(RAD_TO_DEG(icrsFromGalactic->r) - alpha[x]) > TOLERANCE ||
    283                 abs(RAD_TO_DEG(icrsFromGalactic->d) - delta[x]) > TOLERANCE) {
     282        if (fabs(RAD_TO_DEG(icrsFromGalactic->r) - alpha[x]) > TOLERANCE ||
     283                fabs(RAD_TO_DEG(icrsFromGalactic->d) - delta[x]) > TOLERANCE) {
    284284            psError(PS_ERR_UNKNOWN, false,
    285285                    "ICRS for Galactic tranformation incorrect.  Result is (%g,%g), expected (%g,%g)",
     
    498498    output->d *= -1.0;
    499499    empty = psSphereGetOffset(origin, output, PS_LINEAR, PS_RADIAN);
    500     if ( fabs(offset->r - empty->r) > 0.0001 || fabs(offset->d - empty->r) > 0.0001 ) {
     500    if ( fabs(offset->r - empty->r) > 0.0001 || abs(offset->d - empty->r) > 0.0001 ) {
    501501        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    502502                "psSphereGetOffset failed to return correct linear offset values.\n");
  • trunk/psLib/test/astro/verified/tst_psEarthOrientation.stderr

    r5449 r5450  
    1 /***************************** TESTPOINT ******************************************\
    2 *             TestFile: tst_psEarthOrientation.c                                   *
    3 *            TestPoint: psEarthOrientation{psEOCParallax()}                        *
    4 *             TestType: Positive                                                   *
    5 \**********************************************************************************/
    6 
    7 
    8 ---> TESTPOINT PASSED (psEarthOrientation{psEOCParallax()} | tst_psEarthOrientation.c)
    9 
    101/***************************** TESTPOINT ******************************************\
    112*             TestFile: tst_psEarthOrientation.c                                   *
     
    145\**********************************************************************************/
    156
     7<DATE><TIME>|<HOST>|E|psAberration (FILE:LINENO)
     8    Unallowable operation: apparent is NULL.
     9<DATE><TIME>|<HOST>|E|psAberration (FILE:LINENO)
     10    Unallowable operation: direction is NULL.
    1611
    1712---> TESTPOINT PASSED (psEarthOrientation{psAberration()} | tst_psEarthOrientation.c)
     
    2924
    3025---> TESTPOINT PASSED (psEarthOrientation{psGravityDeflect()} | tst_psEarthOrientation.c)
     26
     27/***************************** TESTPOINT ******************************************\
     28*             TestFile: tst_psEarthOrientation.c                                   *
     29*            TestPoint: psEarthOrientation{psEOCParallax()}                        *
     30*             TestType: Positive                                                   *
     31\**********************************************************************************/
     32
     33
     34---> TESTPOINT PASSED (psEarthOrientation{psEOCParallax()} | tst_psEarthOrientation.c)
    3135
    3236/***************************** TESTPOINT ******************************************\
  • trunk/psLib/test/astro/verified/tst_psEarthOrientation.stdout

    r5449 r5450  
     1
     2actual = r,d  = 0.10218436, 0.10218436
    13
    24Apparent r,d = 0.2035,0.2035    Actual r,d = 0.2035000000002, 0.2035000000391
Note: See TracChangeset for help on using the changeset viewer.