IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3351


Ignore:
Timestamp:
Mar 1, 2005, 11:38:23 AM (21 years ago)
Author:
evanalst
Message:

Update psSphereTransform functions to pass unit tests.

Location:
trunk/psLib/src
Files:
2 edited

Legend:

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

    r3334 r3351  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-02-25 22:28:42 $
     12*  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-03-01 21:38:23 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    264264XXX: Private Function.
    265265 
    266 piNormalize(): take an input angle in radians and convert it to the range 0:PI.
     266piNormalize(): take an input angle in radians and convert it to the range 0:2*PI.
    267267 *****************************************************************************/
    268268psF32 piNormalize(psF32 angle)
    269269{
    270270    while (angle < FLT_EPSILON) {
    271         angle+=PS_PI;
    272     }
    273 
    274     while (angle >= PS_PI) {
    275         angle-=PS_PI;
     271        angle+=PS_PI*2;
     272    }
     273
     274    while (angle >= (PS_PI*2)) {
     275        angle-=PS_PI*2;
    276276    }
    277277    return(angle);
     
    299299    psF64 eq55 = (sin(delta) * transform->cosDeltaP) -
    300300                 (cos(delta) * transform->sinDeltaP * sin(alphaMinusAlphaP));
    301 
    302301    psF64 eq56 = (cos(delta) * transform->cosDeltaP * sin(alphaMinusAlphaP)) +
    303302                 (sin(delta) * transform->sinDeltaP);
    304 
    305303    psF64 eq57 = cos(delta) * cos(alphaMinusAlphaP);
    306304
    307305    psF64 theta = asin(eq55);
    308     psF64 phi = atan2(eq56, eq57) + transform->alphaP;
    309 
    310 
     306    psF64 phi = atan2(eq56, eq57) + transform->phiP;
    311307    out->r = piNormalize(phi);
    312308    out->d = theta;
     
    344340
    345341    // Don't neglect the minus sign on deltaP (bug 244):
    346     return (psSphereTransformAlloc(alphaP, -deltaP, phiP));
     342    return (psSphereTransformAlloc(alphaP, deltaP, phiP));
    347343}
    348344
     
    376372    psF64 phiP = 0.0;
    377373
    378     return (psSphereTransformAlloc(alphaP, deltaP, phiP));
     374    return (psSphereTransformAlloc(alphaP, -deltaP, phiP));
    379375}
    380376
    381377// XXX: This is bug 245: alphaP swaps with phiP from psSphereTransformGalacticToICRS()
    382 psSphereTransform* psSphereTransformICRSToGalactic(void)
     378psSphereTransform* psSphereTransformGalacticToICRS(void)
    383379{
    384380    psF64 alphaP = DEG_TO_RAD(32.93192);
     
    389385}
    390386
    391 psSphereTransform* psSphereTransformGalacticToICRS(void)
     387psSphereTransform* psSphereTransformICRSToGalactic(void)
    392388{
    393389    psF64 alphaP = DEG_TO_RAD(282.85948);
  • trunk/psLib/src/astronomy/psCoord.c

    r3334 r3351  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-02-25 22:28:42 $
     12*  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-03-01 21:38:23 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    264264XXX: Private Function.
    265265 
    266 piNormalize(): take an input angle in radians and convert it to the range 0:PI.
     266piNormalize(): take an input angle in radians and convert it to the range 0:2*PI.
    267267 *****************************************************************************/
    268268psF32 piNormalize(psF32 angle)
    269269{
    270270    while (angle < FLT_EPSILON) {
    271         angle+=PS_PI;
    272     }
    273 
    274     while (angle >= PS_PI) {
    275         angle-=PS_PI;
     271        angle+=PS_PI*2;
     272    }
     273
     274    while (angle >= (PS_PI*2)) {
     275        angle-=PS_PI*2;
    276276    }
    277277    return(angle);
     
    299299    psF64 eq55 = (sin(delta) * transform->cosDeltaP) -
    300300                 (cos(delta) * transform->sinDeltaP * sin(alphaMinusAlphaP));
    301 
    302301    psF64 eq56 = (cos(delta) * transform->cosDeltaP * sin(alphaMinusAlphaP)) +
    303302                 (sin(delta) * transform->sinDeltaP);
    304 
    305303    psF64 eq57 = cos(delta) * cos(alphaMinusAlphaP);
    306304
    307305    psF64 theta = asin(eq55);
    308     psF64 phi = atan2(eq56, eq57) + transform->alphaP;
    309 
    310 
     306    psF64 phi = atan2(eq56, eq57) + transform->phiP;
    311307    out->r = piNormalize(phi);
    312308    out->d = theta;
     
    344340
    345341    // Don't neglect the minus sign on deltaP (bug 244):
    346     return (psSphereTransformAlloc(alphaP, -deltaP, phiP));
     342    return (psSphereTransformAlloc(alphaP, deltaP, phiP));
    347343}
    348344
     
    376372    psF64 phiP = 0.0;
    377373
    378     return (psSphereTransformAlloc(alphaP, deltaP, phiP));
     374    return (psSphereTransformAlloc(alphaP, -deltaP, phiP));
    379375}
    380376
    381377// XXX: This is bug 245: alphaP swaps with phiP from psSphereTransformGalacticToICRS()
    382 psSphereTransform* psSphereTransformICRSToGalactic(void)
     378psSphereTransform* psSphereTransformGalacticToICRS(void)
    383379{
    384380    psF64 alphaP = DEG_TO_RAD(32.93192);
     
    389385}
    390386
    391 psSphereTransform* psSphereTransformGalacticToICRS(void)
     387psSphereTransform* psSphereTransformICRSToGalactic(void)
    392388{
    393389    psF64 alphaP = DEG_TO_RAD(282.85948);
Note: See TracChangeset for help on using the changeset viewer.