Index: trunk/psLib/src/astro/psCoord.c
===================================================================
--- trunk/psLib/src/astro/psCoord.c	(revision 4581)
+++ trunk/psLib/src/astro/psCoord.c	(revision 4613)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.80 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-07-20 01:21:13 $
+*  @version $Revision: 1.81 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-07-27 00:36:01 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -212,4 +212,17 @@
     psMemSetDeallocator(s, (psFreeFunc) sphereFree);
     return(s);
+}
+
+static void cubeFree(psCube *c)
+{
+    // There are non dynamic allocated items
+}
+
+psCube* psCubeAlloc(void)
+{
+    psCube *c = psAlloc(sizeof(psCube));
+
+    psMemSetDeallocator(c, (psFreeFunc) cubeFree);
+    return(c);
 }
 
@@ -1256,2 +1269,43 @@
     return(NULL);
 }
+
+psCube *psSphereToCube(const psSphere *sphere)
+{
+    if(sphere == NULL) {
+        //        psError();
+        return NULL;
+    }
+
+    psCube *cube = NULL;
+
+    cube = psCubeAlloc();
+    cube->x = cos(sphere->d) * cos(sphere->r);
+    cube->y = cos(sphere->d) * sin(sphere->r);
+    cube->z = sin(sphere->d);
+    cube->xErr = cos(sphere->dErr) * cos(sphere->rErr);
+    cube->yErr = cos(sphere->dErr) * sin(sphere->rErr);
+    cube->zErr = sin(sphere->dErr);
+
+    return(cube);
+}
+
+psSphere *psCubeToSphere(const psCube *cube)
+{
+    if(cube == NULL) {
+        //        psError();
+        return NULL;
+    }
+
+    psSphere *sphere = NULL;
+    sphere = psSphereAlloc();
+    //    sphere->r = arctan(cube->x/cube->y);
+    //    sphere->d = arctan(sqrt(cube->x*cube->x + cube->y*cube->y)/cube->z);
+    //    sphere->rErr = arctan(cube->xErr/cube->yErr);
+    //    sphere->dErr = arctan(sqrt(cube->xErr*cube->xErr + cube->yErr*cube->yErr)/cube->zErr);
+    sphere->r = 1 / (atan(cube->x/cube->y));
+    sphere->d = 1 / (atan(sqrt(cube->x*cube->x + cube->y*cube->y)/cube->z));
+    sphere->rErr = 1 / (atan(cube->xErr/cube->yErr));
+    sphere->dErr = 1 / (atan(sqrt(cube->xErr*cube->xErr + cube->yErr*cube->yErr)/cube->zErr));
+
+    return(sphere);
+}
