Index: /trunk/archive/pslib/include/psAstrom.h
===================================================================
--- /trunk/archive/pslib/include/psAstrom.h	(revision 622)
+++ /trunk/archive/pslib/include/psAstrom.h	(revision 623)
@@ -96,6 +96,6 @@
 
     psMetadata *md;			///< Chip-level metadata
-    psCoordXform *chipToFPA;            ///< Transformations from chip coordinates to FPA coordinates
-    psCoordXform *FPAtoChip;		///< Transformations from FPA coordinates to chip
+    psPlaneCoordXform *chipToFPA;	///< Transformations from chip coordinates to FPA coordinates
+    psPlaneCoordXform *FPAtoChip;	///< Transformations from FPA coordinates to chip
 
     struct psFPA *parentFPA;		///< FPA which contains this chip
@@ -110,7 +110,7 @@
     psMetadata *md;			///< Cell-level metadata
 
-    psCoordXform *cellToChip;		///< Transformations from cell coordinates to chip coordinates
-    psCoordXform *cellToFPA;		///< Transformations from cell coordinates to FPA coordinates
-    psCoordXform *cellToSky;		///< Quick and Dirty transformations from cell coordinates to sky
+    psPlaneCoordXform *cellToChip;	///< Transformations from cell coordinates to chip coordinates
+    psPlaneCoordXform *cellToFPA;	///< Transformations from cell coordinates to FPA coordinates
+    psPlaneCoordXform *cellToSky;	///< Quick and Dirty transformations from cell coordinates to sky
 
     struct psChip  *parentChip;		///< chip which contains this cell
@@ -137,6 +137,6 @@
 psChip *
 psChipInFPA (psChip *out,		///< Chip to return, or NULL
+	     const psPlaneCoord *coord	///< coordinate in FPA
 	     const psFPA *fpa, 		///< FPA description
-	     const psCoord *coord	///< coordinate in FPA
 	     );
 
@@ -144,6 +144,6 @@
 psCell *
 psCellInChip(psCell *out,		///< Cell to return, or NULL
+	     const psPlaneCoord *coord	///< coordinate in chip
 	     const psChip *chip,	///< chip description
-	     const psCoord *coord	///< coordinate in chip
 	     );
 
@@ -151,96 +151,97 @@
 psCell *
 psCellInFPA(psCell *out,		///< Cell to return, or NULL
+	    const psPlaneCoord *coord	///< Coordinate in FPA
 	    const psFPA *fpa,		///< FPA description
-	    const psCoord *coord	///< Coordinate in FPA
 	    );
 
 
 /** Convert (RA,Dec) to cell and cell coordinates */
