Index: trunk/psLib/src/astro/psCoord.c
===================================================================
--- trunk/psLib/src/astro/psCoord.c	(revision 1374)
+++ trunk/psLib/src/astro/psCoord.c	(revision 1385)
@@ -10,6 +10,6 @@
 *  @author George Gusciora, MHPCC
 *
-*  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2004-08-04 00:55:17 $
+*  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2004-08-04 23:37:39 $
 *
 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -33,14 +33,14 @@
 {
     if ( out == NULL ) {
-            out = ( psPlane * ) psAlloc( sizeof( psPlane ) );
-        }
+        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 );
 }
@@ -56,7 +56,7 @@
 {
     if ( out == NULL ) {
-            out = ( psPlane * ) psAlloc( sizeof( psPlane ) );
-        }
-        
+        out = ( psPlane * ) psAlloc( sizeof( psPlane ) );
+    }
+
     out->x = transform->x->coeff[ 0 ][ 0 ][ 0 ][ 0 ] +
              ( transform->x->coeff[ 1 ][ 0 ][ 0 ][ 0 ] * coords->x ) +
@@ -64,5 +64,5 @@
              ( 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 ) +
@@ -70,5 +70,5 @@
              ( transform->y->coeff[ 0 ][ 0 ][ 1 ][ 0 ] * term3 ) +
              ( transform->y->coeff[ 0 ][ 0 ][ 0 ][ 1 ] * term4 );
-             
+
     return ( out );
 }
@@ -81,10 +81,10 @@
 {
     psSphereTransform * tmp = ( psSphereTransform * ) psAlloc( sizeof( psSphereTransform ) );
-    
+
     tmp->sinPhi = sin( NPlat );
     tmp->cosPhi = cos( NPlat );
     tmp->Xo = Xo;
     tmp->xo = xo;
-    
+
     return ( tmp );
 }
@@ -114,9 +114,9 @@
     double y = 0.0;
     double dx = 0.0;
-    
+
     if ( out == NULL ) {
-            out = ( psSphere * ) psAlloc( sizeof( psSphere ) );
-        }
-        
+        out = ( psSphere * ) psAlloc( sizeof( psSphere ) );
+    }
+
     x = coord->r;
     y = coord->d;
@@ -127,8 +127,8 @@
            cos( y );
     cosX = cos( y ) * cos( dx ) / cos( y );
-    
+
     out->r = atan2( sinX, cosX ) + transform->Xo;
     out->d = atan2( sinY, cosY );
-    
+
     return ( out );
 }
@@ -142,5 +142,5 @@
     double Xo = 0.0;
     double xo = 0.0;
-    
+
     return ( psSphereTransformAlloc( phi, Xo, xo ) );
 }
@@ -154,5 +154,5 @@
     double Xo = 0.0;
     double xo = 0.0;
-    
+
     return ( psSphereTransformAlloc( phi, Xo, xo ) );
 }
@@ -178,15 +178,19 @@
 {
     if ( x > 0 ) {
-            return ( atan( y / x ) );
-        } else if ( ( x == 0 ) && ( y == 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 ) );
-        }
-        
+        } 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 );
@@ -201,37 +205,43 @@
     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 = 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" );
-        }
-        
+
+        } 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 );
 }
@@ -247,40 +257,46 @@
     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 = 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" );
-        }
-        
+
+        } 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 );
 }
@@ -298,41 +314,45 @@
     double tmpR = 0.0;
     double tmpD = 0.0;
-    
+
     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
-            // points on the plane, then deproject?
-            
-            // XXX: Do I need to somehow scale this projection?
-            // project position1?  Will it project to (0.0, 0.0)?
-            proj.R = position1->r;
-            proj.D = position1->d;
-            proj.Xs = 1.0;
-            proj.Ys = 1.0;
-            proj.type = PS_PROJ_TAN;
-            
-            //        lin = psProject(position2, proj);
-            //        tmp = psDeproject(lin, proj);
-            
-            // XXX: Do we need to convert units in tmp?
-            return ( tmp );
-        } else if ( mode == PS_SPHERICAL ) {
+        // XXX: I have no idea how to construct this.  Maybe project both
+        // sperical positions onto the plane, set the origin at one of the
+        // points on the plane, then deproject?
+
+        // XXX: Do I need to somehow scale this projection?
+        // project position1?  Will it project to (0.0, 0.0)?
+        proj.R = position1->r;
+        proj.D = position1->d;
+        proj.Xs = 1.0;
+        proj.Ys = 1.0;
+        proj.type = PS_PROJ_TAN;
+
+        //        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 * 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 );
-                }
-                
+                } 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;
@@ -361,35 +381,39 @@
     double tmpR = 0.0;
     double tmpD = 0.0;
-    
+
     if ( mode == PS_LINEAR ) {
-            proj.R = position->r;
-            proj.D = position->d;
-            proj.Xs = 1.0;
-            proj.Ys = 1.0;
-            proj.type = PS_PROJ_TAN;
-            
-            lin.x = offset->r;
-            lin.y = offset->d;
-            
-            tmp = psDeproject( &lin, &proj );
-            return ( tmp );
-            
-        } else if ( mode == PS_SPHERICAL ) {
+        proj.R = position->r;
+        proj.D = position->d;
+        proj.Xs = 1.0;
+        proj.Ys = 1.0;
+        proj.type = PS_PROJ_TAN;
+
+        lin.x = offset->r;
+        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 * 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 );
-                }
-                
+                } 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;
@@ -397,5 +421,5 @@
             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).
