Index: /trunk/psLib/test/astronomy/Makefile.am
===================================================================
--- /trunk/psLib/test/astronomy/Makefile.am	(revision 3450)
+++ /trunk/psLib/test/astronomy/Makefile.am	(revision 3451)
@@ -29,4 +29,5 @@
          tst_psAstrometry \
          tst_psCoord \
+         tst_psCoord01 \
          tst_psAstrometry01
 
@@ -62,4 +63,5 @@
 tst_psAstrometry_SOURCES = tst_psAstrometry.c
 tst_psCoord_SOURCES = tst_psCoord.c
+tst_psCoord01_SOURCES = tst_psCoord01.c
 tst_psAstrometry01_SOURCES = tst_psAstrometry01.c
 
Index: /trunk/psLib/test/astronomy/tst_psCoord.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psCoord.c	(revision 3450)
+++ /trunk/psLib/test/astronomy/tst_psCoord.c	(revision 3451)
@@ -6,10 +6,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.25 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-03-16 03:26:39 $
-*
-*  XXX: THe psProject() and psDeproject() functions do not work fully.  They
-*  are not tested here.  The SphereGet/SetOffset() code that rely on them
-*  is not tested.
+*  @version $Revision: 1.26 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-03-18 21:36:16 $
 *
 *  XXX: Test with a bad offfset unit type in the SphereGet/SetOffset() functions.
@@ -36,10 +32,6 @@
 static psS32 testSphereTransformGalacticToICRS( void );
 static psS32 testSphereTransformPrecess(void);
-//static psS32 test20( void );
-//static psS32 test21( void );
 static psS32 test40( void );
 static psS32 test41( void );
-//static psS32 test42( void );
-//static psS32 test43( void );
 testDescription tests[] = {
                               {testSphereTransformAlloc, 819, "psSphereTransformAlloc()", 0, false},
@@ -58,10 +50,6 @@
                               {testSphereTransformGalacticToICRS, 823, "psSphereTransformGalacticToICRS()", 0, false},
                               {testSphereTransformPrecess, 825, "psSphereTransformPrecess()", 0, false},
-                              //         {test20, 0000, "psProject()", 0, false},
-                              //         {test21, 0000, "psDeProject()", 0, false},
                               {test40, 0000, "psSphereGetOffset()", 0, false},
                               {test41, 0000, "psSphereSetOffset()", 0, false},
-                              //         {test42, 0000, "psProject(), psDeproject", 0, false},
-                              //         {test43, 0000, "psProject(), psDeproject", 0, false},
                               {NULL}
                           };
@@ -506,5 +494,4 @@
                 return 3;
             }
-            // printf("psSphereTransformApply (%f, %f) -> (%f, %f)\n", out.r, out.d, in.r, in.d);
         }
     }
@@ -1392,231 +1379,4 @@
 }
 
