Index: trunk/psLib/test/astro/tst_psSphereOps.c
===================================================================
--- trunk/psLib/test/astro/tst_psSphereOps.c	(revision 5235)
+++ trunk/psLib/test/astro/tst_psSphereOps.c	(revision 5254)
@@ -6,6 +6,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-10-07 21:27:50 $
+*  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-10-08 03:51:20 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -48,7 +48,7 @@
 #define ERROR_TOL   0.0001
 
-#define ALPHA_P 1.0
-#define DELTA_P 2.0
-#define PHI_P 3.0
+#define ALPHA_P 0.5 * M_PI
+#define DELTA_P 1.0 * M_PI
+#define PHI_P 1.5 * M_PI
 
 psS32 testSphereRotAlloc( void )
@@ -63,29 +63,35 @@
     }
     // Verify sin member is updated
-    //    double vx = cos(DELTA_P)*cos(ALPHA_P);
-    //    double vy = cos(DELTA_P)*sin(ALPHA_P);
-    //    double vz = sin(DELTA_P);
-    //    double q0 = vx * sin(PHI_P/2.0);
-    //    double q1 = vy * sin(PHI_P/2.0);
-    //    double q2 = vz * sin(PHI_P/2.0);
-    //    double q3 = cos(PHI_P/2.0);
-    /*
-        if (FLT_EPSILON < fabs(q0 - myST->q0)) {
-            psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0);
-            return 2;
-        }
-        if (FLT_EPSILON < fabs(q1 - myST->q1)) {
-            psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1);
-            return 3;
-        }
-        if (FLT_EPSILON < fabs(q2 - myST->q2)) {
-            psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2);
-            return 4;
-        }
-        if (FLT_EPSILON < fabs(q3 - myST->q3)) {
-            psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3);
-            return 5;
-        }
-    */
+    double vx = cos(DELTA_P)*cos(ALPHA_P);
+    double vy = cos(DELTA_P)*sin(ALPHA_P);
+    double vz = sin(DELTA_P);
+    double q0 = vx * sin(PHI_P/2.0);
+    double q1 = vy * sin(PHI_P/2.0);
+    double q2 = vz * sin(PHI_P/2.0);
+    double q3 = cos(PHI_P/2.0);
+    double len = sqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3);
+    printf("\nvz = %lf\n", vz);
+    q0 = q0/len;
+    q1 = q1/len;
+    q2 = q2/len;
+    q3 = q3/len;
+
+    if (FLT_EPSILON < fabs(q0 - myST->q0)) {
+        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q0, q0);
+        return 2;
+    }
+    if (FLT_EPSILON < fabs(q1 - myST->q1)) {
+        psError(PS_ERR_UNKNOWN,true,"myST->q1 is %f, should be %f\n", myST->q1, q1);
+        return 3;
+    }
+    if (FLT_EPSILON < fabs(q2 - myST->q2)) {
+        psError(PS_ERR_UNKNOWN,true,"myST->q2 is %f, should be %f\n", myST->q2, q2);
+        return 4;
+    }
+    if (FLT_EPSILON < fabs(q3 - myST->q3)) {
+        psError(PS_ERR_UNKNOWN,true,"myST->q0 is %f, should be %f\n", myST->q3, q3);
+        return 5;
+    }
+
     // Free data structure
     psFree(myST);
@@ -103,5 +109,5 @@
         psSphere *rc = NULL;
         psSphereRot *myST = psSphereRotAlloc(0.0, 0.0, 0.0);
-     
+
         for (float r=0.0;r<180.0;r+=DEG_INC) {
             for (float d=0.0;d<90.0;d+=DEG_INC) {
@@ -110,5 +116,5 @@
                 in->rErr = 0.0;
                 in->dErr = 0.0;
-     
+
                 if(psSphereRotApply(out, myST, in) != out) {
                     psError(PS_ERR_UNKNOWN,true,"Did not return output pointer.");
@@ -125,5 +131,5 @@
             }
         }
-     
+
         // Verify new sphere object is created if out parameter NULL
         temp = psSphereRotApply(NULL, myST, in);
@@ -133,5 +139,5 @@
         }
         psFree(temp);
-     
+
         // Verify NULL returned if transform structure null
         psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
@@ -141,5 +147,5 @@
             return 5;
         }
-     
+
         // Verify NULL returned when input sphere is NULL
         psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error");
@@ -149,5 +155,5 @@
             return 6;
         }
-     
+
         psFree(myST);
         psFree(out);
@@ -180,6 +186,6 @@
         psSphereRot *mySphereRotForward = NULL;
         psSphereRot *mySphereRotReverse = NULL;
-     
-     
+
+
         mySphereRotForward = psSphereRotAlloc(DEG_TO_RAD(22.0),
                                               0.0,
@@ -188,5 +194,5 @@
                                               0.0,
                                               0.0);
