Index: trunk/psLib/src/astro/psCoord.c
===================================================================
--- trunk/psLib/src/astro/psCoord.c	(revision 6204)
+++ trunk/psLib/src/astro/psCoord.c	(revision 6230)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.101 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2006-01-26 21:10:22 $
+*  @version $Revision: 1.102 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2006-01-28 01:31:44 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -206,5 +206,6 @@
 
 // XXX: Verify the order/nterms poly changes
-psPlaneTransform* psPlaneTransformAlloc(int order1, int order2)
+psPlaneTransform* psPlaneTransformAlloc(int order1,
+                                        int order2)
 {
     PS_ASSERT_INT_NONNEGATIVE(order1, NULL);
@@ -240,8 +241,7 @@
 }
 
-psPlane* psPlaneTransformApply(
-    psPlane* out,
-    const psPlaneTransform* transform,
-    const psPlane* coords)
+psPlane* psPlaneTransformApply(psPlane* out,
+                               const psPlaneTransform* transform,
+                               const psPlane* coords)
 {
     PS_ASSERT_PTR_NON_NULL(transform, NULL);
@@ -267,5 +267,8 @@
 
 // XXX: Verify the order/nterms poly changes
-psPlaneDistort* psPlaneDistortAlloc(int order1, int order2, int order3, int order4)
+psPlaneDistort* psPlaneDistortAlloc(int order1,
+                                    int order2,
+                                    int order3,
+                                    int order4)
 {
     PS_ASSERT_INT_NONNEGATIVE(order1, NULL);
@@ -347,10 +350,9 @@
 }
 
-psProjection* psProjectionAlloc(
-    double R,
-    double D,
-    double Xs,
-    double Ys,
-    psProjectionType type)
+psProjection* psProjectionAlloc(double R,
+                                double D,
+                                double Xs,
+                                double Ys,
+                                psProjectionType type)
 {
     psProjection *p = psAlloc(sizeof(psProjection));
@@ -372,8 +374,7 @@
 
 
-psPlane* p_psProject(
-    psPlane *outPlane,
-    const psSphere* coord,
-    const psProjection* projection)
+psPlane* p_psProject(psPlane *outPlane,
+                     const psSphere* coord,
+                     const psProjection* projection)
 {
     PS_ASSERT_PTR_NON_NULL(coord, NULL);
@@ -457,8 +458,7 @@
 }
 
-psSphere* p_psDeproject(
-    psSphere *outSphere,
-    const psPlane* coord,
-    const psProjection* projection)
+psSphere* p_psDeproject(psSphere *outSphere,
+                        const psPlane* coord,
+                        const psProjection* projection)
 {
     PS_ASSERT_PTR_NON_NULL(coord, NULL);
@@ -604,10 +604,9 @@
 routine far too many times.
  *****************************************************************************/
-psPlaneTransform *psPlaneTransformCombine(
-    psPlaneTransform *out,
-    const psPlaneTransform *trans1,
-    const psPlaneTransform *trans2,
-    psRegion region,
-    int nSamples)
+psPlaneTransform *psPlaneTransformCombine(psPlaneTransform *out,
+        const psPlaneTransform *trans1,
+        const psPlaneTransform *trans2,
+        psRegion region,
+        int nSamples)
 {
     psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
@@ -1016,9 +1015,7 @@
 }
 
-psPlane *psPlaneTransformDeriv(
-    psPlane *out,
-    const psPlaneTransform *transformation,
-    const psPlane *coord
-)
+psPlane *psPlaneTransformDeriv(psPlane *out,
+                               const psPlaneTransform *transformation,
+                               const psPlane *coord)
 {
     PS_ASSERT_PTR_NON_NULL(transformation, NULL);
@@ -1080,4 +1077,51 @@
     }
     return(out);
+}
+
+psPixels *psPixelsTransform(psPixels *out,
+                            const psPixels *input,
+                            const psPlaneTransform *inToOut)
+{
+    PS_ASSERT_PTR_NON_NULL(input, NULL);
+    PS_ASSERT_PTR_NON_NULL(inToOut, NULL);
+    PS_ASSERT_PTR_NON_NULL(inToOut->x, NULL);
+    PS_ASSERT_PTR_NON_NULL(inToOut->y, NULL);
+    if (out == NULL) {
+        //XXX: Should the length (nalloc) be 1 and append be used everytime a pixel is added?
+        //        out = psPixelsAlloc(input->nalloc);
+        out = psPixelsAlloc(1);
+    }
+    psPlane *coord = psPlaneAlloc();
+    psPlane *deriv = psPlaneAlloc();
+    psPlane *fxnVal = psPlaneAlloc();
+
+    int i = 0;
+    //    int m = 0;
+    //    while (input->data.x[i] != 0.0 && input->data.y[i] != 0.0) {
+    for ( i = 0; i < input->n; i++) {
+        coord->x = input->data[i].x;
+        coord->y = input->data[i].y;
+        deriv = psPlaneTransformDeriv(deriv, inToOut, coord);
+        fxnVal = psPlaneTransformApply(fxnVal, inToOut, coord);
+        if (fabs(fxnVal->x - coord->x) < fabs(deriv->x) &&
+                fabs(fxnVal->y - coord->y) < fabs(deriv->y)) {
+            int x = (int)(round(fabs(deriv->x)));
+            int y = (int)(round(fabs(deriv->y)));
+            for (int j = -x; j <= x; j++) {
+                for (int k = -y; k <= y; k++) {
+                    //                    out->data[m].x = fxnVal->x + x;
+                    //                    out->data[m].y = fxnVal->y + y;
+                    //                    m++;
+                    out = p_psPixelsAppend(out, 1, (float)(fxnVal->x+j),
+                                           (float)(fxnVal->y+k) );
+                }
+            }
+        }
+    }
+
+    psFree(coord);
+    psFree(deriv);
+    psFree(fxnVal);
+    return out;
 }
 
