Index: trunk/archive/pslib/include/psPosition.h
===================================================================
--- trunk/archive/pslib/include/psPosition.h	(revision 710)
+++ trunk/archive/pslib/include/psPosition.h	(revision 753)
@@ -8,4 +8,14 @@
 
 /** Structures *********************/
+
+/** projection types */
+typedef enum {                          ///< type of val is:
+    PS_PROJ_TAN,                        ///< Tangent projection
+    PS_PROJ_SIN,                        ///< Sine projection
+    PS_PROJ_AIT,                        ///< Aitoff projection
+    PS_PROJ_PAR,                        ///< Par projection
+    PS_PROJ_GLS,                        ///< GLS projection
+    PS_PROJ_NTYPE                       ///< Number of types; must be last
+} psProjectionType;
 
 /** A point in 2-D space, with errors. */
@@ -15,5 +25,5 @@
     double xErr;			///< Error in x position
     double yErr;			///< Error in y position
-} psPlaneCoord;
+} psPlane;
 
 /** A point on the surface of a sphere, with errors */
@@ -23,5 +33,5 @@
     double rErr;			///< Error in RA
     double dErr;			///< Error in Dec
-} psSphereCoord;
+} psSphere;
 
 /** A polynomial transformation between coordinate frames.  This may be a linear relationship, or may
@@ -31,5 +41,5 @@
     psDPolynomial2D *x;
     psDPolynomial2D *y;
-} psPlaneCoordXform;
+} psPlaneTransform;
 
 /** The optical distortion terms.  The lowest two terms are the x and y axis of the target system.  The higher
@@ -39,5 +49,22 @@
     psDPolynomial4D *x;
     psDPolynomial4D *y;
-} psPlaneDistortion;
+} psPlaneDistort;
+
+/** General spherical transformation */
+typedef struct {
+  double sinNPlon;                       ///< sin of North Pole longitude
+  double cosNPlon;                       ///< cos of North Pole longitude
+  double sinNPlat;                       ///< sin of North Pole lattitude
+  double cosNPlat;                       ///< cos of North Pole lattitude
+  double sinZP;	                         ///< sin of First PT of Ares lon
+  double cosZP;	                         ///< cos of First PT of Ares lon
+} psSphereTransform;
+
+/** Spherical <-> Linear projections */
+typedef struct {
+    double R, D;                         ///< coordinates of projection center
+    double Xs, Ys;                       ///< plate-scale in X and Y directions
+    psProjectionType type;               ///< projection type
+} psProjection;
 
 /** Functions **************************************************************/
@@ -47,111 +74,131 @@
 
 /** apply the coordinate transformation to the given coordinate */
-psPlaneCoord *psPlaneCoordXformApply (psPlaneCoord *out, ///< Output coordinates, or NULL
-				      const psPlaneCoordXform *frame, ///< coordinate transformation
-				      const psPlaneCoord *coords ///< input coordiate
-    );
+psPlane *psPlaneTransformApply (psPlane *out, ///< Output coordinates, or NULL
+				const psPlaneTransform *frame, ///< coordinate transformation
+				const psPlane *coords) ///< input coordiate
+;
 
 /** apply the optical distortion to the given coordinate, magnitude, color */
-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
-    );
+psPlane *psPlaneDistortApply (psPlane *out, ///< Output coordinates, or NULL
+			      const psPlaneDistort *pattern, ///< optical distortion pattern
+			      const psPlane *coords, ///< input coordinate
+			      float mag, ///< magnitude of object
+			      float color) ///< color of object
+;
+
+/* Celestial coordinate conversions */
+
+/** Constructor */
+psSphereTransform *
+psSphereTransformAlloc(double pole1, ///< First location of pole
+		       double pole2, ///< Second location of pole
+		       double rotation) ///< Rotation between systems
+;
+
+/** Destructor */
+void psSphereTransformFree(psSphereTransform *trans) ///< Transform to destroy
+;
+
+/** Apply general spherical transformation */
+psSphere *
+psSphereTransformApply(const psSphere *coord, ///< Coordinates to convert
+		       const psSphereTransform *sys) ///< System to use to convert
+;
+
+/** Return transformation structure to convert ICRS to Ecliptic */
+psSphereTransform *psSphereTransformItoE(void);
+
+/** Return transformation structure to convert Ecliptic to ICRS */
+psSphereTransform *psSphereTransformEtoI(void);
+
+/** Return transformation structure to convert ICRS to Galactic */
+psSphereTransform *psSphereTransformItoG(void);
+
+/** Return transformation structure to convert Galactic to ICRS */
+psSphereTransform *psSphereTransformGtoI(void);
+
+/***********************************************************************************************************/
+
+
+/** Project spherical system onto a plane */
+psPlane *
+psCoordProject(const psSphere *coord, ///< Spherical coordinates to project
+	       const psProjection *projection)	///< Projection to use
+;
+
+/** Deproject plane onto spherical system */
+psSphere *
+psCoordDeproject(const psPlane *coord, ///< Plane coordinates to deproject
+		 const psProjection *projection)	///< Projection to use
+;
 
 /** Get offset (RA,Dec) on the sky between two positions position1 and position2 may not be identical */
