Index: trunk/psLib/src/astro/psCoord.c
===================================================================
--- trunk/psLib/src/astro/psCoord.c	(revision 3334)
+++ trunk/psLib/src/astro/psCoord.c	(revision 3351)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-02-25 22:28:42 $
+*  @version $Revision: 1.56 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-03-01 21:38:23 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -264,14 +264,14 @@
 XXX: Private Function.
  
-piNormalize(): take an input angle in radians and convert it to the range 0:PI.
+piNormalize(): take an input angle in radians and convert it to the range 0:2*PI.
  *****************************************************************************/
 psF32 piNormalize(psF32 angle)
 {
     while (angle < FLT_EPSILON) {
-        angle+=PS_PI;
-    }
-
-    while (angle >= PS_PI) {
-        angle-=PS_PI;
+        angle+=PS_PI*2;
+    }
+
+    while (angle >= (PS_PI*2)) {
+        angle-=PS_PI*2;
     }
     return(angle);
@@ -299,14 +299,10 @@
     psF64 eq55 = (sin(delta) * transform->cosDeltaP) -
                  (cos(delta) * transform->sinDeltaP * sin(alphaMinusAlphaP));
-
     psF64 eq56 = (cos(delta) * transform->cosDeltaP * sin(alphaMinusAlphaP)) +
                  (sin(delta) * transform->sinDeltaP);
-
     psF64 eq57 = cos(delta) * cos(alphaMinusAlphaP);
 
     psF64 theta = asin(eq55);
-    psF64 phi = atan2(eq56, eq57) + transform->alphaP;
-
-
+    psF64 phi = atan2(eq56, eq57) + transform->phiP;
     out->r = piNormalize(phi);
     out->d = theta;
@@ -344,5 +340,5 @@
 
     // Don't neglect the minus sign on deltaP (bug 244):
-    return (psSphereTransformAlloc(alphaP, -deltaP, phiP));
+    return (psSphereTransformAlloc(alphaP, deltaP, phiP));
 }
 
@@ -376,9 +372,9 @@
     psF64 phiP = 0.0;
 
-    return (psSphereTransformAlloc(alphaP, deltaP, phiP));
+    return (psSphereTransformAlloc(alphaP, -deltaP, phiP));
 }
 
 // XXX: This is bug 245: alphaP swaps with phiP from psSphereTransformGalacticToICRS()
-psSphereTransform* psSphereTransformICRSToGalactic(void)
+psSphereTransform* psSphereTransformGalacticToICRS(void)
 {
     psF64 alphaP = DEG_TO_RAD(32.93192);
@@ -389,5 +385,5 @@
 }
 
-psSphereTransform* psSphereTransformGalacticToICRS(void)
+psSphereTransform* psSphereTransformICRSToGalactic(void)
 {
     psF64 alphaP = DEG_TO_RAD(282.85948);
