IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 20, 2005, 4:14:02 PM (21 years ago)
Author:
drobbin
Message:

Implemented, debugged, fixed psSphereRot functions/tests. 1 problem remains + testing.

File:
1 edited

Legend:

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

    r5368 r5437  
    88 *  @author Dave Robbins, MHPCC
    99 *
    10  *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2005-10-18 22:14:47 $
     10 *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2005-10-21 02:14:02 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    6262
    6363    // calculate t*s*r.
    64     psSphereRot* result = psSphereRotCombine(NULL,&t,&s);
    65     psSphereRotCombine(result,result,&r);
     64    psSphereRot* temp = psSphereRotCombine(NULL,&t,&s);
     65    psSphereRot* result = psSphereRotCombine(NULL, temp, &r);
     66    psFree(temp);
    6667
    6768    return result;
     
    8990
    9091    return rot;
     92}
     93
     94psSphereRot* psSphereRotConjugate(psSphereRot *out, const psSphereRot *in)
     95{
     96    if (in == NULL) {
     97        psError(PS_ERR_BAD_PARAMETER_NULL, true,
     98                "psSphereRot input cannot be NULL.\n");
     99        return NULL;
     100    }
     101    if (out == NULL) {
     102        out = (psSphereRot* ) psAlloc(sizeof(psSphereRot));
     103        psMemSetDeallocator(out, (psFreeFunc)sphereRotFree);
     104    }
     105    out->q0 = -in->q0;
     106    out->q1 = -in->q1;
     107    out->q2 = -in->q2;
     108    out->q3 = in->q3;
     109
     110    return out;
    91111}
    92112
     
    115135                                 0.0);
    116136
     137    // Inserted by PAP
     138    psSphereRot *conjugate = psSphereRotConjugate(NULL, transform);
     139    psSphereRot *temp = psSphereRotCombine(NULL, transform, coordQuat);
     140    psSphereRot *result = psSphereRotCombine(NULL, temp, conjugate);
     141    out->r = atan2(result->q1, result->q0);
     142    //    out->r = atan2(result->q1, result->q0);
     143    out->d = asin(result->q2);
     144    out->rErr = 0.0;
     145    out->dErr = 0.0;
     146
     147    if (out->r < -0.0001) {
     148        out->r += 2.0 * M_PI;
     149    }
     150
     151    psFree(conjugate);
     152    psFree(temp);
     153    psFree(result);
     154    psFree(coordQuat);
     155    return out;
     156    // Pau.
     157
     158    #if 0
    117159    //    psSphereRot* coordQuatConjugate = psSphereRotQuat(
    118160    //                                       coordQuat->q0, coordQuat->q1, coordQuat->q2, coordQuat->q3);
     
    158200
    159201    return out;
     202    #endif
    160203}
    161204
     
    194237}
    195238
    196 psSphereRot *psSphereRotInvert(psSphereRot *rot)
    197 {
    198     if (rot == NULL) {
    199         return NULL;
    200         // XXX: Error?
    201     }
    202 
    203     rot->q0 = -rot->q0;
    204     rot->q1 = -rot->q1;
    205     rot->q2 = -rot->q2;
    206 
    207     //    rot->q3 = rot->q3;
    208     return rot;
    209 }
    210 
     239psSphereRot *psSphereRotInvert(double alphaP,
     240                               double deltaP,
     241                               double phiP)
     242{
     243    return (psSphereRotAlloc(-phiP, -deltaP, -alphaP));
     244}
    211245
    212246psSphereRot* psSphereRotEclipticToICRS(const psTime *time)
     247{
     248    psF64 T;
     249
     250    // Check for null parameter
     251    PS_ASSERT_PTR_NON_NULL(time, NULL);
     252
     253    // Convert psTime to MJD
     254    psF64 MJD = psTimeToMJD(time);
     255
     256    // Check the specified MJD is greater than 1900
     257    if ( MJD < MJD_1900 ) {
     258        psError(PS_ERR_BAD_PARAMETER_TYPE,true,PS_ERRORTEXT_psCoord_INVALID_MJD);
     259        return NULL;
     260    }
     261
     262    // Calculate number of Julian centuries since 1900
     263    T = ( MJD - MJD_1900 ) / JULIAN_CENTURY;
     264
     265    psF64 phiP = - DEG_TO_RAD(270.0);
     266    psF64 deltaP = - (DEG_TO_RAD(23.0) +
     267                      MIN_TO_RAD(27.0) +
     268                      SEC_TO_RAD(8.26) -
     269                      (SEC_TO_RAD(46.845) * T) -
     270                      (SEC_TO_RAD(0.0059) * T * T) +
     271                      (SEC_TO_RAD(0.00181) * T * T * T));
     272    psF64 alphaP = - DEG_TO_RAD(90.0);
     273
     274    return (psSphereRotAlloc(alphaP, deltaP, phiP));
     275}
     276
     277psSphereRot* psSphereRotICRSToEcliptic(const psTime *time)
    213278{
    214279    psF64 T;
     
    241306}
    242307
    243 psSphereRot* psSphereRotICRSToEcliptic(const psTime *time)
    244 {
    245     return psSphereRotInvert(psSphereRotEclipticToICRS(time));
    246 }
    247 
    248308// XXX: This is bug 245: alphaP swaps with phiP from psSphereTransformGalacticToICRS()
    249309psSphereRot* psSphereRotGalacticToICRS(void)
    250310{
     311    /*    psF64 phiP = - DEG_TO_RAD(180.0-192.85948);
     312        psF64 deltaP = - DEG_TO_RAD(90.0 - 27.12825);
     313        psF64 alphaP = - DEG_TO_RAD(90.0+32.93192);
     314    */
    251315    psF64 alphaP = DEG_TO_RAD(180.0-192.85948);
    252     psF64 deltaP = DEG_TO_RAD(90.0-62.87175);
     316    psF64 deltaP = DEG_TO_RAD(90.0 - 27.12825);
    253317    psF64 phiP = DEG_TO_RAD(90.0+32.93192);
     318    return (psSphereRotAlloc(-phiP,-deltaP,-alphaP));
     319}
     320
     321psSphereRot* psSphereRotICRSToGalactic(void)
     322{
     323    psF64 alphaP = DEG_TO_RAD(180.0-192.85948);
     324    psF64 deltaP = DEG_TO_RAD(90.0 - 27.12825);
     325    psF64 phiP = DEG_TO_RAD(90.0+32.93192);
    254326
    255327    return (psSphereRotAlloc(alphaP, deltaP, phiP));
    256 }
    257 
    258 psSphereRot* psSphereRotICRSToGalactic(void)
    259 {
    260     return psSphereRotInvert(psSphereRotGalacticToICRS());
    261328}
    262329
     
    479546    // Calculate conversion constants
    480547    //    psF64 alphaP = DEG_TO_RAD(90.0) - ((DEG_TO_RAD(0.6406161) * T) +
    481     psF64 alphaP = DEG_TO_RAD(180.0) - ((DEG_TO_RAD(0.6406161) * T) +
     548    psF64 alphaP = DEG_TO_RAD(180.0) + ((DEG_TO_RAD(0.6406161) * T) +
    482549                                        (DEG_TO_RAD(0.0000839) * T * T) +
    483550                                        (DEG_TO_RAD(0.000005) * T * T * T));
     
    497564    // Apply transform to coordinates
    498565    psSphere *out = psSphereRotApply(NULL, tmpST, coords);
     566    if (out->r < -0.0001) {
     567        out->r += 2.0 * M_PI;
     568    }
    499569
    500570    psFree(tmpST);
Note: See TracChangeset for help on using the changeset viewer.