-psCoord *
-psCoordSkyToCell(psCoord *out,		///< Coordinates to return, or NULL
+psPlaneCoord *
+psCoordSkyToCell(psPlaneCoord *out,	///< Coordinates to return, or NULL
 		 psCell *cell,		///< Cell to return
+		 const psSphereCoord *in, ///< Input coordinates
 		 const psFPA *fpa	///< FPA description
 		 );
 
 /** Convert cell and cell coordinate to (RA,Dec) */
-psCoord *
-psCoordCellToSky(psCoord *out,		///< Coordinates to return, or NULL
+psSphereCoord *
+psCoordCellToSky(psSphereCoord *out,	///< Coordinates to return, or NULL
+		 const psPlaneCoord *coord ///< cell coordinates to transform
 		 const psCell *cell,	///< Cell to get coordinates for
-		 const psCoord *coord	///< cell coordinates to transform
 		 );
 
 /** Quick and dirty cell to (RA,Dec) --- employs cellToSky transformation */
-psCoord *
-psCoordCellToSkyQuick(psCoord *out,	///< Coordinates to return, or NULL
+psSphereCoord *
+psCoordCellToSkyQuick(psSphereCoord *out, ///< Coordinates to return, or NULL
+		      const psPlaneCoord *coord	///< cell coordinates to transform
 		      const psCell *cell, ///< Cell description
-		      const psCoord *coord ///< cell coordinates to transform
 		      );
 
 /** Convert (RA,Dec) to tangent plane coords */
-psCoord *
-psCoordSkyToTP(psCoord *out,		///< Coordinates to return, or NULL
-	       const psExposure *exp,	///< Exposure description
-	       const psCoord *coord	///< input Sky coordinate
+psPlaneCoord *
+psCoordSkyToTP(psPlaneCoord *out,	///< Coordinates to return, or NULL
+	       const psSphereCoord *coord ///< input Sky coordinate
+	       const psGrommit *grommit, ///< Grommit for fast conversion
 	       );
 
 /** Convert tangent plane coords to focal plane coordinates */
-psCoord *
-psCoordTPtoFPA(psCoord *out,		///< Coordinates to return, or NULL
+psPlaneCoord *
+psCoordTPtoFPA(psPlaneCoord *out,	///< Coordinates to return, or NULL
+	       const psPlaneCoord *coord ///< input TP coordinate
 	       const psFPA *fpa,	///< FPA description
-	       const psCoord *coord	///< input TP coordinate
 	       );
 
 /** converts the specified FPA coord to the coord on the given Chip */
-psCoord *
-psCoordFPAtoChip (psCoord *out,		///< Coordinates to return, or NULL
+psPlaneCoord *
+psCoordFPAtoChip (psPlaneCoord *out,	///< Coordinates to return, or NULL
+		  const psPlaneCoord *coord ///< input FPA coordinate
 		  const psChip *chip,	///< Chip of interest
-		  const psCoord *coord	///< input FPA coordinate
 		  ); 
 
 /** converts the specified Chip coord to the coord on the given Cell */
-psCoord *
-psCoordChiptoCell (psCoord *out,	///< Coordinates to return, or NULL
+psPlaneCoord *
+psCoordChiptoCell (psPlaneCoord *out,	///< Coordinates to return, or NULL
+		   const psPlaneCoord *coord ///< input Chip coordinate
 		   const psCell *cell, 	///< Cell of interest
-		   const psCoord *coord	///< input Chip coordinate
 		   );
 
 /** converts the specified Cell coord to the coord on the parent Chip */
-psCoord *
-psCoordCelltoChip (psCoord *out,	///< Coordinates to return, or NULL
+psPlaneCoord *
+psCoordCelltoChip (psPlaneCoord *out,	///< Coordinates to return, or NULL
+		   const psPlaneCoord *coord ///< input Cell coordinate
 		   const psCell *cell, 	///< Cell description
-		   const psCoord *coord	///< input Cell coordinate
 		   );
 
 /** converts the specified Chip coord to the coord on the parent FPA */
-psCoord *
-psCoordChiptoFPA (psCoord *out,		///< Coordinates to return, or NULL
+psPlaneCoord *
+psCoordChiptoFPA (psPlaneCoord *out,		///< Coordinates to return, or NULL
+		  const psPlaneCoord *coord	///< input Chip coordinate
 		  const psChip *chip, 	///< Chip description
-		  const psCoord *coord	///< input Chip coordinate
 		  );
 
 /** Convert focal plane coords to tangent plane coordinates */
-psCoord *
-psCoordFPAToTP(psCoord *out,		///< Coordinates to return, or NULL
+psPlaneCoord *
+psCoordFPAToTP(psPlaneCoord *out,		///< Coordinates to return, or NULL
+	       const psPlaneCoord *coord ///< input FPA coordinate
 	       const psFPA *fpa,	///< FPA description
-	       const psCoord *coord	///< input FPA coordinate
 	       );
 
 /** Convert tangent plane coords to (RA,Dec) */
-psCoord *
-psCoordTPtoSky(psCoord *out,		///< Coordinates to return, or NULL
-	       const psExposure *exp,	///< Exposure description
-	       const psCoord *coord	///< input TP coordinate
+psSphereCoord *
+psCoordTPtoSky(psSphereCoord *out,	///< Coordinates to return, or NULL
+	       const psPlaneCoord *coord ///< input TP coordinate
+	       const psGrommit *grommit, ///< Grommit for fast conversion
 	       );
 
 /** Convert Cell coords to FPA coordinates */
-psCoord *
-psCoordCellToFPA(psCoord *out,		///< Coordinates to return, or NULL
+psPlaneCoord *
+psCoordCellToFPA(psPlaneCoord *out,	///< Coordinates to return, or NULL
+		 const psPlaneCoord *coord ///< Input cell coordinates
 		 const psCell *cell,	///< Cell description
-		 const psCoord *coord	///< Input cell coordinates
 		 );
 
 /** Get the airmass for a given position and sidereal time */
 float
-psGetAirmass(const psCoord *coord,	///< Position on the sky
+psGetAirmass(const psSphereCoord *coord, ///< Position on the sky
              double siderealTime,	///< Sidereal time
 	     float height		///< Height above sea level
@@ -249,5 +250,5 @@
 /** Get the parallactic angle for a given position and sidereal time */
 float
-psGetParallactic(const psCoord *coord,	///< Position on the sky
+psGetParallactic(const psSphereCoord *coord, ///< Position on the sky
                  double siderealTime    ///< Sidereal time
                  );
@@ -262,5 +263,5 @@
 
 /** Calculate the parallax factor */
-psCoord *
+psSphereCoord *
 psGetParallaxFactor(const psExposure *exp ///< Exposure details
     );
Index: /trunk/archive/pslib/include/psPosition.h
===================================================================
--- /trunk/archive/pslib/include/psPosition.h	(revision 622)
+++ /trunk/archive/pslib/include/psPosition.h	(revision 623)
@@ -9,20 +9,19 @@
 /** Structures *********************/
 
-/** A point in 2-D space, with errors.
- */
-typedef union {
-    struct {
-	double x;			///< x position
-	double y;			///< y position
-	double xErr;			///< Error in x position
-	double yErr;			///< Error in y position
-    } xy;
-    struct {
-	double r;			///< RA
-	double d;			///< Dec
-	double rErr;			///< Error in RA
-	double dErr;			///< Error in Dec
-    } rd;
-} psCoord;
+/** A point in 2-D space, with errors. */
+typedef struct {
+    double x;				///< x position
+    double y;				///< y position
+    double xErr;			///< Error in x position
+    double yErr;			///< Error in y position
+} psPlaneCoord;
+
+/** A point on the surface of a sphere, with errors */
+typedef struct {
+    double r;				///< RA
+    double d;				///< Dec
+    double rErr;			///< Error in RA
+    double dErr;			///< Error in Dec
+} psSphereCoord;
 
 /** A polynomial transformation between coordinate frames.  This may be a linear relationship, or may
@@ -32,5 +31,5 @@
     psDPolynomial2D *x;
     psDPolynomial2D *y;
-} psCoordXform;
+} psPlaneCoordXform;
 
 /** The optical distortion terms.  The lowest two terms are the x and y axis of the target system.  The higher
@@ -40,5 +39,5 @@
     psDPolynomial4D *x;
     psDPolynomial4D *y;
-} psDistortion;
+} psPlaneDistortion;
 
 /** Functions **************************************************************/
@@ -48,28 +47,28 @@
 
 /** apply the coordinate transformation to the given coordinate */
-psCoord *psCoordXformApply (psCoord *out, ///< Output coordinates, or NULL
-			    const psCoordXform *frame, ///< coordinate transformation
-			    const psCoord *coords ///< input coordiate
+psPlaneCoord *psPlaneCoordXformApply (psPlaneCoord *out, ///< Output coordinates, or NULL
+				      const psPlaneCoordXform *frame, ///< coordinate transformation
+				      const psPlaneCoord *coords ///< input coordiate
     );
 
 /** apply the optical distortion to the given coordinate, magnitude, color */
-psCoord *psDistortionApply (psCoord *out, ///< Output coordinates, or NULL
-			    const psDistortion *pattern, ///< optical distortion pattern
-			    const psCoord *coords, ///< input coordinate
-			    float mag,	///< magnitude of object
-			    float color ///< color of object
+psPlaneCoord *psPlaneDistortionApply (psPlaneCoord *out, ///< Output coordinates, or NULL
+				      const psPlaneDistortion *pattern, ///< optical distortion pattern
+				      const psPlaneCoord *coords, ///< input coordinate
+				      float mag, ///< magnitude of object
+				      float color ///< color of object
     );
 
 /** Get offset (RA,Dec) on the sky between two positions position1 and position2 may not be identical */
-psCoord *
-psGetOffset(const psCoord *restrict position1, ///< Position 1
-	    const psCoord *restrict position2, ///< Position 2
+psSphereCoord *
+psGetOffset(const psSphereCoord *restrict position1, ///< Position 1
+	    const psSphereCoord *restrict position2, ///< Position 2
 	    const char *type		///< Type of offset: Linear, Spherical/Arcsec, Spherical/Degreees etc
     );
 
 /** Apply an offset to a position */
-psCoord *
-psApplyOffset(const psCoord *restrict position, ///< Position
-	      const psCoord *restrict offset, ///< Offset
+psSphereCoord *
+psApplyOffset(const psSphereCoord *restrict position, ///< Position
+	      const psSphereCoord *restrict offset, ///< Offset
 	      const char *type		///< Type of offset: Linear, Spherical/Arcsec, Spherical/Degreees etc
     );
@@ -78,10 +77,10 @@
 
 /** Get Sun Position */
-psCoord *
+psSphereCoord *
 psGetSunPos(float mjd			///< MJD to get position for
     );
 
 /** Get Moon position */
-psCoord *
+psSphereCoord *
 psGetMoonPos(float mjd,			///< MJD to get position for
 	     double latitude,		///< Latitude for apparent position
@@ -95,5 +94,5 @@
 
 /** Get Planet positions */
-psCoord *
+psSphereCoord *
 psGetSolarSystemPos(const char *solarSystemObject, ///< Named S.S. object
 		    float mjd		///< MJD to get position for
@@ -105,21 +104,21 @@
 
 /** Convert ICRS to Ecliptic */
-psCoord *
-psCoordinatesItoE(const psCoord *restrict coordinates ///< ICRS coordinates to convert
+psSphereCoord *
+psCoordinatesItoE(const psSphereCoord *restrict coordinates ///< ICRS coordinates to convert
     );
 
 /** Convert Ecliptic to ICRS */
-psCoord *
-psCoordinatesEtoI(const psCoord *restrict coordinates ///< Ecliptic coordinates to convert
+psSphereCoord *
+psCoordinatesEtoI(const psSphereCoord *restrict coordinates ///< Ecliptic coordinates to convert
     );
 
 /** Convert ICRS to Galactic */
-psCoord *
-psCoordinatesItoG(const psCoord *restrict coordinates ///< ICRS coordinates to convert
+psSphereCoord *
+psCoordinatesItoG(const psSphereCoord *restrict coordinates ///< ICRS coordinates to convert
     );
 
 /** Convert Galactic to ICRS */
-psCoord *
-psCoordinatesGtoI(const psCoord *restrict coordinates ///< Galactic coordinates to convert
+psSphereCoord *
+psCoordinatesGtoI(const psSphereCoord *restrict coordinates ///< Galactic coordinates to convert
     );
 
