Index: /branches/eam_branches/ipp-20101205/Ohana/src/libohana/include/ohana.h
===================================================================
--- /branches/eam_branches/ipp-20101205/Ohana/src/libohana/include/ohana.h	(revision 30514)
+++ /branches/eam_branches/ipp-20101205/Ohana/src/libohana/include/ohana.h	(revision 30515)
@@ -283,4 +283,5 @@
 int     ohana_str_to_radec     PROTO((double *ra, double *dec, char *str1, char *str2));
 double  ohana_normalize_angle  PROTO((double angle));
+double  ohana_normalize_angle_to_midpoint  PROTO((double angle, double Rmid));
 
 int     hstgsc_hms_to_deg      PROTO((double *h0, double *h1, double *d0, double *d1, char *string));
Index: /branches/eam_branches/ipp-20101205/Ohana/src/libohana/src/time.c
===================================================================
--- /branches/eam_branches/ipp-20101205/Ohana/src/libohana/src/time.c	(revision 30514)
+++ /branches/eam_branches/ipp-20101205/Ohana/src/libohana/src/time.c	(revision 30515)
@@ -469,4 +469,39 @@
 }
 
+double ohana_normalize_angle_to_midpoint (double angle, double Rmid) {
+
+    double result;
+
+    // take an input angle and force the domain to be 0.0 - 360.0
+    // there are a few ways to do this:  
+
+    // option 1: This is a potentially very slow method, also subject to round off errors
+# if (0)
+    while (angle > 360.0) angle -= 360.0;
+    while (angle <   0.0) angle += 360.0;
+# endif
+    
+    // option 2: take sin & cos, apply atan2 (y, x) 
+# if (1)    
+    double x, y;
+
+    x = cos(angle*RAD_DEG);
+    y = sin(angle*RAD_DEG);
+
+    result = DEG_RAD*atan2 (y, x);
+    if (result < Rmid - 180.0) result += 360.0;
+    if (result > Rmid + 180.0) result -= 360.0;
+# endif
+
+# if (0)
+    // option 3:
+    int nCircle = angle / 360.0;
+    result -= 360.0*nCircle;
+    if (result < 0.0) result += 360.0;
+# endif
+
+    return (result);
+}
+
 short ToShortPixels (float pixels) {
 