-     
+
         for (float r=0.1;r<180.0;r+=(DEG_INC/5.0)) {
             for (float d=0.1;d<90.0;d+=(DEG_INC/5.0)) {
@@ -195,8 +201,8 @@
                 in.rErr = 0.0;
                 in.dErr = 0.0;
-     
+
                 psSphereRotApply(&out, mySphereRotForward, &in);
                 psSphereRotApply(&out2, mySphereRotReverse, &out);
-     
+
                 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) ||
                         (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) {
@@ -210,5 +216,5 @@
         psFree(mySphereRotForward);
         psFree(mySphereRotReverse);
-     
+
         mySphereRotForward = psSphereRotAlloc(0.0,
                                               DEG_TO_RAD(33.0),
@@ -223,8 +229,8 @@
                 in.rErr = 0.0;
                 in.dErr = 0.0;
-     
+
                 psSphereRotApply(&out, mySphereRotForward, &in);
                 psSphereRotApply(&out2, mySphereRotReverse, &out);
-     
+
                 if ((fabs((in.r - out2.r) / in.r) > ERROR_PERCENT) ||
                         (fabs((in.d - out2.d) / in.d) > ERROR_PERCENT)) {
@@ -238,5 +244,5 @@
         psFree(mySphereRotForward);
         psFree(mySphereRotReverse);
-     
+
         return(testStatus);
         */
@@ -257,13 +263,13 @@
         double l[] =     { 96.337272, 122.93192, 195.639488};
         double b[] =     {-60.188553,  27.12825,  78.353806};
-     
+
         double t[] =     {  MJD_2000,  MJD_2000,   MJD_2100};
-     
+
         double TOLERANCE = 0.001;
-     
-     
-     
+
+
+
         for (int x = 0; x < numTestPoints; x++) {
-     
+
             psTime* time = psTimeFromMJD(t[x]);
             psSphereRot* toEcliptic = psSphereRotICRSToEcliptic(time);
@@ -272,14 +278,14 @@
             psSphereRot* fromGalactic = psSphereRotGalacticToICRS();
             psFree(time);
-     
+
             // set the ICRS coordinate
             psSphere* icrs = psSphereAlloc();
             icrs->r = DEG_TO_RAD(alpha[x]);
             icrs->d = DEG_TO_RAD(delta[x]);
-     
+
             // apply/unapply Ecliptic
             psSphere* ecliptic = psSphereRotApply(NULL, toEcliptic, icrs);
             psSphere* icrsFromEcliptic = psSphereRotApply(NULL, fromEcliptic, ecliptic);
-     
+
             // check ecliptic transforms for correctness
             if (abs(RAD_TO_DEG(ecliptic->r) - lambda[x]) > TOLERANCE ||
@@ -301,9 +307,9 @@
             psFree(ecliptic);
             psFree(icrsFromEcliptic);
-     
+
             // apply/unapply Galactic
             psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs);
             psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic);
-     
+
             // check ecliptic transforms for correctness
             if (abs(RAD_TO_DEG(galactic->r) - l[x]) > TOLERANCE ||
@@ -325,10 +331,10 @@
             psFree(galactic);
             psFree(icrsFromGalactic);
-     
+
             psFree(toEcliptic);
             psFree(fromEcliptic);
             psFree(toGalactic);
             psFree(fromGalactic);
-     
+
         }
     */
@@ -356,5 +362,5 @@
         psTime*       fromTime    = psTimeFromMJD(MJD_2100);
         psTime*       toTime      = psTimeFromMJD(MJD_1900);
-     
+
         // Set input coordinate
         inputCoord->r = SPHERE_PRECESS_TP1_R;
@@ -362,5 +368,5 @@
         inputCoord->rErr = 0.0;
         inputCoord->dErr = 0.0;
-     
+
         // Calculate precess
         outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
@@ -382,5 +388,5 @@
         }
         psFree(outputCoord);
-     
+
         // Set input coordinate
         inputCoord->r = SPHERE_PRECESS_TP2_R;
@@ -388,5 +394,5 @@
         inputCoord->rErr = 0.0;
         inputCoord->dErr = 0.0;
-     
+
         // Calculate precess
         outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
@@ -408,5 +414,5 @@
         }
         psFree(outputCoord);
-     
+
         // Set input coordinate
         inputCoord->r = SPHERE_PRECESS_TP3_R;
@@ -414,5 +420,5 @@
         inputCoord->rErr = 0.0;
         inputCoord->dErr = 0.0;
-     
+
         // Calculate precess
         outputCoord = psSpherePrecess(inputCoord, fromTime, toTime);
@@ -434,5 +440,5 @@
         }
         psFree(outputCoord);
-     
+
         // Invoke precess with invalid parameter
         psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
@@ -442,5 +448,5 @@
             return 10;
         }
-     
+
         // Invoke precess with invalid parameter
         psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
@@ -450,5 +456,5 @@
             return 11;
         }
-     
+
         // Invoke precess with invalid parameter
         psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message");
@@ -458,5 +464,5 @@
             return 12;
         }
-     
+
         // Free objects
         psFree(fromTime);
