Index: trunk/psLib/src/astro/psCoord.c
===================================================================
--- trunk/psLib/src/astro/psCoord.c	(revision 3682)
+++ trunk/psLib/src/astro/psCoord.c	(revision 3711)
@@ -10,6 +10,6 @@
 *  @author GLG, MHPCC
 *
-*  @version $Revision: 1.62 $ $Name: not supported by cvs2svn $
-*  @date $Date: 2005-04-07 20:27:41 $
+*  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
+*  @date $Date: 2005-04-19 01:22:59 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -61,39 +61,4 @@
 /*  FUNCTION IMPLEMENTATION - LOCAL                                          */
 /*****************************************************************************/
-/*****************************************************************************
-multiplyDPoly2D(trans1, trans2): Takes two 2-D polynomials as input and
-multiplies them.  Basically, for each non-zero coeff in the trans1 coeff[][]
-array, you must multiply by all non-zero coeffs in trans2.
- 
-XXX: Inefficient in that the out polynomial is allocated every time.
- *****************************************************************************/
-
-psDPolynomial2D *multiplyDPoly2D(psDPolynomial2D *trans1,
-                                 psDPolynomial2D *trans2)
-{
-    psS32 orderX = (trans1->nX + trans2->nX) - 1;
-    psS32 orderY = (trans1->nX + trans2->nX) - 1;
-
-    psDPolynomial2D *out = psDPolynomial2DAlloc(orderX, orderY, PS_POLYNOMIAL_ORD);
-    for (psS32 i = 0 ; i < out->nX; i++) {
-        for (psS32 j = 0 ; j < out->nY; j++) {
-            out->coeff[i][j] = 0.0;
-            out->mask[i][j] = 0;
-        }
-    }
-
-    for (psS32 t1x = 0 ; t1x < trans1->nX ; t1x++) {
-        for (psS32 t1y = 0 ; t1y < trans1->nY ; t1y++) {
-            if (0.0 != trans1->coeff[t1x][t1y]) {
-                for (psS32 t2x = 0 ; t2x < trans2->nX ; t2x++) {
-                    for (psS32 t2y = 0 ; t2y < trans2->nY ; t2y++) {
-                        out->coeff[t1x+t2x][t1y+t2y]+= (trans1->coeff[t1x][t1y] * trans2->coeff[t2x][t2y]);
-                    }
-                }
-            }
-        }
-    }
-    return(out);
-}
 
 /*****************************************************************************/
@@ -861,4 +826,47 @@
 }
 
+/*****************************************************************************
+multiplyDPoly2D(trans1, trans2): Takes two 2-D polynomials as input and
+multiplies them.  Basically, for each non-zero coeff in the trans1 coeff[][]
+array, you must multiply by all non-zero coeffs in trans2.
+ 
+XXX: Inefficient in that the out polynomial is allocated every time.
+ *****************************************************************************/
+
+psDPolynomial2D *multiplyDPoly2D(psDPolynomial2D *trans1,
+                                 psDPolynomial2D *trans2)
+{
+    //TRACE: printf("multiplyDPoly2D(%d %d: %d %d)\n", trans1->nX, trans1->nY, trans2->nX, trans2->nY);
+    psS32 orderX = (trans1->nX + trans2->nX) - 1;
+    psS32 orderY = (trans1->nY + trans2->nY) - 1;
+
+    psDPolynomial2D *out = psDPolynomial2DAlloc(orderX, orderY, PS_POLYNOMIAL_ORD);
+    //TRACE: printf("Creating poly (%d, %d)\n", orderX, orderY);
+    for (psS32 i = 0 ; i < out->nX; i++) {
+        for (psS32 j = 0 ; j < out->nY; j++) {
+            out->coeff[i][j] = 0.0;
+            out->mask[i][j] = 0;
+        }
+    }
+
+    for (psS32 t1x = 0 ; t1x < trans1->nX ; t1x++) {
+        for (psS32 t1y = 0 ; t1y < trans1->nY ; t1y++) {
+            if (0.0 != trans1->coeff[t1x][t1y]) {
+                for (psS32 t2x = 0 ; t2x < trans2->nX ; t2x++) {
+                    for (psS32 t2y = 0 ; t2y < trans2->nY ; t2y++) {
+                        /* VERIFY MACRO
+                        if ((t1x+t2x) >= orderX)
+                            printf("CRAP 1\n");
+                        if ((t1y+t2y) >= orderY)
+                            printf("CRAP 2\n");
+                        */
+                        out->coeff[t1x+t2x][t1y+t2y]+= (trans1->coeff[t1x][t1y] * trans2->coeff[t2x][t2y]);
+                    }
+                }
+            }
+        }
+    }
+    return(out);
+}
 
 
@@ -875,5 +883,5 @@
     PS_PTR_CHECK_NULL(trans1, NULL);
     PS_PTR_CHECK_NULL(trans2, NULL);
-
+    //TRACE: printf("psPlaneTransformCombine(%d, %d, %d, %d: %d, %d, %d, %d)\n", trans1->x->nX, trans1->x->nY, trans1->y->nX, trans1->y->nY, trans2->x->nX, trans2->x->nY, trans2->y->nX, trans2->y->nY);
     //
     // Determine the size of the new psPlaneTransform.
@@ -930,7 +938,9 @@
     // multiplied against themselves.  This can easily be improved.
     //
+
     for (psS32 t2x = 0 ; t2x < trans2->x->nX ; t2x++) {
         for (psS32 t2y = 0 ; t2y < trans2->x->nY ; t2y++) {
             psDPolynomial2D *currPoly = psDPolynomial2DAlloc(1, 1, PS_POLYNOMIAL_ORD);
+
             currPoly->coeff[0][0] = 1.0;
             currPoly->mask[0][0] = 0;
@@ -938,5 +948,4 @@
 
             if (trans2->x->mask[t2x][t2y] == 0) {
-
                 // Must raise trans1->y to the t2y-power.
                 for (psS32 c = 0 ; c < t2y; c++) {
@@ -965,5 +974,4 @@
 
 
-
     for (psS32 t2x = 0 ; t2x < trans2->y->nX ; t2x++) {
         for (psS32 t2y = 0 ; t2y < trans2->y->nY ; t2y++) {
@@ -1000,4 +1008,5 @@
     }
 
+    //TRACE: printf("Exiting combine()\n");
     return(myPT);
 }
