Index: trunk/psLib/src/image/psImageManip.c
===================================================================
--- trunk/psLib/src/image/psImageManip.c	(revision 1263)
+++ trunk/psLib/src/image/psImageManip.c	(revision 1292)
@@ -10,6 +10,6 @@
  *  @author Ross Harman, MHPCC
  *
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2004-07-22 20:42:22 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2004-07-24 02:00:21 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -25,6 +25,4 @@
 #include "psMemory.h"
 #include "psImageExtraction.h"
-
-bool getSpecifiedStatValue(const psStats* stats, double* value);
 
 int psImageClip(psImage* input, psF64 min, psF64 vmin, psF64 max, psF64 vmax)
@@ -337,58 +335,4 @@
 }
 
-bool getSpecifiedStatValue(const psStats* stats, double* value)
-{
-
-    switch (stats->options &
-            ~ (PS_STAT_USE_RANGE | PS_STAT_USE_BINSIZE | PS_STAT_ROBUST_FOR_SAMPLE)) {
-    case PS_STAT_SAMPLE_MEAN:
-        *value = stats->sampleMean;
-        return true;
-
-    case PS_STAT_SAMPLE_MEDIAN:
-        *value = stats->sampleMedian;
-        return true;
-
-    case PS_STAT_SAMPLE_STDEV:
-        *value = stats->sampleStdev;
-        return true;
-
-    case PS_STAT_ROBUST_MEAN:
-        *value = stats->robustMean;
-        return true;
-
-    case PS_STAT_ROBUST_MEDIAN:
-        *value = stats->robustMedian;
-        return true;
-
-    case PS_STAT_ROBUST_MODE:
-        *value = stats->robustMode;
-        return true;
-
-    case PS_STAT_ROBUST_STDEV:
-        *value = stats->robustStdev;
-        return true;
-
-    case PS_STAT_CLIPPED_MEAN:
-        *value = stats->clippedMean;
-        return true;
-
-    case PS_STAT_CLIPPED_STDEV:
-        *value = stats->clippedStdev;
-        return true;
-
-    case PS_STAT_MAX:
-        *value = stats->max;
-        return true;
-
-    case PS_STAT_MIN:
-        *value = stats->min;
-        return true;
-
-    default:
-        return false;
-    }
-}
-
 
 psImage* psImageRebin(psImage* out,const psImage* in,unsigned int scale,const psStats* stats)
@@ -420,5 +364,5 @@
     }
 
-    if (getSpecifiedStatValue(stats,&statVal) == false) {
+    if (p_psGetStatValue(stats,&statVal) == false) {
         psError(__func__,"The stat options didn't specify a single supported statistic type.");
         psFree(out);
@@ -457,5 +401,5 @@
                 vec->n = n; \
                 myStats = psVectorStats(myStats,vec,NULL,0); \
-                getSpecifiedStatValue(myStats,&statVal); \
+                p_psGetStatValue(myStats,&statVal); \
                 outRowData[col] = (ps##type)statVal; \
             } \
@@ -723,6 +667,4 @@
         float cosT = cosf(t);
         float sinT = sinf(t);
-        float cosNegT = cosf(-t);
-        float sinNegT = sinf(-t);
 
         // calculate the corners of the rotated image so we know the proper output image size.
@@ -730,43 +672,9 @@
         //    y' = y cos(t) - x sin(t);  i.e. y' = (y-centerY)*cosT - (x-centerX)*sinT;
 
-        #define rotateProjectX(x,y) (x-centerX)*cosNegT + (y-centerY)*sinNegT
-        #define rotateProjectY(x,y) (y-centerY)*cosNegT - (x-centerX)*sinNegT
-
-        // bottom-left, i.e., (0,0)
-        float xbl = rotateProjectX(0,0);
-        float ybl = rotateProjectY(0,0);
-        // bottom-right, i.e., (numCols,0)
-        float xbr = rotateProjectX(numCols,0);
-        float ybr = rotateProjectY(numCols,0);
-        // top-left, i.e., (0,numRows)
-        float xtl = rotateProjectX(0,numRows);
-        float ytl = rotateProjectY(0,numRows);
-        // top-right, i.e., (numCols,numRows)
-        float xtr = rotateProjectX(numCols,numRows);
-        float ytr = rotateProjectY(numCols,numRows);
-
-        float minX = xbl;
-        minX = (minX > xbr) ? xbr : minX;
-        minX = (minX > xtl) ? xtl : minX;
-        minX = (minX > xtr) ? xtr : minX;
-
-        float minY = ybl;
-        minY = (minY > ybr) ? ybr : minY;
-        minY = (minY > ytl) ? ytl : minY;
-        minY = (minY > ytr) ? ytr : minY;
-
-        float maxX = xbl;
-        maxX = (maxX < xbr) ? xbr : maxX;
-        maxX = (maxX < xtl) ? xtl : maxX;
-        maxX = (maxX < xtr) ? xtr : maxX;
-
-        float maxY = ybl;
-        maxY = (maxY < ybr) ? ybr : maxY;
-        maxY = (maxY < ytl) ? ytl : maxY;
-        maxY = (maxY < ytr) ? ytr : maxY;
-
-        int intMinY = minY;
-        int outRows = ceil(maxY-minY)+1;
-        int outCols = ceil(maxX-minX)+1;
+
+        int outCols = ceil(abs(numCols*cosT)+abs(numRows*sinT))+1;
+        int outRows = ceil(abs(numCols*sinT)+abs(numRows*cosT))+1;
+        float minX = (float)outCols/-2.0f;
+        int intMinY = outRows/-2;
 
         out = psImageRecycle(out,outCols,outRows,type);
