Index: trunk/psLib/src/astro/psCoord.c
===================================================================
--- trunk/psLib/src/astro/psCoord.c	(revision 1406)
+++ trunk/psLib/src/astro/psCoord.c	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psCoord.c
 *
@@ -10,6 +11,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-06 22:34:05 $
+*  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-07 00:06:06 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -27,68 +28,56 @@
 #include <float.h>
 
-static float cot( float x );
-static float arg( float x, float y );
+static float cot(float x);
+static float arg(float x, float y);
 
 // This is the only function in this file which I understand.
-psPlane *psPlaneTransformApply( psPlane *out,
-                                const psPlaneTransform *transform,
-                                const psPlane *coords )
-{
-    if ( out == NULL ) {
-        out = ( psPlane * ) psAlloc( sizeof( psPlane ) );
-    }
-    out->x = transform->x->coeff[ 0 ][ 0 ] +
-             ( transform->x->coeff[ 1 ][ 0 ] * coords->x ) +
-             ( transform->x->coeff[ 0 ][ 1 ] * coords->y );
-
-    out->y = transform->y->coeff[ 0 ][ 0 ] +
-             ( transform->y->coeff[ 1 ][ 0 ] * coords->x ) +
-             ( transform->y->coeff[ 0 ][ 1 ] * coords->y );
-
-    return ( out );
-}
-
+psPlane *psPlaneTransformApply(psPlane * out, const psPlaneTransform * transform, const psPlane * coords)
+{
+    if (out == NULL) {
+        out = (psPlane *) psAlloc(sizeof(psPlane));
+    }
+    out->x = transform->x->coeff[0][0] +
+             (transform->x->coeff[1][0] * coords->x) + (transform->x->coeff[0][1] * coords->y);
+
+    out->y = transform->y->coeff[0][0] +
+             (transform->y->coeff[1][0] * coords->x) + (transform->y->coeff[0][1] * coords->y);
+
+    return (out);
+}
 
 // This transformation takes into account parameters beyond an objects
 // spatial coordinates: term3 and term4.
-psPlane *psPlaneDistortApply( psPlane *out,
-                              const psPlaneDistort *transform,
-                              const psPlane *coords,
-                              float term3,
-                              float term4 )
-{
-    if ( out == NULL ) {
-        out = ( psPlane * ) psAlloc( sizeof( psPlane ) );
-    }
-
-    out->x = transform->x->coeff[ 0 ][ 0 ][ 0 ][ 0 ] +
-             ( transform->x->coeff[ 1 ][ 0 ][ 0 ][ 0 ] * coords->x ) +
-             ( transform->x->coeff[ 0 ][ 1 ][ 0 ][ 0 ] * coords->y ) +
-             ( transform->x->coeff[ 0 ][ 0 ][ 1 ][ 0 ] * term3 ) +
-             ( transform->x->coeff[ 0 ][ 0 ][ 0 ][ 1 ] * term4 );
-
-    out->y = transform->y->coeff[ 0 ][ 0 ][ 0 ][ 0 ] +
-             ( transform->y->coeff[ 1 ][ 0 ][ 0 ][ 0 ] * coords->x ) +
-             ( transform->y->coeff[ 0 ][ 1 ][ 0 ][ 0 ] * coords->y ) +
-             ( transform->y->coeff[ 0 ][ 0 ][ 1 ][ 0 ] * term3 ) +
-             ( transform->y->coeff[ 0 ][ 0 ][ 0 ][ 1 ] * term4 );
-
-    return ( out );
-}
-
+psPlane *psPlaneDistortApply(psPlane * out,
+                             const psPlaneDistort * transform,
+                             const psPlane * coords, float term3, float term4)
+{
+    if (out == NULL) {
+        out = (psPlane *) psAlloc(sizeof(psPlane));
+    }
+
+    out->x = transform->x->coeff[0][0][0][0] +
+             (transform->x->coeff[1][0][0][0] * coords->x) +
+             (transform->x->coeff[0][1][0][0] * coords->y) +
+             (transform->x->coeff[0][0][1][0] * term3) + (transform->x->coeff[0][0][0][1] * term4);
+
+    out->y = transform->y->coeff[0][0][0][0] +
+             (transform->y->coeff[1][0][0][0] * coords->x) +
+             (transform->y->coeff[0][1][0][0] * coords->y) +
+             (transform->y->coeff[0][0][1][0] * term3) + (transform->y->coeff[0][0][0][1] * term4);
+
+    return (out);
+}
 
 // This function prototype has been modified since the SDRS.
