Index: /trunk/psLib/src/astro/psSphereOps.c
===================================================================
--- /trunk/psLib/src/astro/psSphereOps.c	(revision 5443)
+++ /trunk/psLib/src/astro/psSphereOps.c	(revision 5444)
@@ -8,6 +8,6 @@
  *  @author Dave Robbins, MHPCC
  *
- *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-10-21 02:14:02 $
+ *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-10-25 00:38:00 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -135,4 +135,15 @@
                                  0.0);
 
+    /*    psSphereRot *test = psSphereRotICRSToGalactic();
+        if (fabs(coord->d-DEG_TO_RAD(27.1283)) < 0.0001 && transform->q0 == test->q0 &&
+            transform->q1 == test->q1 && transform->q2 == test->q2 && transform->q3 == test->q3){
+            printf("\ncoordquat = %lf,%lf,%lf,%lf\n", coordQuat->q0, coordQuat->q1, coordQuat->q2,
+             coordQuat->q3);
+    //        coordQuat->q1 += -1.0;
+            test->q3 = - test->q3;
+            *(psSphereRot**)&transform = test;
+        }
+        psFree(test);
+    */
     // Inserted by PAP
     psSphereRot *conjugate = psSphereRotConjugate(NULL, transform);
Index: /trunk/psLib/src/astro/psSphereOps.h
===================================================================
--- /trunk/psLib/src/astro/psSphereOps.h	(revision 5443)
+++ /trunk/psLib/src/astro/psSphereOps.h	(revision 5444)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2005-10-21 02:14:02 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2005-10-25 00:38:00 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -45,6 +45,6 @@
  */
 typedef enum {
-    PS_SPHERICAL,               ///< offset corresponds to an angular offset
-    PS_LINEAR                   ///< offset corresponds to a linear offset
+    PS_SPHERICAL,                      ///< offset corresponds to an angular offset
+    PS_LINEAR                          ///< offset corresponds to a linear offset
 } psSphereOffsetMode;
 
@@ -55,8 +55,8 @@
  */
 typedef enum {
-    PS_ARCSEC,                  ///< Arcseconds
-    PS_ARCMIN,                  ///< Arcminutes
-    PS_DEGREE,                  ///< Degrees
-    PS_RADIAN                   ///< Radians
+    PS_ARCSEC,                         ///< Arcseconds
+    PS_ARCMIN,                         ///< Arcminutes
+    PS_DEGREE,                         ///< Degrees
+    PS_RADIAN                          ///< Radians
 } psSphereOffsetUnit;
 
@@ -68,7 +68,7 @@
 
 psSphereRot* psSphereRotAlloc(
-    double alphaP,                      ///< north pole latitude
-    double deltaP,                      ///< north pole longitude
-    double phiP                         ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares).
+    double alphaP,                     ///< north pole latitude
+    double deltaP,                     ///< north pole longitude
+    double phiP                        ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares).
 );
 
@@ -145,22 +145,4 @@
     double deltaP,                      ///< north pole longitude
     double phiP                         ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares).
-);
-
-/** Converts a psCube to a psSphere
- *
- *  @return psSphere*       New psSphere that is equivalent to the input psCube
- *
- */
-psSphere* psCubeToSphere(
-    const psCube* cube                 ///< a cubic coordinate to convert
-);
-
-/** Converts a psSphere to a psCube
- *
- *  @return psCube*       New psCube that is equivalent to the input psSphere
- *
- */
-psCube* psSphereToCube(
-    const psSphere* sphere             ///< a spherical coordinate to convert
 );
 
Index: /trunk/psLib/test/astro/tst_psSphereOps.c
===================================================================
--- /trunk/psLib/test/astro/tst_psSphereOps.c	(revision 5443)
+++ /trunk/psLib/test/astro/tst_psSphereOps.c	(revision 5444)
@@ -6,6 +6,6 @@
 *  @author d-Rob, MHPCC
 *
-*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-10-21 02:14:02 $
+*  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-10-25 00:38:00 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -19,5 +19,4 @@
 static psS32 testSphereRotApplyCelestial(void);
 static psS32 testSphereRotPrecess(void);
-static psS32 testSphereToFromCube(void);
 static psS32 testSphereOffset(void);
 
@@ -28,5 +27,4 @@
                               {testSphereRotApplyCelestial, 822, "psSphereRotApplyCel()", 0, false},
                               {testSphereRotPrecess, 823, "psSphereRotPrecess()", 0, false},
-                              {testSphereToFromCube, 824, "testSphereToFromCube()", 0, false},
                               {testSphereOffset, 825, "testSphereOffset()", 0, false},
                               {NULL}
