Index: trunk/psLib/src/astronomy/psCoord.h
===================================================================
--- trunk/psLib/src/astronomy/psCoord.h	(revision 4401)
+++ trunk/psLib/src/astronomy/psCoord.h	(revision 4540)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-06-27 20:38:11 $
+*  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-07-12 19:12:00 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -24,5 +24,5 @@
 #include "psList.h"
 #include "psFunctions.h"
-#include "psTime.h"
+// N.B. inclusion of psTime.h was done to after the typedefs to handle cross-dependency of typedefs
 
 /// @addtogroup CoordinateTransform
@@ -38,8 +38,8 @@
 typedef struct
 {
-    double x;                   ///< x position
-    double y;                   ///< y position
-    double xErr;                ///< Error in x position
-    double yErr;                ///< Error in y position
+    double x;                          ///< x position
+    double y;                          ///< y position
+    double xErr;                       ///< Error in x position
+    double yErr;                       ///< Error in y position
 }
 psPlane;
@@ -52,12 +52,40 @@
  *
  */
-typedef struct psSphere
-{
-    double r;                   ///< RA
-    double d;                   ///< Dec
-    double rErr;                ///< Error in RA
-    double dErr;                ///< Error in Dec
+typedef struct
+{
+    double r;                          ///< RA
+    double d;                          ///< Dec
+    double rErr;                       ///< Error in RA
+    double dErr;                       ///< Error in Dec
 }
 psSphere;
+
+/** Cubic Coordinate System
+ *
+ */
+typedef struct
+{
+    double x;                          ///< cos (DEC) cos (RA)
+    double y;                          ///< cos (DEC) sic (RA)
+    double z;                          ///< sin (DEC)
+    double xErr;                       ///< Error in x
+    double yErr;                       ///< Error in y
+    double zErr;                       ///< Error in z
+}
+psCube;
+
+/** Spherical rotations represent coordinate transformation in 3-D, as well as
+ *  the effects of precession and nutation.  The structure contains the
+ *  elements of a quaternion to represent the spherical rotational.
+ *
+ */
+typedef struct
+{
+    double q0;                         ///< first element of the quaternion
+    double q1;                         ///< second element of the quaternion
+    double q2;                         ///< third element of the quaternion
+    double q3;                         ///< fourth element of the quaternion
+}
+psSphereRot;
 
 /** 2D Polynomial Transform
@@ -94,23 +122,4 @@
 }
 psPlaneDistort;
-
-/** Spherical Transform Definition
- *
- *  We need to be able to convert between ICRS, Galactic and Ecliptic
- *  coordinates, and potentially between arbitrary spherical coordinate
- *  systems. All of these basic spherical transformations represent rotations
- *  of the spherical coordinate reference. We specify a general
- *  transformation function which takes a structure, psSphereTransform,
- *  defining the transformation between two spherical coordinate systems
- *
- */
-typedef struct
-{
-    double alphaP;                    ///< Longitude of the target system pole in the source system
-    double cosDeltaP;                 ///< Cosine of target pole latitude in the source system
-    double sinDeltaP;                 ///< Sine of target pole latitude in the source system
-    double phiP;                      ///< Longitude of the ascending node in the target system
-}
-psSphereTransform;
 
 /** Projection type for projection/deprojection
@@ -167,4 +176,6 @@
 } psSphereOffsetUnit;
 
+#include "psTime.h"
+
 /** Allocates a psPlane
  *
@@ -178,7 +189,28 @@
  *  @return psSphere*     resulting sphere structure.
  */
-
 psSphere* psSphereAlloc(void);
 
+/** psSphereRot allocator which defines the rotation in terms of the coordinate
+ *  of the pole and the rotation about that pole.
+ *
+ *  @return psSphereRot*       Newly allocated psSphereRot object
+ */
+psSphereRot* psSphereRotAlloc(
+    double alphaP,
+    double deltaP,
+    double phiP
+);
+
+/** psSphereRot allocator which defines the rotation from the elements of the
+ *  quaternion.
+ *
+ *  @return psSphereRot*       Newly allocated psSphereRot object
+ */
+psSphereRot* psSphereRotQuat(
+    double q0,
+    double q1,
+    double q2,
+    double q3
+);
 
 /** Allocates a psPlaneTransform transform.
@@ -186,5 +218,4 @@
  *  @return psPlaneTransform*     resulting plane transform
  */
-
 psPlaneTransform* psPlaneTransformAlloc(
     int n1,                            ///< The order of the x term in the transform.
@@ -227,23 +258,32 @@
 );
 
-/** Allocator for psSphereTransform
- *
- *  @return psSphereTransform*         newly allocated struct
- */
-
-psSphereTransform* psSphereTransformAlloc(
-    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).
-);
-
-/** Applies the psSphereTransform transform for a specified coordinate
+
+/** Applies the psSphereRot transform for a specified coordinate
  *
  *  @return psSphere*      resulting coordinate based on transform
  */
-psSphere* psSphereTransformApply(
+psSphere* psSphereRotApply(
     psSphere* out,                     ///< a psSphere to recycle.  If NULL, a new one is generated.
-    const psSphereTransform* transform,///< the transform to apply
+    const psSphereRot* transform,      ///< the transform to apply
     const psSphere* coord              ///< the coordinate to apply the transform above.x
+);
+
+/** Combines two rotations to produce a single rotation which is equivalent of
+ *  applying the first rotation and then the second.
+ *
+ *  @return psSphereRot*               new psSphereRot transform
+ */
+psSphereRot* psSphereRotCombine(
+    psSphereRot* out,
+    const psSphereRot* rot1,
+    const psSphereRot* rot2
+);
+
+/** Inverts a psSphereRot's rotation.
+ *
+ *  @return psSphereRot*               The inverted psSphereRot
+ */
+psSphereRot* psSphereRotInvert(
+    psSphereRot* rot                   ///< the psSphereRot to invert
 );
 
@@ -251,8 +291,8 @@
  *  coordinate systems.
  *
- *  @return psSphereTransform*     transform for ICRS->Ecliptic coordinate systems
- */
-psSphereTransform* psSphereTransformICRSToEcliptic(
-    psTime *time                        ///< the time for which the resulting transform will be valid
+ *  @return psSphereRot*               transform for ICRS->Ecliptic coordinate systems
+ */
+psSphereRot* psSphereRotICRSToEcliptic(
+    const psTime* time                 ///< the time for which the resulting transform will be valid
 );
 
@@ -260,8 +300,8 @@
  *  coordinate systems.
  *
- *  @return psSphereTransform*     transform for Ecliptic->ICRS coordinate systems
- */
-psSphereTransform* psSphereTransformEclipticToICRS(
-    psTime *time                        ///< the time for which the resulting transform will be valid
+ *  @return psSphereRot*               transform for Ecliptic->ICRS coordinate systems
+ */
+psSphereRot* psSphereRotEclipticToICRS(
+    const psTime* time                 ///< the time for which the resulting transform will be valid
 );
 
@@ -270,5 +310,5 @@
  *
  */
-psSphereTransform* psSphereTransformICRSToGalactic(void);
+psSphereRot* psSphereRotICRSToGalactic(void);
 
 /** Creates the appropriate transform for converting from Galactic to ICRS
@@ -276,5 +316,5 @@
  *
  */
-psSphereTransform* psSphereTransformGalacticToICRS(void);
+psSphereRot* psSphereRotGalacticToICRS(void);
 
 /** Allocates memory for a psProjection structure