-psSphereCoord *
-psSphereCoordGetOffset(const psSphereCoord *restrict position1, ///< Position 1
-		       const psSphereCoord *restrict position2, ///< Position 2
-		       const char *type		///< Type of offset: Linear, Spherical/Arcsec,
-						///< Spherical/Degreees etc
-    );
+psSphere *
+psSphereGetOffset(const psSphere *restrict position1, ///< Position 1
+		  const psSphere *restrict position2, ///< Position 2
+		  const char *type)	///< Type of offset: Spherical/Arcsec, Spherical/Degreees etc
+;
 
 /** Apply an offset to a position */
-psSphereCoord *
-psSphereCoordApplyOffset(const psSphereCoord *restrict position, ///< Position
-			 const psSphereCoord *restrict offset, ///< Offset
-			 const char *type		///< Type of offset: Linear, Spherical/Arcsec,
-							///< Spherical/Degreees etc
-    );
+psSphere *
+psSphereApplyOffset(const psSphere *restrict position, ///< Position
+		    const psSphere *restrict offset, ///< Offset
+		    const char *type)	///< Type of offset: Spherical/Arcsec, Spherical/Degreees etc
+;
 
 /* Positions of well-known objects */
 
 /** Get Sun Position */
-psSphereCoord *
-psGetSunPos(float mjd			///< MJD to get position for
-    );
-
-/** Get Moon position */
-psSphereCoord *
-psGetMoonPos(float mjd,			///< MJD to get position for
-	     double latitude,		///< Latitude for apparent position
-	     double longitude		///< Longitude for apparent position
-    );
+psSphere *
+psSunGetPos(psTime time)		///< MJD to get position for
+;
+
+/** Get Sun Rise time */
+psSphere *
+psSunGetRise(psTime *twi15,		///< corresponding 15 deg twilight
+	     psTime *twi18,		///< corresponding 18 deg twilight
+	     psTime time)		///< get rise closest to this time
+;
+
+/** Get Sun Set time */
+psSphere *
+psSunGetSet(psTime *twi15,		///< corresponding 15 deg twilight
+	    psTime *twi18,		///< corresponding 18 deg twilight
+	    psTime time)		///< get set closest to this time
+;
+
+/** Get Length of closest night */
+float
+psNightLength(psTime time)		///< MJD to get position for
+;
+
+/** Get Moon Position */
+psSphere *
+psMoonGetPos(psTime time)		///< MJD to get position for
+;
+
+/** Get Moon Rise time */
+psSphere *
+psMoonGetRise(psTime time)		///< get rise closest to this time
+;
+
+/** Get Moon Set time */
+psSphere *
+psMoonGetSet(psTime time)		///< get set closest to this time
+;
 
 /** Get Moon phase */
 float
-psGetMoonPhase(float mjd		///< MJD to get phase for
-    );
+psMoonGetPhase(psTime time)		///< MJD to get phase for
+;
 
 /** Get Planet positions */
-psSphereCoord *
-psGetSolarSystemPos(const char *solarSystemObject, ///< Named S.S. object
-		    float mjd		///< MJD to get position for
-    );
+psSphere *
+psPlanetGetPos(const char *solarSystemObject, ///< Named S.S. object
+	       psTime time)		///< MJD to get position for
+;
 
 /***********************************************************************************************************/
 
-/* Celestial coordinate conversions */
-
-/** General spherical transformation */
-typedef struct {
-    double sin1, sin2, sin3, cos1, cos2, cos3; ///< Sines and cosines for transformation
-} psSphereCoordTransformation;
-
-/** Constructor */
-psSphereCoordTransformation *
-psSphereCoordTransformationAlloc(double pole1, ///< First location of pole
-				 double pole2, ///< Second location of pole
-				 double rotation ///< Rotation between systems
-    );
-
-/** Destructor */
-void psSphereCoordTranformationFree(psSphereCoordTransformation *trans ///< Transformation to destroy
-    );
-
-/** Apply general spherical transformation */
-psSphereCoord *
-psSphereCoordTransform(const psSphereCoord *coord, ///< Coordinates to convert
-		       const psSphereCoordTransformation *sys ///< System to use to convert
-    );
-
-/** Return transformation structure to convert ICRS to Ecliptic */
-psSphereCoordTransformation *psSphereCoordTransformationItoE(void);
-
-/** Return transformation structure to convert Ecliptic to ICRS */
-psSphereCoordTransformation *psSphereCoordTransformationEtoI(void);
-
-/** Return transformation structure to convert ICRS to Galactic */
-psSphereCoordTransformation *psSphereCoordTransformationItoG(void);
-
-/** Return transformation structure to convert Galactic to ICRS */
-psSphereCoordTransformation *psSphereCoordTransformationGtoI(void);
-
-/***********************************************************************************************************/
-
-
-/** Project spherical system onto a plane */
-psPlaneCoord *
-psCoordProject(const psSphereCoord *coord, ///< Spherical coordinates to project
-	       const char *projection	///< Projection to use
-    );
-
-/** Deproject plane onto spherical system */
-psSphereCoord *
-psCoordDeproject(const psPlaneCoord *coord, ///< Plane coordinates to deproject
-		 const char *projection	///< Projection to use
-    );
-
 /* \} */ // End of AstroGroup Functions
 