-psS32 test20( void )
-{
-    psS32 testStatus = 0;
-    psSphere in;
-    double expectX;
-    double expectY;
-    psPlane *out;
-    psProjection myProjection;
-    myProjection.R = DEG_TO_RAD(20.0);
-    myProjection.D = DEG_TO_RAD(10.0);
-    myProjection.Xs = 1.0;
-    myProjection.Ys = 1.0;
-
-    for (float r=0.0;r<180.0;r+=DEG_INC) {
-        for (float d=0.0;d<90.0;d+=DEG_INC) {
-            in.r = DEG_TO_RAD(r);
-            in.d = DEG_TO_RAD(d);
-            in.rErr = 0.0;
-            in.dErr = 0.0;
-
-            /******************************************************************
-             Tangent Plane Projection
-             *****************************************************************/
-            myProjection.type = PS_PROJ_TAN;
-            out = psProject(&in, &myProjection);
-            expectX = cos(in.r) * sin(in.d) / sin(in.r);
-            expectY = -cos(in.r) * cos(in.d) / sin(in.r);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 1);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 2);
-            psFree(out);
-
-            /******************************************************************
-             PS_PROJ_SIN Projection
-             *****************************************************************/
-            myProjection.type = PS_PROJ_SIN;
-            out = psProject(&in, &myProjection);
-            expectX = cos(in.d) * sin(in.d);
-            expectY = -cos(in.d) * cos(in.d);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 3);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 4);
-            psFree(out);
-
-            /******************************************************************
-             PS_PROJ_CAR Projection
-             *****************************************************************/
-            myProjection.type = PS_PROJ_CAR;
-            out = psProject(&in, &myProjection);
-
-            expectX = in.d;
-            expectY = in.r;
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 5);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 6);
-            psFree(out);
-
-            /******************************************************************
-             PS_PROJ_MER Projection
-             *****************************************************************/
-            myProjection.type = PS_PROJ_MER;
-            out = psProject(&in, &myProjection);
-
-            expectX = in.d;
-            expectY = log(tan(DEG_TO_RAD(45.0) + (0.5 * in.r)));
-
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 7);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 8);
-            psFree(out);
-
-            /******************************************************************
-             PS_PROJ_AIT Projection
-             *****************************************************************/
-            myProjection.type = PS_PROJ_AIT;
-            out = psProject(&in, &myProjection);
-
-
-            psF64 tmpF64  = PS_SQRT_F32(0.5 * (1.0 + (cos(in.r) * cos(0.5 * in.d))));
-            tmpF64 = 1.0 / tmpF64;
-            expectX = 2.0 * tmpF64 * cos(in.r) * sin(0.5 * in.d);
-            expectY = sin(in.r) * tmpF64;
-
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->x, expectX, 20);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->y, expectY, 21);
-            psFree(out);
-
-
-        }
-    }
-
-    printf("-------------------------------------------------------------------\n");
-    printf("Calling psProject() with NULL input coords.  Should generate error, return NULL.\n");
-    out = psProject(NULL, &myProjection);
-    if (out != NULL) {
-        printf("TEST ERROR: psSphereTransformEclipticToICRS() did not return NULL.\n");
-        testStatus = false;
-        out = NULL;
-    }
-
-    printf("-------------------------------------------------------------------\n");
-    printf("Calling psProject() with NULL psProjection.  Should generate error, return NULL.\n");
-    out = psProject(&in, NULL);
-    if (out != NULL) {
-        printf("TEST ERROR: psProject() did not return NULL.\n");
-        testStatus = false;
-        out = NULL;
-    }
-
-    printf("-------------------------------------------------------------------\n");
-
-    return(testStatus);
-}
-
-#define SPACE_INC 10.0
-psS32 test21( void )
-{
-    psS32 testStatus = 0;
-    psPlane in;
-    double R;
-    double expectD;
-    double expectR;
-    psSphere *out;
-    psProjection myProjection;
-    myProjection.R = DEG_TO_RAD(20.0);
-    myProjection.D = DEG_TO_RAD(10.0);
-    myProjection.Xs = 1.0;
-    myProjection.Ys = 1.0;
-
-    in.xErr = 0.0;
-    in.yErr = 0.0;
-    for (in.x=0.0; in.x<100.0; in.x+=SPACE_INC) {
-        for (in.y=0.0;in.y<100.0;in.y+=SPACE_INC) {
-
-            /******************************************************************
-             Tangent Plane Projection
-             *****************************************************************/
-            myProjection.type = PS_PROJ_TAN;
-            out = psDeproject(&in, &myProjection);
-
-            R = PS_SQRT_F32((in.x * in.x) + (in.y * in.y));
-            expectD = atan(1.0 / R);
-            expectR = atan2(-in.y, in.x);
-
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->r, expectR, 1);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->d, expectD, 2);
-            psFree(out);
-
-            /******************************************************************
-             PS_PROJ_SIN Projection
-             *****************************************************************/
-            myProjection.type = PS_PROJ_SIN;
-            out = psDeproject(&in, &myProjection);
-
-            R = sqrt((in.x * in.x) + (in.y * in.y));
-            expectD = p_psArg(-in.y, in.x);
-            expectR = acos((R * M_PI) / 180.0);
-
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->r, expectR, 3);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->d, expectD, 4);
-            psFree(out);
-
-            /******************************************************************
-             PS_PROJ_CAR Projection
-             *****************************************************************/
-            myProjection.type = PS_PROJ_CAR;
-            out = psDeproject(&in, &myProjection);
-
-            expectD = in.x;
-            expectR = in.y;
-
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->r, expectR, 3);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->d, expectD, 4);
-            psFree(out);
-
-            /******************************************************************
-             PS_PROJ_MER Projection
-             *****************************************************************/
-            myProjection.type = PS_PROJ_MER;
-            out = psDeproject(&in, &myProjection);
-
-            expectD = in.x;
-            expectR = (2.0 * atan(exp((in.y * M_PI / 180.0)))) - 180.0;
-
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->r, expectR, 3);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->d, expectD, 4);
-            psFree(out);
-
-
-            /******************************************************************
-             PS_PROJ_AIT Projection
-             *****************************************************************/
-            myProjection.type = PS_PROJ_AIT;
-            out = psDeproject(&in, &myProjection);
-
-            float chu1 = (in.x * M_PI) / 720.0;
-            chu1 *= chu1;
-            float chu2 = (in.y * M_PI) / 360.0;
-            chu2 *= chu2;
-            float chu = sqrt(1.0 - chu1 - chu2);
-            expectD = 2.0 * p_psArg((2.0 * chu * chu) - 1.0, (in.x * chu * M_PI) / 360.0);
-            expectR = asin((in.y * chu * M_PI) / 180.0);
-
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->r, expectR, 3);
-            PS_COMPARE_TINY_THEN_PRINT_ERROR(out->d, expectD, 4);
-            psFree(out);
-        }
-    }
-
-    printf("-------------------------------------------------------------------\n");
-    printf("Calling psDeproject() with NULL input coords.  Should generate error, return NULL.\n");
-    out = psDeproject(NULL, &myProjection);
-    if (out != NULL) {
-        printf("TEST ERROR: psDeproject() did not return NULL.\n");
-        testStatus = false;
-        out = NULL;
-    }
-
-    printf("-------------------------------------------------------------------\n");
-    printf("Calling psDeproject() with NULL psProjection.  Should generate error, return NULL.\n");
-    out = psDeproject(&in, NULL);
-    if (out != NULL) {
-        printf("TEST ERROR: psDeproject() did not return NULL.\n");
-        testStatus = false;
-        out = NULL;
-    }
-
-    printf("-------------------------------------------------------------------\n");
-
-    return(testStatus);
-}
 
 psS32 test40( void )