-psSphereTransform *psSphereTransformAlloc( double NPlat,
-        double Xo,
-        double xo )
-{
-    psSphereTransform * tmp = ( psSphereTransform * ) psAlloc( sizeof( psSphereTransform ) );
-
-    tmp->sinPhi = sin( NPlat );
-    tmp->cosPhi = cos( NPlat );
+psSphereTransform *psSphereTransformAlloc(double NPlat, double Xo, double xo)
+{
+    psSphereTransform *tmp = (psSphereTransform *) psAlloc(sizeof(psSphereTransform));
+
+    tmp->sinPhi = sin(NPlat);
+    tmp->cosPhi = cos(NPlat);
     tmp->Xo = Xo;
     tmp->xo = xo;
 
-    return ( tmp );
+    return (tmp);
 }
 
@@ -100,7 +89,5 @@
 // there are no typo's.
 
-psSphere *psSphereTransformApply( psSphere *out,
-                                  const psSphereTransform *transform,
-                                  const psSphere *coord )
+psSphere *psSphereTransformApply(psSphere * out, const psSphereTransform * transform, const psSphere * coord)
 {
     double sinY = 0.0;
@@ -112,6 +99,6 @@
     double dx = 0.0;
 
-    if ( out == NULL ) {
-        out = ( psSphere * ) psAlloc( sizeof( psSphere ) );
+    if (out == NULL) {
+        out = (psSphere *) psAlloc(sizeof(psSphere));
     }
 
@@ -119,20 +106,19 @@
     y = coord->d;
     dx = x - transform->xo;
-    sinY = cos( y ) * sin( dx ) * transform->sinPhi + sin( y ) * transform->cosPhi;
-    cosY = sqrt( 1.0 - sinY * sinY );
-    sinX = ( cos( y ) * sin( dx ) * transform->cosPhi - sin( y ) * transform->sinPhi ) /
-           cos( y );
-    cosX = cos( y ) * cos( dx ) / cos( y );
-
-    out->r = atan2( sinX, cosX ) + transform->Xo;
-    out->d = atan2( sinY, cosY );
-
-    return ( out );
-}
-
-psSphereTransform *psSphereTransformICRStoEcliptic( psTime time )
-{
-    struct tm * tmTime = psTimeToTM( time );
-    double year = ( double ) ( 1900 + tmTime->tm_year );
+    sinY = cos(y) * sin(dx) * transform->sinPhi + sin(y) * transform->cosPhi;
+    cosY = sqrt(1.0 - sinY * sinY);
+    sinX = (cos(y) * sin(dx) * transform->cosPhi - sin(y) * transform->sinPhi) / cos(y);
+    cosX = cos(y) * cos(dx) / cos(y);
+
+    out->r = atan2(sinX, cosX) + transform->Xo;
+    out->d = atan2(sinY, cosY);
+
+    return (out);
+}
+
+psSphereTransform *psSphereTransformICRStoEcliptic(psTime time)
+{
+    struct tm *tmTime = psTimeToTM(time);
+    double year = (double)(1900 + tmTime->tm_year);
     double T = year / 100.0;
     double phi = -23.452294 + 0.013013 * T + 0.000001639 * T * T - 0.000000503 * T * T * T;
@@ -140,112 +126,99 @@
     double xo = 0.0;
 
-    return ( psSphereTransformAlloc( phi, Xo, xo ) );
-}
-
-psSphereTransform *psSphereTransformEcliptictoICRS( psTime time )
-{
-    struct tm * tmTime = psTimeToTM( time );
-    double year = ( double ) ( 1900 + tmTime->tm_year );
+    return (psSphereTransformAlloc(phi, Xo, xo));
+}
+
+psSphereTransform *psSphereTransformEcliptictoICRS(psTime time)
+{
+    struct tm *tmTime = psTimeToTM(time);
+    double year = (double)(1900 + tmTime->tm_year);
     double T = year / 100.0;
-    double phi = + 23.452294 - 0.013013 * T - 0.000001639 * T * T + 0.000000503 * T * T * T;
+    double phi = +23.452294 - 0.013013 * T - 0.000001639 * T * T + 0.000000503 * T * T * T;
     double Xo = 0.0;
     double xo = 0.0;
 
-    return ( psSphereTransformAlloc( phi, Xo, xo ) );
-}
-
-psSphereTransform *psSphereTransformICRStoGalatic( void )
-{
-    return ( psSphereTransformAlloc( 62.6, 282.25, 33.0 ) );
-}
-
-psSphereTransform *psSphereTransformGalatictoICRS( void )
-{
-    return ( psSphereTransformAlloc( -62.6, 33.0, 282.25 ) );
+    return (psSphereTransformAlloc(phi, Xo, xo));
+}
+
+psSphereTransform *psSphereTransformICRStoGalatic(void)
+{
+    return (psSphereTransformAlloc(62.6, 282.25, 33.0));
+}
+
+psSphereTransform *psSphereTransformGalatictoICRS(void)
+{
+    return (psSphereTransformAlloc(-62.6, 33.0, 282.25));
 }
 
 // XXX: Is this the correct way to calculate this?
-float cot( float x )
-{
-    return ( 1.0 / atan( x ) );
+float cot(float x)
+{
+    return (1.0 / atan(x));
 }
 
 // This is some kind of arc tan function.
-float arg( float x, float y )
-{
-    if ( x > 0 ) {
-        return ( atan( y / x ) );
-    } else
-        if ( ( x == 0 ) && ( y == 0 ) ) {
-            return ( 0.5 * M_PI );
-        } else
-            if ( ( x == 0 ) && ( y == 0 ) ) {
-                return ( -0.5 * M_PI );
-            } else
-                if ( ( x == 0 ) && ( y == 0 ) ) {
-                    return ( M_PI + atan( y / x ) );
-                } else
-                    if ( ( x == 0 ) && ( y == 0 ) ) {
-                        return ( -M_PI + atan( y / x ) );
-                    }
-
-    psAbort( __func__, "Unacceptable range for (arg(%f, %f).\n", x, y );
-    return ( 0.0 );
+float arg(float x, float y)
+{
+    if (x > 0) {
+        return (atan(y / x));
+    } else if ((x == 0) && (y == 0)) {
+        return (0.5 * M_PI);
+    } else if ((x == 0) && (y == 0)) {
+        return (-0.5 * M_PI);
+    } else if ((x == 0) && (y == 0)) {
+        return (M_PI + atan(y / x));
+    } else if ((x == 0) && (y == 0)) {
+        return (-M_PI + atan(y / x));
+    }
+
+    psAbort(__func__, "Unacceptable range for (arg(%f, %f).\n", x, y);
+    return (0.0);
 }
 
 // XXX: Waiting for the definition of the PS_PROJ_PAR projection.
 // XXX: Waiting for the definition of the PS_PROJ_GLS projection.
-psPlane *psProject( const psSphere *coord,
-                    const psProjection *projection )
+psPlane *psProject(const psSphere * coord, const psProjection * projection)
 {
     float R = 0.0;
     float alpha = 0.0;
-    psPlane *tmp = ( psPlane * ) psAlloc( sizeof( psPlane ) );
-
-    if ( projection->type == PS_PROJ_TAN ) {
-        R = cot( coord->r ) * ( 180.0 / M_PI );
-        tmp->x = R * sin( coord->d );
-        tmp->y = R * cos( coord->d );
-
-    } else
-        if ( projection->type == PS_PROJ_SIN ) {
-            R = cos( coord->r ) * ( 180.0 / M_PI );
-            tmp->x = R * sin( coord->d );
-            tmp->y = R * cos( coord->d );
-
-        } else
-            if ( projection->type == PS_PROJ_CAR ) {
-                tmp->x = coord->d;
-                tmp->y = coord->r;
-
-            } else
-                if ( projection->type == PS_PROJ_MER ) {
-                    tmp->x = coord->d;
-                    tmp->y = log( tan( 45.0 + ( 0.5 * coord->r ) ) ) * 180.0 / M_PI;
-
-                } else
-                    if ( projection->type == PS_PROJ_AIT ) {
-                        alpha = 1.0 / ( ( 180.0 / M_PI ) *
-                                        sqrt( 1.0 + ( cos( coord->r ) * cos( 0.5 * coord->d ) * 0.5 ) ) );
-
-                        tmp->x = 2.0 * alpha * cos( coord->r ) * sin( 0.5 * coord->d );
-                        tmp->y = alpha * sin( coord->d );
-
-                    } else
-                        if ( projection->type == PS_PROJ_PAR ) {
-                            psAbort( __func__, "The projection type PS_PROJ_PAR is undefined.\n" );
-
-                        } else
-                            if ( projection->type == PS_PROJ_GLS ) {
-                                psAbort( __func__, "The projection type PS_PROJ_GLS is undefined.\n" );
-                            }
-
-    return ( tmp );
+    psPlane *tmp = (psPlane *) psAlloc(sizeof(psPlane));
+
+    if (projection->type == PS_PROJ_TAN) {
+        R = cot(coord->r) * (180.0 / M_PI);
+        tmp->x = R * sin(coord->d);
+        tmp->y = R * cos(coord->d);
+
+    } else if (projection->type == PS_PROJ_SIN) {
+        R = cos(coord->r) * (180.0 / M_PI);
+        tmp->x = R * sin(coord->d);
+        tmp->y = R * cos(coord->d);
+
+    } else if (projection->type == PS_PROJ_CAR) {
+        tmp->x = coord->d;
+        tmp->y = coord->r;
+
+    } else if (projection->type == PS_PROJ_MER) {
+        tmp->x = coord->d;
+        tmp->y = log(tan(45.0 + (0.5 * coord->r))) * 180.0 / M_PI;
+
+    } else if (projection->type == PS_PROJ_AIT) {
+        alpha = 1.0 / ((180.0 / M_PI) * sqrt(1.0 + (cos(coord->r) * cos(0.5 * coord->d) * 0.5)));
+
+        tmp->x = 2.0 * alpha * cos(coord->r) * sin(0.5 * coord->d);
+        tmp->y = alpha * sin(coord->d);
+
+    } else if (projection->type == PS_PROJ_PAR) {
+        psAbort(__func__, "The projection type PS_PROJ_PAR is undefined.\n");
+
+    } else if (projection->type == PS_PROJ_GLS) {
+        psAbort(__func__, "The projection type PS_PROJ_GLS is undefined.\n");
+    }
+
+    return (tmp);
 }
 
 // XXX: Waiting for the definition of the PS_PROJ_PAR projection.
 // XXX: Waiting for the definition of the PS_PROJ_GLS projection.
-psSphere *psDeproject( const psPlane *coord,
-                       const psProjection *projection )
+psSphere *psDeproject(const psPlane * coord, const psProjection * projection)
 {
     float R = 0.0;
@@ -253,58 +226,50 @@
     float chu1 = 0.0;
     float chu2 = 0.0;
-    psSphere *tmp = ( psSphere * ) psAlloc( sizeof( psSphere ) );
-
-    if ( projection->type == PS_PROJ_TAN ) {
-        R = sqrt( ( coord->x * coord->x ) + ( coord->y * coord->y ) );
-        tmp->d = arg( -coord->y, coord->x );
-        tmp->r = atan( 180.0 / ( R * M_PI ) );
-
-    } else
-        if ( projection->type == PS_PROJ_SIN ) {
-            R = sqrt( ( coord->x * coord->x ) + ( coord->y * coord->y ) );
-            tmp->d = arg( -coord->y, coord->x );
-            tmp->r = acos( ( R * M_PI ) / 180.0 );
-
-        } else
-            if ( projection->type == PS_PROJ_CAR ) {
-                tmp->d = coord->x;
-                tmp->r = coord->y;
-
-            } else
-                if ( projection->type == PS_PROJ_MER ) {
-                    tmp->d = coord->x;
-                    tmp->r = ( 2.0 * atan( exp( ( coord->y * M_PI / 180.0 ) ) ) ) - 180.0;
-
-                } else
-                    if ( projection->type == PS_PROJ_AIT ) {
-                        chu1 = ( coord->x * M_PI ) / 720.0;
-                        chu1 *= chu1;
-                        chu2 = ( coord->y * M_PI ) / 360.0;
-                        chu2 *= chu2;
-                        chu = sqrt( 1.0 - chu1 - chu2 );
-                        tmp->d = 2.0 * arg( ( 2.0 * chu * chu ) - 1.0,
-                                            ( coord->x * chu * M_PI ) / 360.0 );
-                        tmp->r = asin( ( coord->y * chu * M_PI ) / 180.0 );
-
-                    } else
-                        if ( projection->type == PS_PROJ_PAR ) {
-                            psAbort( __func__, "The projection type PS_PROJ_PAR is undefined.\n" );
-
-                        } else
-                            if ( projection->type == PS_PROJ_GLS ) {
-                                psAbort( __func__, "The projection type PS_PROJ_GLG is undefined.\n" );
-                            }
-
-    return ( tmp );
+    psSphere *tmp = (psSphere *) psAlloc(sizeof(psSphere));
+
+    if (projection->type == PS_PROJ_TAN) {
+        R = sqrt((coord->x * coord->x) + (coord->y * coord->y));
+        tmp->d = arg(-coord->y, coord->x);
+        tmp->r = atan(180.0 / (R * M_PI));
+
+    } else if (projection->type == PS_PROJ_SIN) {
+        R = sqrt((coord->x * coord->x) + (coord->y * coord->y));
+        tmp->d = arg(-coord->y, coord->x);
+        tmp->r = acos((R * M_PI) / 180.0);
+
+    } else if (projection->type == PS_PROJ_CAR) {
+        tmp->d = coord->x;
+        tmp->r = coord->y;
+
+    } else if (projection->type == PS_PROJ_MER) {
+        tmp->d = coord->x;
+        tmp->r = (2.0 * atan(exp((coord->y * M_PI / 180.0)))) - 180.0;
+
+    } else if (projection->type == PS_PROJ_AIT) {
+        chu1 = (coord->x * M_PI) / 720.0;
+        chu1 *= chu1;
+        chu2 = (coord->y * M_PI) / 360.0;
+        chu2 *= chu2;
+        chu = sqrt(1.0 - chu1 - chu2);
+        tmp->d = 2.0 * arg((2.0 * chu * chu) - 1.0, (coord->x * chu * M_PI) / 360.0);
+        tmp->r = asin((coord->y * chu * M_PI) / 180.0);
+
+    } else if (projection->type == PS_PROJ_PAR) {
+        psAbort(__func__, "The projection type PS_PROJ_PAR is undefined.\n");
+
+    } else if (projection->type == PS_PROJ_GLS) {
+        psAbort(__func__, "The projection type PS_PROJ_GLG is undefined.\n");
+    }
+
+    return (tmp);
 }
 
 // XXX: Do I need to check for unacceptable transformation parameters?
 // Maybe, if the points are on the North/South Pole, etc?
-psSphere *psSphereGetOffset( const psSphere *restrict position1,
-                             const psSphere *restrict position2,
-                             psSphereOffsetMode mode,
-                             psSphereOffsetUnit unit )
-{
-    //    psPlane *lin;
+psSphere *psSphereGetOffset(const psSphere * restrict position1,
+                            const psSphere * restrict position2,
+                            psSphereOffsetMode mode, psSphereOffsetUnit unit)
+{
+    // psPlane *lin;
     psProjection proj;
     psSphere *tmp;
@@ -312,5 +277,5 @@
     double tmpD = 0.0;
 
-    if ( mode == PS_LINEAR ) {
+    if (mode == PS_LINEAR) {
         // XXX: I have no idea how to construct this.  Maybe project both
         // sperical positions onto the plane, set the origin at one of the
@@ -318,5 +283,5 @@
 
         // XXX: Do I need to somehow scale this projection?
-        // project position1?  Will it project to (0.0, 0.0)?
+        // project position1? Will it project to (0.0, 0.0)?
         proj.R = position1->r;
         proj.D = position1->d;
@@ -325,51 +290,45 @@
         proj.type = PS_PROJ_TAN;
 
-        //        lin = psProject(position2, proj);
-        //        tmp = psDeproject(lin, proj);
+        // lin = psProject(position2, proj);
+        // tmp = psDeproject(lin, proj);
 
         // XXX: Do we need to convert units in tmp?
-        return ( tmp );
-    } else
-        if ( mode == PS_SPHERICAL ) {
-            tmpR = position2->r - position1->r;
-            tmpD = position2->d - position1->d;
-
-            if ( unit == PS_ARCSEC ) {
-                tmpR = ( tmpR * 180.0 * 60.0 * 60.0 ) / M_PI;
-                tmpD = ( tmpR * 180.0 * 60.0 * 60.0 ) / M_PI;
-            } else
-                if ( unit == PS_ARCMIN ) {
-                    tmpR = ( tmpR * 180.0 * 60.0 ) / M_PI;
-                    tmpD = ( tmpR * 180.0 * 60.0 ) / M_PI;
-                } else
-                    if ( unit == PS_DEGREE ) {
-                        tmpR = ( tmpR * 180.0 ) / M_PI;
-                        tmpD = ( tmpR * 180.0 ) / M_PI;
-                    } else
-                    if ( unit == PS_RADIAN ) {}
-                        else {
-                            psAbort( __func__, "Unknown offset unit: 0x%x\n", unit );
-                        }
-
-            tmp = ( psSphere * ) psAlloc( sizeof( psSphere ) );
-            tmp->r = tmpR;
-            tmp->d = tmpD;
-            tmp->rErr = 0.0;
-            tmp->dErr = 0.0;
-            // XXX: Do we need to wrap these to an acceptable range?
-            return ( tmp );
+        return (tmp);
+    } else if (mode == PS_SPHERICAL) {
+        tmpR = position2->r - position1->r;
+        tmpD = position2->d - position1->d;
+
+        if (unit == PS_ARCSEC) {
+            tmpR = (tmpR * 180.0 * 60.0 * 60.0) / M_PI;
+            tmpD = (tmpR * 180.0 * 60.0 * 60.0) / M_PI;
+        } else if (unit == PS_ARCMIN) {
+            tmpR = (tmpR * 180.0 * 60.0) / M_PI;
+            tmpD = (tmpR * 180.0 * 60.0) / M_PI;
+        } else if (unit == PS_DEGREE) {
+            tmpR = (tmpR * 180.0) / M_PI;
+            tmpD = (tmpR * 180.0) / M_PI;
+        } else if (unit == PS_RADIAN) {}
+        else {
+            psAbort(__func__, "Unknown offset unit: 0x%x\n", unit);
         }
-    psAbort( __func__, "Unrecognized offset mode\n" );
-    return ( NULL );
-}
-
+
+        tmp = (psSphere *) psAlloc(sizeof(psSphere));
+        tmp->r = tmpR;
+        tmp->d = tmpD;
+        tmp->rErr = 0.0;
+        tmp->dErr = 0.0;
+        // XXX: Do we need to wrap these to an acceptable range?
+        return (tmp);
+    }
+    psAbort(__func__, "Unrecognized offset mode\n");
+    return (NULL);
+}
 
 // XXX: Do I need to check for unacceptable transformation parameters?
 // Maybe, if the points are on the North/South Pole, etc?
 // XXX: I copied the algorithm from the ADD exactly.
-psSphere *psSphereSetOffset( const psSphere *restrict position,
-                             const psSphere *restrict offset,
-                             psSphereOffsetMode mode,
-                             psSphereOffsetUnit unit )
+psSphere *psSphereSetOffset(const psSphere * restrict position,
+                            const psSphere * restrict offset,
+                            psSphereOffsetMode mode, psSphereOffsetUnit unit)
 {
     psPlane lin;
@@ -379,5 +338,5 @@
     double tmpD = 0.0;
 
-    if ( mode == PS_LINEAR ) {
+    if (mode == PS_LINEAR) {
         proj.R = position->r;
         proj.D = position->d;
@@ -389,39 +348,35 @@
         lin.y = offset->d;
 
-        tmp = psDeproject( &lin, &proj );
-        return ( tmp );
-
-    } else
-        if ( mode == PS_SPHERICAL ) {
-            if ( unit == PS_ARCSEC ) {
-                tmpR = ( M_PI * offset->r ) / ( 180.0 * 60.0 * 60.0 );
-                tmpD = ( M_PI * offset->d ) / ( 180.0 * 60.0 * 60.0 );
-            } else
-                if ( unit == PS_ARCMIN ) {
-                    tmpR = ( M_PI * offset->r ) / ( 180.0 * 60.0 );
-                    tmpD = ( M_PI * offset->d ) / ( 180.0 * 60.0 );
-                } else
-                    if ( unit == PS_DEGREE ) {
-                        tmpR = ( M_PI * offset->r ) / ( 180.0 );
-                        tmpD = ( M_PI * offset->d ) / ( 180.0 );
-                    } else
-                        if ( unit == PS_RADIAN ) {
-                            tmpR = offset->r;
-                            tmpD = offset->d;
-                        } else {
-                            psAbort( __func__, "Unknown offset unit: 0x%x\n", unit );
-                        }
-
-            tmp = ( psSphere * ) psAlloc( sizeof( psSphere ) );
-            tmp->r = position->r + tmpR;
-            tmp->r = position->d + tmpD;
-            tmp->rErr = 0.0;
-            tmp->dErr = 0.0;
-
-            // XXX: wrap tmp->r and tmp->d to the allowed range (-PI to PI)
-            // and (0 to 2*PI).
-            return ( tmp );
+        tmp = psDeproject(&lin, &proj);
+        return (tmp);
+
+    } else if (mode == PS_SPHERICAL) {
+        if (unit == PS_ARCSEC) {
+            tmpR = (M_PI * offset->r) / (180.0 * 60.0 * 60.0);
+            tmpD = (M_PI * offset->d) / (180.0 * 60.0 * 60.0);
+        } else if (unit == PS_ARCMIN) {
+            tmpR = (M_PI * offset->r) / (180.0 * 60.0);
+            tmpD = (M_PI * offset->d) / (180.0 * 60.0);
+        } else if (unit == PS_DEGREE) {
+            tmpR = (M_PI * offset->r) / (180.0);
+            tmpD = (M_PI * offset->d) / (180.0);
+        } else if (unit == PS_RADIAN) {
+            tmpR = offset->r;
+            tmpD = offset->d;
+        } else {
+            psAbort(__func__, "Unknown offset unit: 0x%x\n", unit);
         }
-    psAbort( __func__, "Unrecognized offset mode\n" );
-    return ( NULL );
-}
+
+        tmp = (psSphere *) psAlloc(sizeof(psSphere));
+        tmp->r = position->r + tmpR;
+        tmp->r = position->d + tmpD;
+        tmp->rErr = 0.0;
+        tmp->dErr = 0.0;
+
+        // XXX: wrap tmp->r and tmp->d to the allowed range (-PI to PI)
+        // and (0 to 2*PI).
+        return (tmp);
+    }
+    psAbort(__func__, "Unrecognized offset mode\n");
+    return (NULL);
+}
Index: trunk/psLib/src/astro/psCoord.h
===================================================================
--- trunk/psLib/src/astro/psCoord.h	(revision 1406)
+++ trunk/psLib/src/astro/psCoord.h	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psCoord.h
 *
@@ -10,19 +11,19 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-05 19:38:51 $
+*  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-07 00:06:06 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
 */
 
-# ifndef PS_COORD_H
-# define PS_COORD_H
-
-#include "psType.h"
-#include "psImage.h"
-#include "psArray.h"
-#include "psList.h"
-#include "psFunctions.h"
-#include "psTime.h"
+#ifndef PS_COORD_H
+#    define PS_COORD_H
+
+#    include "psType.h"
+#    include "psImage.h"
+#    include "psArray.h"
+#    include "psList.h"
+#    include "psFunctions.h"
+#    include "psTime.h"
 
 /// @addtogroup CoordinateTransform
@@ -38,8 +39,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;
@@ -54,8 +55,8 @@
 typedef struct
 {
-    double r;      ///< RA
-    double d;      ///< Dec
-    double rErr;   ///< Error in RA
-    double dErr;   ///< Error in Dec
+    double r;                   // /< RA
+    double d;                   // /< Dec
+    double rErr;                // /< Error in RA
+    double dErr;                // /< Error in Dec
 }
 psSphere;
@@ -71,6 +72,6 @@
 typedef struct
 {
-    psDPolynomial2D *x;                ///< 2D polynomial transform of X coordinates
-    psDPolynomial2D *y;                ///< 2D polynomial transform of Y coordinates
+    psDPolynomial2D *x;         // /< 2D polynomial transform of X coordinates
+    psDPolynomial2D *y;         // /< 2D polynomial transform of Y coordinates
 }
 psPlaneTransform;
@@ -90,6 +91,6 @@
 typedef struct
 {
-    psDPolynomial4D *x;                ///< 4D polynomial transform of X coordinates
-    psDPolynomial4D *y;                ///< 4D polynomial transform of Y coordinates
+    psDPolynomial4D *x;         // /< 4D polynomial transform of X coordinates
+    psDPolynomial4D *y;         // /< 4D polynomial transform of Y coordinates
 }
 psPlaneDistort;
@@ -107,8 +108,8 @@
 typedef struct
 {
-    double sinPhi;                    ///< sin of North Pole lattitude
-    double cosPhi;                    ///< cos of North Pole lattitude
-    double Xo;                        ///< First PT of Ares lon
-    double xo;                        ///< First PT of Ares equiv lon
+    double sinPhi;              // /< sin of North Pole lattitude
+    double cosPhi;              // /< cos of North Pole lattitude
+    double Xo;                  // /< First PT of Ares lon
+    double xo;                  // /< First PT of Ares equiv lon
 }
 psSphereTransform;
@@ -120,12 +121,12 @@
  */
 typedef enum {
-    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_CAR,        ///< CAR projection
-    PS_PROJ_MER,        ///< MER projection
-    PS_PROJ_NTYPE      ///< Number of types; must be last.
+    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_CAR,                // /< CAR projection
+    PS_PROJ_MER,                // /< MER projection
+    PS_PROJ_NTYPE               // /< Number of types; must be last.
 } psProjectionType;
 
@@ -137,9 +138,9 @@
 typedef struct
 {
-    double R;     ///< Coordinates of projection center
-    double D;     ///< Coordinates of projection center
-    double Xs;    ///< plate-scale in X direction
-    double Ys;    ///< plate-scale in Y direction
-    psProjectionType type;  ///< Projection type
+    double R;                   // /< Coordinates of projection center
+    double D;                   // /< Coordinates of projection center
+    double Xs;                  // /< plate-scale in X direction
+    double Ys;                  // /< plate-scale in Y direction
+    psProjectionType type;      // /< Projection type
 }
 psProjection;
@@ -151,6 +152,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;
 
@@ -161,8 +162,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;
 
@@ -170,75 +171,55 @@
  *
  */
-psPlane *psPlaneTransformApply(
-    psPlane *out,                      ///< a psPlane to recycle.  If NULL, a new one is generated.
-    const psPlaneTransform *transform, ///< the transform to apply
-    const psPlane *coords              ///< the coordinate to apply the transform above.
-);
+psPlane *psPlaneTransformApply(psPlane * out,   // /< a psPlane to recycle.  If NULL, a new one is generated.
+                               const psPlaneTransform * transform,      // /< the transform to apply
+                               const psPlane * coords   // /< the coordinate to apply the transform above.
+                              );
 
 /** Applies the psPlaneDistort transform to a specified coordinate
  *
  */
-psPlane *psPlaneDistortApply(
-    psPlane *out,                      ///< a psPlane to recycle.  If NULL, a new one is generated.
-    const psPlaneDistort *transform,   ///< the transform to apply
-    const psPlane *coords,             ///< the coordinate to apply the transform above.
-    float term3,                       ///< third term -- maybe magnitude
-    float term4                        ///< forth term -- maybe color
-);
+psPlane *psPlaneDistortApply(psPlane * out,     // /< a psPlane to recycle.  If NULL, a new one is generated.
+                             const psPlaneDistort * transform,  // /< the transform to apply
+                             const psPlane * coords,    // /< the coordinate to apply the transform above.
+                             float term3,       // /< third term -- maybe magnitude
+                             float term4        // /< forth term -- maybe color
+                            );
 
 /** Allocator for psSphereTransform
  *
  */
-psSphereTransform *psSphereTransformAlloc(
-    double NPlat,                      ///< north pole latitude
-    double Xo,                         ///< First PT of Ares lon
-    double xo                          ///< First PT of Ares equiv lon
-);
-
+psSphereTransform *psSphereTransformAlloc(double NPlat, // /< north pole latitude
+        double Xo,    // /< First PT of Ares lon
+        double xo     // /< First PT of Ares equiv lon
+                                         );
 
 /** Applies the psSphereTransform transform for a specified coordinate
  *
  */
-psSphere *psSphereTransformApply(
-    psSphere *out,                     ///< a psSphere to recycle.  If NULL, a new one is generated.
-    const psSphereTransform *transform,///< the transform to apply
-    const psSphere *coord              ///< the coordinate to apply the transform above.x
-);
-
-psSphereTransform *psSphereTransformICRStoEcliptic(
-    psTime time
-);
-
-psSphereTransform *psSphereTransformEcliptictoICRS(
-    psTime time
-);
-
-psSphereTransform *psSphereTransformICRStoGalatic( void );
-
-psSphereTransform *psSphereTransformGalatictoICRS( void );
-
-psPlane *psProject(
-    const psSphere *coord,
-    const psProjection *projection
-);
-
-psSphere *psDeproject(
-    const psPlane *coord,
-    const psProjection *projection
-);
-
-psSphere *psSphereGetOffset(
-    const psSphere *restrict position1,
-    const psSphere *restrict position2,
-    psSphereOffsetMode mode,
-    psSphereOffsetUnit unit
-);
-
-psSphere *psSphereSetOffset(
-    const psSphere *restrict position,
-    const psSphere *restrict offset,
-    psSphereOffsetMode mode,
-    psSphereOffsetUnit unit
-);
+psSphere *psSphereTransformApply(psSphere * out,        // /< a psSphere to recycle.  If NULL, a new one is
+                                 // generated.
+                                 const psSphereTransform * transform,   // /< the transform to apply
+                                 const psSphere * coord // /< the coordinate to apply the transform above.x
+                                );
+
+psSphereTransform *psSphereTransformICRStoEcliptic(psTime time);
+
+psSphereTransform *psSphereTransformEcliptictoICRS(psTime time);
+
+psSphereTransform *psSphereTransformICRStoGalatic(void);
+
+psSphereTransform *psSphereTransformGalatictoICRS(void);
+
+psPlane *psProject(const psSphere * coord, const psProjection * projection);
+
+psSphere *psDeproject(const psPlane * coord, const psProjection * projection);
+
+psSphere *psSphereGetOffset(const psSphere * restrict position1,
+                            const psSphere * restrict position2,
+                            psSphereOffsetMode mode, psSphereOffsetUnit unit);
+
+psSphere *psSphereSetOffset(const psSphere * restrict position,
+                            const psSphere * restrict offset,
+                            psSphereOffsetMode mode, psSphereOffsetUnit unit);
 
 /// @}
Index: trunk/psLib/src/astro/psTime.c
===================================================================
--- trunk/psLib/src/astro/psTime.c	(revision 1406)
+++ trunk/psLib/src/astro/psTime.c	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psTime.c
  *
@@ -12,13 +13,14 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-06 22:34:05 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-07 00:06:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
  */
 
-
 /******************************************************************************/
+
 /*  INCLUDE FILES                                                             */
+
 /******************************************************************************/
 
@@ -32,5 +34,7 @@
 
 /******************************************************************************/
+
 /*  DEFINE STATEMENTS                                                         */
+
 /******************************************************************************/
 
@@ -73,6 +77,9 @@
 }                                                                                                            \
 
+
 /******************************************************************************/
+
 /*  TYPE DEFINITIONS                                                          */
+
 /******************************************************************************/
 
@@ -80,5 +87,7 @@
 
 /*****************************************************************************/
+
 /*  GLOBAL VARIABLES                                                         */
+
 /*****************************************************************************/
 
@@ -86,5 +95,7 @@
 
 /*****************************************************************************/
+
 /*  FILE STATIC VARIABLES                                                    */
+
 /*****************************************************************************/
 
@@ -119,79 +130,57 @@
 
 // Table for Julian date of leapsecond update and current total number of leapseconds at that date
-static double leapseconds[NUM_LEAPSECOND_UPDATES][2] =
-    {
-        {
-            2441317.5, 10.0
-        },
-        {
-            2441499.5, 11.0
-        },
-        {
-            2441683.5, 12.0
-        },
-        {
-            2442048.5, 13.0
-        },
-        {
-            2442413.5, 14.0
-        },
-        {
-            2442778.5, 15.0
-        },
-        {
-            2443144.5, 16.0
-        },
-        {
-            2443509.5, 17.0
-        },
-        {
-            2443874.5, 18.0
-        },
-        {
-            2444239.5, 19.0
-        },
-        {
-            2444786.5, 20.0
-        },
-        {
-            2445151.5, 21.0
-        },
-        {
-            2445516.5, 22.0
-        },
-        {
-            2446247.5, 23.0
-        },
-        {
-            2447161.5, 24.0
-        },
-        {
-            2447892.5, 25.0
-        },
-        {
-            2448257.5, 26.0
-        },
-        {
-            2448804.5, 27.0
-        },
-        {
-            2449169.5, 28.0
-        },
-        {
-            2449534.5, 29.0
-        },
-        {
-            2450083.5, 30.0
-        },
-        {
-            2450630.5, 31.0
-        },
-        {
-            2451179.5, 32.0
-        }
-    };
-
-/*****************************************************************************/
+static double leapseconds[NUM_LEAPSECOND_UPDATES][2] = {
+            {
+                2441317.5, 10.0},
+            {
+                2441499.5, 11.0},
+            {
+                2441683.5, 12.0},
+            {
+                2442048.5, 13.0},
+            {
+                2442413.5, 14.0},
+            {
+                2442778.5, 15.0},
+            {
+                2443144.5, 16.0},
+            {
+                2443509.5, 17.0},
+            {
+                2443874.5, 18.0},
+            {
+                2444239.5, 19.0},
+            {
+                2444786.5, 20.0},
+            {
+                2445151.5, 21.0},
+            {
+                2445516.5, 22.0},
+            {
+                2446247.5, 23.0},
+            {
+                2447161.5, 24.0},
+            {
+                2447892.5, 25.0},
+            {
+                2448257.5, 26.0},
+            {
+                2448804.5, 27.0},
+            {
+                2449169.5, 28.0},
+            {
+                2449534.5, 29.0},
+            {
+                2450083.5, 30.0},
+            {
+                2450630.5, 31.0},
+            {
+                2451179.5, 32.0}
+        };
+
+/*****************************************************************************/
+
 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
+
 /*****************************************************************************/
 
@@ -199,5 +188,7 @@
 
 /*****************************************************************************/
+
 /* FUNCTION IMPLEMENTATION - PUBLIC                                          */
+
 /*****************************************************************************/
 
@@ -210,9 +201,8 @@
     time.tv_usec = 0;
 
-    if(gettimeofday(&now,(struct timezone *) 0) == -1) {
+    if (gettimeofday(&now, (struct timezone *)0) == -1) {
         psError(__func__, " : Line %d - Failed to get time", __LINE__);
         return time;
     }
-
     // Convert timeval time to psTime
     time.tv_sec = now.tv_sec;
@@ -220,10 +210,10 @@
 
     // Add most current leapseconds value to UTC time to get TAI time
-    time.tv_sec += leapseconds[NUM_LEAPSECOND_UPDATES-1][1];
+    time.tv_sec += leapseconds[NUM_LEAPSECOND_UPDATES - 1][1];
 
     return time;
 }
 
-char* psTimeToISO(psTime time)
+char *psTimeToISO(psTime time)
 {
     int ms = 0;
@@ -232,5 +222,5 @@
     struct tm *tmTime = NULL;
 
-    CHECK_NEGATIVE_TIME_STRUCT(time,NULL);
+    CHECK_NEGATIVE_TIME_STRUCT(time, NULL);
 
     tempString = psAlloc(MAX_TIME_STRING_LENGTH);
@@ -238,13 +228,13 @@
 
     // Converts psTime to YYYY/MM/DD,HH:MM:SS.SSS in string form
-    ms = time.tv_usec/1000;
+    ms = time.tv_usec / 1000;
 
     // tmTime variable is statically allocated, no need to free
     tmTime = gmtime(&time.tv_sec);
-    if(!strftime(tempString, MAX_TIME_STRING_LENGTH, "%Y/%m/%d,%H:%M:%S", tmTime)) {
+    if (!strftime(tempString, MAX_TIME_STRING_LENGTH, "%Y/%m/%d,%H:%M:%S", tmTime)) {
         psError(__func__, " : Line %d - Failed strftime conversion", __LINE__);
     }
 
-    if(snprintf(timeString,MAX_TIME_STRING_LENGTH,"%s.%3.3d", tempString, ms) < 0) {
+    if (snprintf(timeString, MAX_TIME_STRING_LENGTH, "%s.%3.3d", tempString, ms) < 0) {
         psError(__func__, " : Line %d - Failed snprintf conversion", __LINE__);
     }
@@ -262,11 +252,11 @@
     psTime outTime;
 
-    CHECK_NEGATIVE_TIME_STRUCT(time,outTime);
+    CHECK_NEGATIVE_TIME_STRUCT(time, outTime);
 
     // Find leapseconds to subtract from psTime to get UTC time
     jd = psTimeToJD(time);
     jdTable = leapseconds[0];
-    for(i=0; i<NUM_LEAPSECOND_UPDATES; i++, jdTable+=2) {
-        if(jd > *jdTable) {
+    for (i = 0; i < NUM_LEAPSECOND_UPDATES; i++, jdTable += 2) {
+        if (jd > *jdTable) {
             ls = *(jdTable + 1);
         }
@@ -276,5 +266,5 @@
     outTime.tv_usec = time.tv_usec;
 
-    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
+    CHECK_NEGATIVE_TIME_STRUCT(outTime, outTime);
 
     return outTime;
@@ -285,8 +275,8 @@
     double mjd = 0.0;
 
-    CHECK_NEGATIVE_TIME_STRUCT(time,mjd);
+    CHECK_NEGATIVE_TIME_STRUCT(time, mjd);
 
     // Modified Julian date conversion courtesy of Eugene Magnier
-    mjd = time.tv_sec/SEC_PER_DAY + time.tv_usec/USEC_PER_DAY + 40587.0;
+    mjd = time.tv_sec / SEC_PER_DAY + time.tv_usec / USEC_PER_DAY + 40587.0;
 
     return mjd;
@@ -297,8 +287,8 @@
     double jd = 0.0;
 
-    CHECK_NEGATIVE_TIME_STRUCT(time,jd);
+    CHECK_NEGATIVE_TIME_STRUCT(time, jd);
 
     // Julian date conversion courtesy of Eugene Magnier
-    jd = time.tv_sec/SEC_PER_DAY + time.tv_usec/USEC_PER_DAY + 2440587.5;
+    jd = time.tv_sec / SEC_PER_DAY + time.tv_usec / USEC_PER_DAY + 2440587.5;
 
     return jd;
@@ -309,5 +299,5 @@
     struct timeval timevalTime;
 
-    CHECK_NEGATIVE_TIME_STRUCT(time,timevalTime);
+    CHECK_NEGATIVE_TIME_STRUCT(time, timevalTime);
     timevalTime.tv_sec = time.tv_sec;
     timevalTime.tv_usec = time.tv_usec;
@@ -316,9 +306,9 @@
 }
 
-struct tm* psTimeToTM(psTime time)
+struct tm *psTimeToTM(psTime time)
 {
     struct tm *tmTime = NULL;
 
-    CHECK_NEGATIVE_TIME_STRUCT(time,tmTime);
+    CHECK_NEGATIVE_TIME_STRUCT(time, tmTime);
     tmTime = gmtime(&time.tv_sec);
 
@@ -343,42 +333,42 @@
     // Convert YYYY/MM/DD,HH:MM:SS.SSS in string form to tm time
     year = atoi(strtok(tempString, "/"));
-    if(year < 1900) {
-        psError(__func__,"Years less than 1900 not allowed. Value: %d", year);
+    if (year < 1900) {
+        psError(__func__, "Years less than 1900 not allowed. Value: %d", year);
         return outTime;
     }
 
     month = atoi(strtok(NULL, "/"));
-    if(month<1 || month>12) {
-        psError(__func__,"Month must have a value from 1 to 12. Value: %d", month);
+    if (month < 1 || month > 12) {
+        psError(__func__, "Month must have a value from 1 to 12. Value: %d", month);
         return outTime;
     }
 
     day = atoi(strtok(NULL, ","));
-    if(day<1 || day>31) {
-        psError(__func__,"Day must have a value from 1 to 31. Value: %d", day);
+    if (day < 1 || day > 31) {
+        psError(__func__, "Day must have a value from 1 to 31. Value: %d", day);
         return outTime;
     }
 
     hour = atoi(strtok(NULL, ":"));
-    if(hour<0 || hour>23) {
-        psError(__func__,"Hour must have a value from 0 to 23. Value: %d", hour);
+    if (hour < 0 || hour > 23) {
+        psError(__func__, "Hour must have a value from 0 to 23. Value: %d", hour);
         return outTime;
     }
 
     minute = atoi(strtok(NULL, ":"));
-    if(minute<0 || minute>59) {
-        psError(__func__,"Minute must have a value from 0 to 59. Value: %d", minute);
+    if (minute < 0 || minute > 59) {
+        psError(__func__, "Minute must have a value from 0 to 59. Value: %d", minute);
         return outTime;
     }
 
     second = atoi(strtok(NULL, "."));
-    if(second<0 || second>59) {
-        psError(__func__,"Second must have a value from 0 to 59. Value: %d", second);
+    if (second < 0 || second > 59) {
+        psError(__func__, "Second must have a value from 0 to 59. Value: %d", second);
         return outTime;
     }
 
     millisecond = atoi(strtok(NULL, "X"));
-    if(millisecond<0 || millisecond>1000) {
-        psError(__func__,"Millisecond must have a value from 0 to 999. Value: %d", millisecond);
+    if (millisecond < 0 || millisecond > 1000) {
+        psError(__func__, "Millisecond must have a value from 0 to 999. Value: %d", millisecond);
         return outTime;
     }
@@ -394,5 +384,5 @@
     // Convert tm time to psTime
     outTime = psTMToTime(&tmTime);
-    outTime.tv_usec = millisecond*1000;
+    outTime.tv_usec = millisecond * 1000;
 
     return outTime;
@@ -403,10 +393,10 @@
     psTime outTime;
 
-    CHECK_NEGATIVE_TIME_STRUCT(time,outTime);
+    CHECK_NEGATIVE_TIME_STRUCT(time, outTime);
 
     // Convert UTC time to psTime/TAI
-    outTime.tv_sec = time.tv_sec + leapseconds[NUM_LEAPSECOND_UPDATES-1][1];
+    outTime.tv_sec = time.tv_sec + leapseconds[NUM_LEAPSECOND_UPDATES - 1][1];
     outTime.tv_usec = time.tv_usec;
-    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
+    CHECK_NEGATIVE_TIME_STRUCT(outTime, outTime);
 
     return outTime;
@@ -419,5 +409,5 @@
     double seconds = 0.0;
 
-    CHECK_NEGATIVE_TIME(time,outTime);
+    CHECK_NEGATIVE_TIME(time, outTime);
 
     // Modified Julian date conversion courtesy of Eugene Magnier
@@ -425,9 +415,9 @@
 
     // Convert to psTime/TAI
-    seconds = days*SEC_PER_DAY;
-    outTime.tv_usec = (seconds -(long)seconds)*1000000.0;
+    seconds = days * SEC_PER_DAY;
+    outTime.tv_usec = (seconds - (long)seconds) * 1000000.0;
     outTime.tv_sec = seconds;
 
-    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
+    CHECK_NEGATIVE_TIME_STRUCT(outTime, outTime);
 
     return outTime;
@@ -440,5 +430,5 @@
     psTime outTime;
 
-    CHECK_NEGATIVE_TIME(time,outTime);
+    CHECK_NEGATIVE_TIME(time, outTime);
 
     // Julian date conversion courtesy of Eugene Magnier
@@ -446,106 +436,96 @@
 
     // Convert to psTime/TAI
-    seconds = days*SEC_PER_DAY;
+    seconds = days * SEC_PER_DAY;
     outTime.tv_sec = seconds;
-    outTime.tv_usec = (seconds -(long)seconds)*1000000.0;
-
-    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
-
-    return outTime;
-}
-
-psTime psTimevalToTime(struct timeval *time)
-{
-    psTime outTime;
-    if(time == NULL)
-    {
-        psError(__func__,"Null value for timeval arg not allowed");
-        return outTime;
-    } else
-        if(time->tv_sec < 0)
-        {
-            psError(__func__,"Negative seconds are not allowed: %ld", time->tv_sec);
-            return outTime;
-        } else
-            if(time->tv_usec<0)
-            {
-                psError(__func__,"Negative microseconds are not allowed: %ld", time->tv_usec);
-                return outTime;
-            }
-
+    outTime.tv_usec = (seconds - (long)seconds) * 1000000.0;
+
+    CHECK_NEGATIVE_TIME_STRUCT(outTime, outTime);
+
+    return outTime;
+}
+
+psTime psTimevalToTime(struct timeval * time)
+{
+    psTime outTime;
+
+    if (time == NULL)
+    {
+        psError(__func__, "Null value for timeval arg not allowed");
+        return outTime;
+    } else if (time->tv_sec < 0)
+    {
+        psError(__func__, "Negative seconds are not allowed: %ld", time->tv_sec);
+        return outTime;
+    } else if (time->tv_usec < 0)
+    {
+        psError(__func__, "Negative microseconds are not allowed: %ld", time->tv_usec);
+        return outTime;
+    }
     // Convert to psTime/TAI
     outTime.tv_sec = time->tv_sec;
     outTime.tv_usec = time->tv_usec;
 
-    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
-
-    return outTime;
-}
-
-
-psTime psTMToTime(struct tm *time)
+    CHECK_NEGATIVE_TIME_STRUCT(outTime, outTime);
+
+    return outTime;
+}
+
+psTime psTMToTime(struct tm * time)
 {
     int i;
     int n;
     int y;
-    int mon [] =
-        {
-            31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-        };
+    int mon[] = {
+                    31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+                };
     long epoch;
     psTime outTime;
 
-    i= 0;
+    i = 0;
     n = 0;
     y = 0;
     epoch = 0;
 
-    if(time == NULL)
-    {
-        psError(__func__,"Null value for tm arg not allowed");
-        return outTime;
-    } else
-        if(time->tm_year < 70)
-        {
-            psError(__func__,"Input times earlier than 1970 not allowed. Value: %d", time->tm_year+1900);
-            return outTime;
-        } else
-            if(time->tm_mon<0 || time->tm_mon>11)
-            {
-                psError(__func__,"Month must have a value from 0 to 11. Value: %d", time->tm_mon);
-                return outTime;
-            } else
-                if(time->tm_mday<1 || time->tm_mday>31)
-                {
-                    psError(__func__,"Day must have a value from 1 to 31. Value: %d", time->tm_mday);
-                    return outTime;
-                } else
-                    if(time->tm_hour<0 || time->tm_hour>23)
-                    {
-                        psError(__func__,"Hour must have a value from 0 to 23. Value: %d", time->tm_hour);
-                        return outTime;
-                    } else
-                        if(time->tm_min<0 || time->tm_min>59)
-                        {
-                            psError(__func__,"Minute must have a value from 0 to 59. Value: %d", time->tm_min);
-                            return outTime;
-                        } else
-                            if(time->tm_sec<0 || time->tm_sec>59)
-                            {
-                                psError(__func__,"Second must have a value from 0 to 59. Value: %d", time->tm_sec);
-                                return outTime;
-                            }
+    if (time == NULL)
+    {
+        psError(__func__, "Null value for tm arg not allowed");
+        return outTime;
+    } else if (time->tm_year < 70)
+    {
+        psError(__func__, "Input times earlier than 1970 not allowed. Value: %d", time->tm_year + 1900);
+        return outTime;
+    } else if (time->tm_mon < 0 || time->tm_mon > 11)
+    {
+        psError(__func__, "Month must have a value from 0 to 11. Value: %d", time->tm_mon);
+        return outTime;
+    } else if (time->tm_mday < 1 || time->tm_mday > 31)
+    {
+        psError(__func__, "Day must have a value from 1 to 31. Value: %d", time->tm_mday);
+        return outTime;
+    } else if (time->tm_hour < 0 || time->tm_hour > 23)
+    {
+        psError(__func__, "Hour must have a value from 0 to 23. Value: %d", time->tm_hour);
+        return outTime;
+    } else if (time->tm_min < 0 || time->tm_min > 59)
+    {
+        psError(__func__, "Minute must have a value from 0 to 59. Value: %d", time->tm_min);
+        return outTime;
+    } else if (time->tm_sec < 0 || time->tm_sec > 59)
+    {
+        psError(__func__, "Second must have a value from 0 to 59. Value: %d", time->tm_sec);
+        return outTime;
+    }
 
     n = time->tm_year + 1900 - 1;
-    epoch = (time->tm_year - 70) * SEC_PER_YEAR + ((n/4 - n/100 + n/400) -
-            (1969/4 - 1969/100 + 1969/400)) * SEC_PER_DAY;
+    epoch = (time->tm_year - 70) * SEC_PER_YEAR + ((n / 4 - n / 100 + n / 400) -
+            (1969 / 4 - 1969 / 100 + 1969 / 400)) * SEC_PER_DAY;
 
     y = time->tm_year + 1900;
 
     // Adjust for leap years
-    for(i = 0; i<time->tm_mon; i++)
-    {
-        epoch += mon [i] * SEC_PER_DAY;
-        if(i == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) {
+    for (i = 0; i < time->tm_mon; i++)
+    {
+        epoch += mon[i] * SEC_PER_DAY;
+        if (i == 1 && y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) {
             epoch += SEC_PER_DAY;
         }
@@ -554,5 +534,5 @@
     // Add everything
     epoch += (time->tm_mday - 1) * SEC_PER_DAY;
-    epoch += time->tm_hour *SEC_PER_HOUR + time->tm_min * SEC_PER_MINUTE + time->tm_sec;
+    epoch += time->tm_hour * SEC_PER_HOUR + time->tm_min * SEC_PER_MINUTE + time->tm_sec;
 
     // Create psTime
@@ -560,6 +540,6 @@
     outTime.tv_sec = epoch;
 
-    CHECK_NEGATIVE_TIME_STRUCT(outTime,outTime);
-
-    return outTime;
-}
+    CHECK_NEGATIVE_TIME_STRUCT(outTime, outTime);
+
+    return outTime;
+}
Index: trunk/psLib/src/astro/psTime.h
===================================================================
--- trunk/psLib/src/astro/psTime.h	(revision 1406)
+++ trunk/psLib/src/astro/psTime.h	(revision 1407)
@@ -1,2 +1,3 @@
+
 /** @file  psTime.h
  *
@@ -12,6 +13,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-08-06 22:34:05 $
+ *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-08-07 00:06:06 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -19,11 +20,11 @@
 
 #ifndef PSTIME_H
-#define PSTIME_H
-
-#include <time.h>
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include "psType.h"
+#    define PSTIME_H
+
+#    include <time.h>
+#    include <sys/types.h>
+#    include <sys/time.h>
+
+#    include "psType.h"
 
 /// @addtogroup Time
@@ -31,5 +32,7 @@
 
 /******************************************************************************/
+
 /*  TYPE DEFINITIONS                                                          */
+
 /******************************************************************************/
 
@@ -42,11 +45,15 @@
 typedef struct
 {
-    time_t        tv_sec;    /**< Seconds since epoch, Jan 1, 1970. */
-    suseconds_t   tv_usec;   /**< Microseconds since last second. */
+
+    time_t tv_sec;           /**< Seconds since epoch, Jan 1, 1970. */
+
+    suseconds_t tv_usec;     /**< Microseconds since last second. */
 }
 psTime;
 
 /*****************************************************************************/
+
 /* FUNCTION PROTOTYPES                                                       */
+
 /*****************************************************************************/
 
@@ -57,7 +64,8 @@
  *  @return  psTime: Struct with current time.
  */
-psTime psTimeGetTime(
-    void   /** No argument. */
-);
+
+psTime psTimeGetTime(void
+                     /** No argument. */
+                    );
 
 /** Convert psTime to ISO time in TAI units.
@@ -68,7 +76,8 @@
  *  @return  char*: Pointer null terminated array of chars in ISO time.
  */
-char* psTimeToISO(
-    psTime time     /** Input time to be converted. */
-);
+
+char *psTimeToISO(psTime time
+                  /** Input time to be converted. */
+                 );
 
 /** Convert psTime to UTC time.
@@ -80,7 +89,8 @@
  *  @return  psTime: UTC time psTime format.
  */
-psTime psTimeToUTC(
-    psTime time    /** Input time to be converted. */
-);
+
+psTime psTimeToUTC(psTime time
+                   /** Input time to be converted. */
+                  );
 
 /** Convert psTime to modified Julian date time.
@@ -91,7 +101,8 @@
  *  @return  double: Modified Julian Days (MJD) time.
  */
-double psTimeToMJD(
-    psTime time    /** Input time to be converted. */
-);
+
+double psTimeToMJD(psTime time
+                   /** Input time to be converted. */
+                  );
 
 /** Convert psTime to Julian date time.
@@ -102,7 +113,8 @@
  *  @return  double: Julian Date (JD) time.
  */
-double psTimeToJD(
-    psTime time    /** Input time to be converted. */
-);
+
+double psTimeToJD(psTime time
+                  /** Input time to be converted. */
+                 );
 
 /** Convert psTime to timeval time.
@@ -113,7 +125,8 @@
  *  @return  timeval: timeval struct time.
  */
-struct timeval psTimeToTimeval(
-                psTime time    /** Input time to be converted. */
-            );
+
+struct timeval psTimeToTimeval(psTime time
+                                           /** Input time to be converted. */
+                                          );
 
 /** Convert psTime to tm time.
@@ -124,7 +137,8 @@
  *  @return  tm: tm struct time.
  */
-struct tm* psTimeToTM(
-                psTime time    /** Input time to be converted. */
-            );
+
+struct tm *psTimeToTM(psTime time
+                                  /** Input time to be converted. */
+                                 );
 
 /** Convert ISO to psTime.
@@ -135,7 +149,8 @@
  *  @return  psTime: time
  */
-psTime psISOToTime(
-    char *time  /** Input time to be converted. */
-);
+
+psTime psISOToTime(char *time
+                   /** Input time to be converted. */
+                  );
 
 /** Convert UTC to psTime.
@@ -146,7 +161,8 @@
  *  @return  psTime: time in TAI units.
  */
-psTime psUTCToTime(
-    psTime time /** Input time to be converted. */
-);
+
+psTime psUTCToTime(psTime time
+                   /** Input time to be converted. */
+                  );
 
 /** Convert MJD to psTime.
@@ -157,7 +173,8 @@
  *  @return  psTime: time.
  */
-psTime psMJDToTime(
-    double time /** Input time to be converted. */
-);
+
+psTime psMJDToTime(double time
+                   /** Input time to be converted. */
+                  );
 
 /** Convert JD to psTime.
@@ -168,7 +185,8 @@
  *  @return  psTime: time.
  */
-psTime psJDToTime(
-    double time /** Input time to be converted. */
-);
+
+psTime psJDToTime(double time
+                  /** Input time to be converted. */
+                 );
 
 /** Convert timeval to psTime.
@@ -179,7 +197,8 @@
  *  @return  psTime: time.
  */
-psTime psTimevalToTime(
-    struct timeval *time    /** Input time to be converted. */
-);
+
+psTime psTimevalToTime(struct timeval *time
+                       /** Input time to be converted. */
+                      );
 
 /** Convert tm time to psTime.
@@ -190,7 +209,9 @@
  *  @return  psTime: time.
  */
-psTime psTMToTime(
-    struct tm *time /** Input time to be converted. */
-);
+
+psTime psTMToTime(struct tm *time
+                  /** Input time to be converted. */
+                 );
+
 /// @}
 