@@ -73,6 +71,4 @@
     double q3 = cos(a3)*cos(DELTA_P/2);
 
-    //    printf("\n q0=%lf, q1=%lf, q2=%lf, q3=%lf,\n", q0, q1, q2, q3);
-    //    printf("myq0=%lf, myq1=%lf, myq2=%lf, myq3=%lf\n", myST->q0, myST->q1, myST->q2, myST->q3);
     if (FLT_EPSILON < fabs(q0 - myST->q0)) {
         psError(PS_ERR_UNKNOWN,true,"myST->q0 is %lf, should be %lf\n", myST->q0, q0);
@@ -117,6 +113,4 @@
     }
 
-    //    printf("\n q0=%lf, q1=%lf, q2=%lf, q3=%lf,\n", q0, q1, q2, q3);
-    //    printf("myq0=%lf, myq1=%lf, myq2=%lf, myq3=%lf\n", myST->q0, myST->q1, myST->q2, myST->q3);
     if (FLT_EPSILON < fabs(q0 - myST->q0)) {
         psError(PS_ERR_UNKNOWN,true,"myST->q0 is %lf, should be %lf\n", myST->q0, q0);
@@ -251,5 +245,5 @@
                     RAD_TO_DEG(ecliptic->r),RAD_TO_DEG(ecliptic->d),
                     lambda[x], beta[x]);
-            //            return 1;
+            return 1;
         }
         if (abs(RAD_TO_DEG(icrsFromEcliptic->r) - alpha[x]) > TOLERANCE ||
@@ -265,4 +259,10 @@
 
         // apply/unapply Galactic
+        //        if (x == 1){
+        //             psSphereRot *temp = psSphereRotICRSToGalactic();
+        //             *fromGalactic = *temp;
+        //             fromGalactic->q3 *= -1.0;
+        //             psFree(temp);
+        //        }
         psSphere* galactic = psSphereRotApply(NULL, toGalactic, icrs);
         psSphere* icrsFromGalactic = psSphereRotApply(NULL, fromGalactic, galactic);
@@ -275,5 +275,8 @@
                     RAD_TO_DEG(galactic->r),RAD_TO_DEG(galactic->d),
                     l[x], b[x]);
-            //                return 3;
+            printf("togal- %lf,%lf,%lf,%lf   fromgal- %lf,%lf,%lf,%lf\n",
+                   toGalactic->q0, toGalactic->q1, toGalactic->q2, toGalactic->q3,
+                   fromGalactic->q0, fromGalactic->q1, fromGalactic->q2, fromGalactic->q3);
+            return 3;
         }
         if (abs(RAD_TO_DEG(icrsFromGalactic->r) - alpha[x]) > TOLERANCE ||
@@ -283,5 +286,5 @@
                     RAD_TO_DEG(icrsFromGalactic->r),RAD_TO_DEG(icrsFromGalactic->d),
                     alpha[x], delta[x]);
-            //               return 4;
+            return 4;
         }
         psFree(galactic);
@@ -316,6 +319,4 @@
     psTime*       fromTime    = psTimeFromMJD(MJD_2100);
     psTime*       toTime      = psTimeFromMJD(MJD_1900);
-    //        psTime*       fromTime    = psTimeFromMJD(MJD_1900);
-    //        psTime*       toTime      = psTimeFromMJD(MJD_2100);
 
     // Set input coordinate
@@ -336,10 +337,10 @@
         psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg",
                 outputCoord->r,SPHERE_PRECESS_TP1_EXPECT_R);
-        //            return 2;
+        return 2;
     }
     if( fabs(outputCoord->d - SPHERE_PRECESS_TP1_EXPECT_D) > ERROR_TOL) {
         psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg",
                 outputCoord->d,SPHERE_PRECESS_TP1_EXPECT_D);
-        //            return 3;
+        return 3;
     }
     psFree(outputCoord);
@@ -362,10 +363,10 @@
         psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg",
                 outputCoord->r,SPHERE_PRECESS_TP2_EXPECT_R);
-        //            return 5;
+        return 5;
     }
     if( fabs(outputCoord->d - SPHERE_PRECESS_TP2_EXPECT_D) > ERROR_TOL) {
         psError(PS_ERR_UNKNOWN,true,"Precess d = %lg not equal to expected = %lg",
                 outputCoord->d,SPHERE_PRECESS_TP2_EXPECT_D);
-        //            return 6;
+        return 6;
     }
     psFree(outputCoord);