@@ -1882,67 +1642,2 @@
 }
 
-#define NUM_DEGREES 5
-/******************************************************************************
-test42(): This test attempts to verify the psProject() and psDeproject()
-functions.  We create an arbitrary psProjection.  We then project several
-spherical coordinates onto the plane and then immediately deproject them; we
-ensure that the resulting spherical coordinates are identical to the start
-coordinates.
- 
-Currently, this test works only for angles near the first quadrant.
- *****************************************************************************/
-psS32 test42( void )
-{
-    psS32 testStatus = 0;
-    psSphere projCenter;
-    psSphere startCoords;
-    psSphere *endCoords;
-    psPlane *planeCoords;
-
-    #define PROG_CENTER_R_DEG 15.0
-    #define PROG_CENTER_D_DEG 20.0
-
-    projCenter.r = DEG_TO_RAD(PROG_CENTER_R_DEG);
-    projCenter.d = DEG_TO_RAD(PROG_CENTER_D_DEG);
-    // Create the psProjection plane:
-    psProjection myProj;
-    myProj.R = projCenter.r;
-    myProj.D = projCenter.d;
-    myProj.Xs = 1.0;
-    myProj.Ys = 1.0;
-    myProj.type = PS_PROJ_TAN;
-
-    #define RADIUS_DEG 30.0
-    #define NUM_ANGLES 30
-    #define MY_DEG_INC ((2.0 * RADIUS_DEG) / NUM_ANGLES)
-
-    for (float r= (PROG_CENTER_R_DEG - RADIUS_DEG);
-            r<=(PROG_CENTER_R_DEG + RADIUS_DEG);
-            r+=MY_DEG_INC) {
-        printf("------------------------ r is %.1f ------------------------\n", r);
-        for (float d= (PROG_CENTER_D_DEG - RADIUS_DEG);
-                d<=(PROG_CENTER_D_DEG + RADIUS_DEG);
-                d+=MY_DEG_INC) {
-            startCoords.r = DEG_TO_RAD(r);
-            startCoords.d = DEG_TO_RAD(d);
-            printf("----- startCoords (R, D) is (%f, %f) is deg (%.1f, %.1f)  -----\n", startCoords.r, startCoords.d, r, d);
-
-            planeCoords = psProject(&startCoords, &myProj);
-            endCoords = psDeproject(planeCoords, &myProj);
-
-            if (testNonEqualF32(endCoords->r, startCoords.r) ||
-                    testNonEqualF32(endCoords->d, startCoords.d)) {
-                printf("ERROR: \n");
-                printf("    startCoords (R, D) is (%f, %f)\n", startCoords.r, startCoords.d);
-                //                printf("        plane Coords is (%f, %f)\n", planeCoords->x, planeCoords->y);
-                printf("    endCoords (R, D) is (%f, %f)\n", endCoords->r, endCoords->d);
-            }
-            psFree(planeCoords);
-            psFree(endCoords);
-        }
-    }
-    return(testStatus);
-}
-
-// This code will ...
-
Index: /trunk/psLib/test/astronomy/tst_psCoord01.c
===================================================================
--- /trunk/psLib/test/astronomy/tst_psCoord01.c	(revision 3451)
+++ /trunk/psLib/test/astronomy/tst_psCoord01.c	(revision 3451)
@@ -0,0 +1,578 @@
+/**  @file  tst_psCoord01.c
+*
+*    @brief  The code will test several functions with PSLib source file
+*            psCoord.c
+*
+*    @author Eric Van Alst, MHPCC
+*
+*    @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
+*    @date  $Date: 2005-03-18 21:36:16 $
+*
+*    Copyright 2005 Maui High Performance Computing Center, Univ. of Hawaii
+*/
+
+#include "pslib.h"
+#include "psTest.h"
+
+static psS32 testProjectionAlloc(void);
+static psS32 testProjectTan(void);
+static psS32 testDeprojectTan(void);
+static psS32 testProjectSin(void);
+static psS32 testDeprojectSin(void);
+static psS32 testProjectAit(void);
+static psS32 testDeprojectAit(void);
+static psS32 testProjectPar(void);
+static psS32 testDeprojectPar(void);
+static psS32 testProjectFail(void);
+static psS32 testDeprojectFail(void);
+
+testDescription tests[] = {
+                              {testProjectionAlloc, 000, "psProjectionAlloc",0,false},
+                              {testProjectTan, 000, "psProject(TAN)",0,false},
+                              {testDeprojectTan, 000, "psDeproject(TAN)",0,false},
+                              {testProjectSin, 000, "psProject(SIN)",0,false},
+                              {testDeprojectSin, 000, "psDeproject(SIN)",0,false},
+                              {testProjectAit, 000, "psProject(AIT)",0,false},
+                              {testDeprojectAit, 000, "psDeproject(AIT)",0,false},
+                              {testProjectPar, 000, "psProject(PAR)",0,false},
+                              {testDeprojectPar, 000, "psDeproject(PAR)",0,false},
+                              {testProjectFail, 000, "psProject",0,false},
+                              {testDeprojectFail, 000, "psProject",0,false},
+                              {NULL}
+                          };
+
+#define ERROR_TOL    0.0001
+#define TESTPOINTS   4
+
+//  alpha, delta, alpha-center, delta-center, scale-x, scale-y
+psF64 projectionTestPoint[TESTPOINTS][6] = {
+            {  0.785398,  0.785398,  0.000000,  0.000000,  1.000000,  1.000000 },
+            {  0.100000,  1.500000,  0.500000,  0.250000,  1.000000,  1.000000 },
+            {  0.628319,  0.448799,  0.000000,  0.000000,  0.250000,  0.750000 },
+            { -1.047196,  0.222222, -0.250000,  0.000000,  1.500000,  1.250000 }
+        };
+
+// Expected values for TAN
+psF64 projectionTanExpected[TESTPOINTS][2] = {
+            { -1.000000, -1.414214 },
+            {  0.088884, -3.066567 },
+            { -0.181636, -0.446444 },
+            {  1.535818, -0.404231 }
+        };
+
+// Expected values for SIN
+psF64 projectionSinExpected[TESTPOINTS][2] = {
+            { -0.500000, -0.707101 },
+            {  0.027546, -0.950366 },
+            { -0.132394, -0.325413 },
+            {  1.046712, -0.275497 }
+        };
+
+// Expected values for AIT
+psF64 projectionAitExpected[TESTPOINTS][2] = {
+            { -0.549175,  0.523375 },
+            {  0.027895,  0.313807 },
+            { -0.162822,  0.607646 },
+            {  1.455312,  0.955388 }
+        };
+
+// Expected values for PAR
+psF64 projectionParExpected[TESTPOINTS][2] = {
+            { -0.541244,  0.545532 },
+            {  0.027703,  0.329366 },
+            { -0.157157,  0.633550 },
+            {  1.432951,  0.971372 }
+        };
+
+psS32 main( psS32 argc, char* argv[] )
+{
+    psLogSetLevel( PS_LOG_INFO );
+
+    return ( !runTestSuite(stderr,"psCoord",tests,argc,argv) );
+}
+
+psS32 testProjectionAlloc(void)
+{
+    // Allocate new psProjection structure
+    psProjection*  myProjection = psProjectionAlloc(1.1, 2.2, 3.3, 4.4, PS_PROJ_AIT);
+
+    // Verify NULL is not returned
+    if(myProjection == NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Unexpected return of NULL");
+        return 1;
+    }
+    // Verify the members are set correctly
+    if(myProjection->R != 1.1) {
+        psError(PS_ERR_UNKNOWN,true,"R member set to %lg, but expected %lg",
+                myProjection->R, 1.1);
+        return 2;
+    }
+    if(myProjection->D != 2.2) {
+        psError(PS_ERR_UNKNOWN,true,"D member set to %lg, but expected %lg",
+                myProjection->D, 2.2);
+        return 3;
+    }
+    if(myProjection->Xs != 3.3) {
+        psError(PS_ERR_UNKNOWN,true,"Xs member set to %lg, but expected %lg",
+                myProjection->Xs, 3.3);
+        return 4;
+    }
+    if(myProjection->Ys != 4.4) {
+        psError(PS_ERR_UNKNOWN,true,"Ys member set to %lg, but expected %lg",
+                myProjection->Ys, 4.4);
+        return 5;
+    }
+    if(myProjection->type != PS_PROJ_AIT) {
+        psError(PS_ERR_UNKNOWN,true,"type member set to %d, but expected %d",
+                myProjection->type, PS_PROJ_AIT);
+        return 6;
+    }
+
+    // Free projection
+    psFree(myProjection);
+
+    return 0;
+}
+
+psS32 testProjectTan(void)
+{
+    psPlane*       out = NULL;
+    psSphere*      in = psSphereAlloc();
+    psProjection*  myProjection = psProjectionAlloc(0.0,0.0,1.0,1.0,PS_PROJ_TAN);
+
+    // Perform projecton on various test points
+    for(psS32 i = 0; i < TESTPOINTS; i++) {
+
+        // Initialize input and project members
+        in->r = projectionTestPoint[i][0];
+        in->d = projectionTestPoint[i][1];
+        myProjection->R = projectionTestPoint[i][2];
+        myProjection->D = projectionTestPoint[i][3];
+        myProjection->Xs = projectionTestPoint[i][4];
+        myProjection->Ys = projectionTestPoint[i][5];
+
+        // Perform projection
+        out = psProject(in, myProjection);
+
+        // Verify output not NULL
+        if(out == NULL) {
+            psError(PS_ERR_UNKNOWN,true,"Return null not expected");
+            return i*10;
+        }
+
+        // Verify output is as expected
+        if(fabs(out->x - projectionTanExpected[i][0]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psPlane->x = %lg  expected %lg",
+                    i,out->x, projectionTanExpected[i][0]);
+            return i*10+1;
+        }
+        if(fabs(out->y - projectionTanExpected[i][1]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint % d  psPlane->y = %lg  expected %lg",
+                    i,out->y, projectionTanExpected[i][1]);
+            return i*10+2;
+        }
+        psFree(out);
+    }
+
+    psFree(in);
+    psFree(myProjection);
+
+    return 0;
+}
+
+psS32 testDeprojectTan(void)
+{
+    psSphere*       out = NULL;
+    psPlane*        in = psPlaneAlloc();
+    psProjection*   myProjection = psProjectionAlloc(0.0,0.0,1.0,1.0,PS_PROJ_TAN);
+
+    // Perform deprojection on various test points
+    for(psS32 i = 0; i < TESTPOINTS; i++) {
+
+        // Initialize input and projection members
+        in->x = projectionTanExpected[i][0];
+        in->y = projectionTanExpected[i][1];
+        myProjection->R = projectionTestPoint[i][2];
+        myProjection->D = projectionTestPoint[i][3];
+        myProjection->Xs = projectionTestPoint[i][4];
+        myProjection->Ys = projectionTestPoint[i][5];
+
+        // Perform deprojection
+        out = psDeproject(in, myProjection);
+
+        // Verify output is not NULL
+        if(out == NULL) {
+            psError(PS_ERR_UNKNOWN,true,"Return null not expected");
+            return 20*i;
+        }
+
+        // Verify output is as expected
+        if(fabs(out->r - projectionTestPoint[i][0]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psSphere->r = %lg  expected %lg",
+                    i,out->r,projectionTestPoint[i][0]);
+            return 20*i + 1;
+        }
+        if(fabs(out->d - projectionTestPoint[i][1]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psSphere->d = %lg expected %lg",
+                    i, out->d, projectionTestPoint[i][1]);
+            return 20*i + 2;
+        }
+        psFree(out);
+    }
+
+    psFree(in);
+    psFree(myProjection);
+
+    return 0;
+}
+
+psS32 testProjectSin(void)
+{
+    psPlane*       out = NULL;
+    psSphere*      in = psSphereAlloc();
+    psProjection*  myProjection = psProjectionAlloc(0.0,0.0,1.0,1.0,PS_PROJ_SIN);
+
+    // Perform projecton on various test points
+    for(psS32 i = 0; i < TESTPOINTS; i++) {
+
+        // Initialize input and project members
+        in->r = projectionTestPoint[i][0];
+        in->d = projectionTestPoint[i][1];
+        myProjection->R = projectionTestPoint[i][2];
+        myProjection->D = projectionTestPoint[i][3];
+        myProjection->Xs = projectionTestPoint[i][4];
+        myProjection->Ys = projectionTestPoint[i][5];
+
+        // Perform projection
+        out = psProject(in, myProjection);
+
+        // Verify output not NULL
+        if(out == NULL) {
+            psError(PS_ERR_UNKNOWN,true,"Return null not expected");
+            return i*10;
+        }
+
+        // Verify output is as expected
+        if(fabs(out->x - projectionSinExpected[i][0]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psPlane->x = %lg  expected %lg",
+                    i,out->x, projectionSinExpected[i][0]);
+            return i*10+1;
+        }
+        if(fabs(out->y - projectionSinExpected[i][1]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint % d  psPlane->y = %lg  expected %lg",
+                    i,out->y, projectionSinExpected[i][1]);
+            return i*10+2;
+        }
+        psFree(out);
+    }
+
+    psFree(in);
+    psFree(myProjection);
+
+    return 0;
+}
+
+psS32 testDeprojectSin(void)
+{
+    psSphere*       out = NULL;
+    psPlane*        in = psPlaneAlloc();
+    psProjection*   myProjection = psProjectionAlloc(0.0,0.0,1.0,1.0,PS_PROJ_SIN);
+
+    // Perform deprojection on various test points
+    for(psS32 i = 0; i < TESTPOINTS; i++) {
+
+        // Initialize input and projection members
+        in->x = projectionSinExpected[i][0];
+        in->y = projectionSinExpected[i][1];
+        myProjection->R = projectionTestPoint[i][2];
+        myProjection->D = projectionTestPoint[i][3];
+        myProjection->Xs = projectionTestPoint[i][4];
+        myProjection->Ys = projectionTestPoint[i][5];
+
+        // Perform deprojection
+        out = psDeproject(in, myProjection);
+
+        // Verify output is not NULL
+        if(out == NULL) {
+            psError(PS_ERR_UNKNOWN,true,"Return null not expected");
+            return 20*i;
+        }
+
+        // Verify output is as expected
+        if(fabs(out->r - projectionTestPoint[i][0]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psSphere->r = %lg  expected %lg",
+                    i,out->r,projectionTestPoint[i][0]);
+            return 20*i + 1;
+        }
+        if(fabs(out->d - projectionTestPoint[i][1]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psSphere->d = %lg expected %lg",
+                    i, out->d, projectionTestPoint[i][1]);
+            return 20*i + 2;
+        }
+        psFree(out);
+    }
+
+    psFree(in);
+    psFree(myProjection);
+
+    return 0;
+}
+
+psS32 testProjectAit(void)
+{
+    psPlane*       out = NULL;
+    psSphere*      in = psSphereAlloc();
+    psProjection*  myProjection = psProjectionAlloc(0.0,0.0,1.0,1.0,PS_PROJ_AIT);
+
+    // Perform projecton on various test points
+    for(psS32 i = 0; i < TESTPOINTS; i++) {
+
+        // Initialize input and project members
+        in->r = projectionTestPoint[i][0];
+        in->d = projectionTestPoint[i][1];
+        myProjection->R = projectionTestPoint[i][2];
+        myProjection->D = projectionTestPoint[i][3];
+        myProjection->Xs = projectionTestPoint[i][4];
+        myProjection->Ys = projectionTestPoint[i][5];
+
+        // Perform projection
+        out = psProject(in, myProjection);
+
+        // Verify output not NULL
+        if(out == NULL) {
+            psError(PS_ERR_UNKNOWN,true,"Return null not expected");
+            return i*10;
+        }
+
+        // Verify output is as expected
+        if(fabs(out->x - projectionAitExpected[i][0]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psPlane->x = %lg  expected %lg",
+                    i,out->x, projectionAitExpected[i][0]);
+            return i*10+1;
+        }
+        if(fabs(out->y - projectionAitExpected[i][1]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint % d  psPlane->y = %lg  expected %lg",
+                    i,out->y, projectionAitExpected[i][1]);
+            return i*10+2;
+        }
+        psFree(out);
+    }
+
+    psFree(in);
+    psFree(myProjection);
+
+    return 0;
+}
+
+psS32 testDeprojectAit(void)
+{
+    psSphere*       out = NULL;
+    psPlane*        in = psPlaneAlloc();
+    psProjection*   myProjection = psProjectionAlloc(0.0,0.0,1.0,1.0,PS_PROJ_AIT);
+
+    // Perform deprojection on various test points
+    for(psS32 i = 0; i < TESTPOINTS; i++) {
+
+        // Initialize input and projection members
+        in->x = projectionAitExpected[i][0];
+        in->y = projectionAitExpected[i][1];
+        myProjection->R = projectionTestPoint[i][2];
+        myProjection->D = projectionTestPoint[i][3];
+        myProjection->Xs = projectionTestPoint[i][4];
+        myProjection->Ys = projectionTestPoint[i][5];
+
+        // Perform deprojection
+        out = psDeproject(in, myProjection);
+
+        // Verify output is not NULL
+        if(out == NULL) {
+            psError(PS_ERR_UNKNOWN,true,"Return null not expected");
+            return 20*i;
+        }
+
+        // Verify output is as expected
+        if(fabs(out->r - projectionTestPoint[i][0]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psSphere->r = %lg  expected %lg",
+                    i,out->r,projectionTestPoint[i][0]);
+            return 20*i + 1;
+        }
+        if(fabs(out->d - projectionTestPoint[i][1]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psSphere->d = %lg expected %lg",
+                    i, out->d, projectionTestPoint[i][1]);
+            return 20*i + 2;
+        }
+        psFree(out);
+    }
+
+    psFree(in);
+    psFree(myProjection);
+
+    return 0;
+}
+
+psS32 testProjectPar(void)
+{
+    psPlane*       out = NULL;
+    psSphere*      in = psSphereAlloc();
+    psProjection*  myProjection = psProjectionAlloc(0.0,0.0,1.0,1.0,PS_PROJ_PAR);
+
+    // Perform projecton on various test points
+    for(psS32 i = 0; i < TESTPOINTS; i++) {
+
+        // Initialize input and project members
+        in->r = projectionTestPoint[i][0];
+        in->d = projectionTestPoint[i][1];
+        myProjection->R = projectionTestPoint[i][2];
+        myProjection->D = projectionTestPoint[i][3];
+        myProjection->Xs = projectionTestPoint[i][4];
+        myProjection->Ys = projectionTestPoint[i][5];
+
+        // Perform projection
+        out = psProject(in, myProjection);
+
+        // Verify output not NULL
+        if(out == NULL) {
+            psError(PS_ERR_UNKNOWN,true,"Return null not expected");
+            return i*10;
+        }
+
+        // Verify output is as expected
+        if(fabs(out->x - projectionParExpected[i][0]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psPlane->x = %lg  expected %lg",
+                    i,out->x, projectionParExpected[i][0]);
+            return i*10+1;
+        }
+        if(fabs(out->y - projectionParExpected[i][1]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint % d  psPlane->y = %lg  expected %lg",
+                    i,out->y, projectionParExpected[i][1]);
+            return i*10+2;
+        }
+        psFree(out);
+    }
+
+    psFree(in);
+    psFree(myProjection);
+
+    return 0;
+}
+
+psS32 testDeprojectPar(void)
+{
+    psSphere*       out = NULL;
+    psPlane*        in = psPlaneAlloc();
+    psProjection*   myProjection = psProjectionAlloc(0.0,0.0,1.0,1.0,PS_PROJ_PAR);
+
+    // Perform deprojection on various test points
+    for(psS32 i = 0; i < TESTPOINTS; i++) {
+
+        // Initialize input and projection members
+        in->x = projectionParExpected[i][0];
+        in->y = projectionParExpected[i][1];
+        myProjection->R = projectionTestPoint[i][2];
+        myProjection->D = projectionTestPoint[i][3];
+        myProjection->Xs = projectionTestPoint[i][4];
+        myProjection->Ys = projectionTestPoint[i][5];
+
+        // Perform deprojection
+        out = psDeproject(in, myProjection);
+
+        // Verify output is not NULL
+        if(out == NULL) {
+            psError(PS_ERR_UNKNOWN,true,"Return null not expected");
+            return 20*i;
+        }
+
+        // Verify output is as expected
+        if(fabs(out->r - projectionTestPoint[i][0]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psSphere->r = %lg  expected %lg",
+                    i,out->r,projectionTestPoint[i][0]);
+            return 20*i + 1;
+        }
+        if(fabs(out->d - projectionTestPoint[i][1]) > ERROR_TOL) {
+            psError(PS_ERR_UNKNOWN,true,"Testpoint %d  psSphere->d = %lg expected %lg",
+                    i, out->d, projectionTestPoint[i][1]);
+            return 20*i + 2;
+        }
+        psFree(out);
+    }
+
+    psFree(in);
+    psFree(myProjection);
+
+    return 0;
+}
+
+psS32 testProjectFail(void)
+{
+    psPlane*       out          = NULL;
+    psProjection*  myProjection = psProjectionAlloc(0.0,0.0,1.0,1.0,PS_PROJ_TAN);
+    psSphere*      in           = psSphereAlloc();
+
+    // Invoke function with null coordinate argument
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for null coord arg");
+    out = psProject(NULL, myProjection);
+    if(out != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return null as expected");
+        return 1;
+    }
+
+    // Invoke function with null projection argument
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for null projection arg");
+    out = psProject(in, NULL);
+    if(out != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return null as expected");
+        return 2;
+    }
+
+    // Invoke function with invalid projection type
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid projection type");
+    myProjection->type = PS_PROJ_NTYPE;
+    out = psProject(in,myProjection);
+    if(out != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return null as expected");
+        return 3;
+    }
+
+    psFree(myProjection);
+    psFree(in);
+
+    return 0;
+}
+
+psS32 testDeprojectFail(void)
+{
+    psSphere*      out          = NULL;
+    psProjection*  myProjection = psProjectionAlloc(0.0,0.0,1.0,1.0,PS_PROJ_TAN);
+    psPlane*       in           = psPlaneAlloc();
+
+    // Invoke function with null coordinate argument
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for null coord arg");
+    out = psDeproject(NULL, myProjection);
+    if(out != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return null as expected");
+        return 1;
+    }
+
+    // Invoke function with null projection argument
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for null projection arg");
+    out = psDeproject(in, NULL);
+    if(out != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return null as expected");
+        return 2;
+    }
+
+    // Invoke function with invalid projection type
+    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for invalid projection type");
+    myProjection->type = PS_PROJ_NTYPE;
+    out = psDeproject(in,myProjection);
+    if(out != NULL) {
+        psError(PS_ERR_UNKNOWN,true,"Did not return null as expected");
+        return 3;
+    }
+
+    psFree(myProjection);
+    psFree(in);
+
+    return 0;
+}
+