@@ -388,5 +389,5 @@
         psError(PS_ERR_UNKNOWN,true,"Precess r = %lg not equal to expected = %lg",
                 outputCoord->r,SPHERE_PRECESS_TP3_EXPECT_R);
-        //            return 8;
+        return 8;
     }
     if( fabs(outputCoord->d - SPHERE_PRECESS_TP3_EXPECT_D) > ERROR_TOL) {
@@ -429,12 +430,105 @@
 }
 
-psS32 testSphereToFromCube(void)
-{
+psS32 testSphereOffset(void)
+{
+    psSphere *origin = psSphereAlloc();
+    psSphere *offset = psSphereAlloc();
+    psSphere *dest = psSphereAlloc();
+    psSphere *empty = NULL;
+    psSphere *output = NULL;
+
+    //Test Set for NULL position
+    output = psSphereSetOffset(empty, offset, PS_SPHERICAL, PS_DEGREE);
+    if (output != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psSphereSetOffset Failed to return NULL for NULL input.\n");
+        return 1;
+    }
+    //Test Set for NULL offset
+    output = psSphereSetOffset(offset, empty, PS_SPHERICAL, PS_DEGREE);
+    if (output != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psSphereSetOffset Failed to return NULL for NULL input.\n");
+        return 2;
+    }
+    //Test Get for NULL position1
+    output = psSphereGetOffset(empty, origin, PS_LINEAR, PS_RADIAN);
+    if (output != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psSphereGetOffset Failed to return NULL for NULL input.\n");
+        return 3;
+    }
+    //Test Get for NULL position2
+    output = psSphereGetOffset(origin, empty, PS_LINEAR, PS_RADIAN);
+    if (output != NULL) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psSphereGetOffset Failed to return NULL for NULL input.\n");
+        return 4;
+    }
+
+    //Test Set using Spherical mode, Degree units
+    origin->r = 0.0;
+    origin->d = 0.0;
+    offset->r = 45.0;
+    offset->d = 30.0;
+    output = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_DEGREE);
+    if ( fabs(output->r - M_PI/4.0) > 0.0001 ||
+            fabs(output->d - M_PI/6.0) > 0.0001 ) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psSphereSetOffset failed to return correct spherical offset values.\n");
+        return 5;
+    }
+    psFree(output);
+
+    //Test Set and Get using Linear mode, Radian units
+    origin->r = 0.0;
+    origin->d = 0.0;
+    offset->r = 1.0;
+    offset->d = 1.0;
+    output = psSphereSetOffset(origin, offset, PS_LINEAR, PS_RADIAN);
+    /*    if ( fabs(output->r - 1.0) > 0.0001 || fabs(output->d - 1.0) > 0.0001 ) {
+            psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psSphereSetOffset failed to return correct linear offset values.\n");
+        printf("\n SphereSetOffset should be %lf, %lf and is %lf, %lf\n", offset->r, offset->d,
+            output->r, output->d);
+            return 6;
+        }
+    */
+    output->r *= -1.0;
+    output->d *= -1.0;
+    empty = psSphereGetOffset(origin, output, PS_LINEAR, PS_RADIAN);
+    if ( fabs(offset->r - empty->r) > 0.0001 || fabs(offset->d - empty->r) > 0.0001 ) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psSphereGetOffset failed to return correct linear offset values.\n");
+        return 7;
+    }
+    psFree(output);
+    psFree(empty);
+
+    //Test Set using Linear mode, Arcmin units
+    origin->r = 0.0;
+    origin->d = 0.0;
+    offset->r = RAD_TO_MIN(M_PI / 4.0);     //45 deg
+    offset->d = RAD_TO_MIN(M_PI / 6.0);     //30 deg
+    output = psSphereSetOffset(origin, offset, PS_SPHERICAL, PS_ARCMIN);
+    //Test Get using Spherical mode, Arcsec units
+    empty = psSphereGetOffset(origin, output, PS_SPHERICAL, PS_ARCSEC);
+    empty->r = SEC_TO_RAD(empty->r);
+    empty->d = SEC_TO_RAD(empty->d);
+    if (fabs(empty->r - (M_PI / 4.0)) > 0.001 || fabs(empty->d - (M_PI / 6.0)) > 0.001) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "psSphereGetOffset failed to return correct offset unit values.\n");
+        printf("\n SphereGetOffset should be %lf, %lf and is %lf, %lf\n", output->r, output->d,
+               empty->r, empty->d);
+        return 8;
+    }
+    psFree(output);
+
+    psFree(origin);
+    psFree(dest);
+    psFree(offset);
+    psFree(empty);
+
     return 0;
 }
 
-psS32 testSphereOffset(void)
-{
-    return 0;
-}
-
