Index: trunk/Ohana/src/opihi/cmd.astro/cplot.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/cplot.c	(revision 18718)
+++ trunk/Ohana/src/opihi/cmd.astro/cplot.c	(revision 19823)
@@ -41,4 +41,5 @@
   Npts = 0;
   for (i = 0; i < Xvec.Nelements; i++, r++, d++) {
+      *r = ohana_normalize_angle (*r);
     while (*r < Rmin) *r += 360.0;
     while (*r > Rmax) *r -= 360.0;
Index: trunk/Ohana/src/opihi/cmd.astro/czplot.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/czplot.c	(revision 18718)
+++ trunk/Ohana/src/opihi/cmd.astro/czplot.c	(revision 19823)
@@ -49,6 +49,5 @@
   for (i = 0; i < Zvec.Nelements; i++, in++, out++, r++, d++, x++, y++) {
     *out = MIN (1.0, MAX (0.01, (*in - min) / range));
-    while (*r < Rmin) *r += 360.0;
-    while (*r > Rmax) *r -= 360.0;
+    *r = ohana_normalize_angle (*r);
     fRD_to_XY (x, y, *r, *d, &graphmode.coords);
   }
Index: trunk/Ohana/src/opihi/cmd.astro/drizzle.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/drizzle.c	(revision 18718)
+++ trunk/Ohana/src/opihi/cmd.astro/drizzle.c	(revision 19823)
@@ -221,6 +221,5 @@
   *phi   = DEG_RAD*atan2(y,x) + rot_phi;
   
-  while (*phi <   0.0) *phi += 360.0;
-  while (*phi > 360.0) *phi -= 360.0;
+  *phi = ohana_normalize_angle(*phi);
   return (TRUE);
 }
Index: trunk/Ohana/src/opihi/cmd.astro/getvel.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/getvel.c	(revision 18718)
+++ trunk/Ohana/src/opihi/cmd.astro/getvel.c	(revision 19823)
@@ -43,6 +43,5 @@
   dV *= 0.001;
 
-  while (L >= 360) {L -= 360.0;}
-  while (L < 0.0)  {L += 360.0;}
+  L = ohana_normalize_angle (L);
   gprint (GP_ERR, "L: %f\n", L);
 
Index: trunk/Ohana/src/opihi/cmd.astro/polar.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/polar.c	(revision 18718)
+++ trunk/Ohana/src/opihi/cmd.astro/polar.c	(revision 19823)
@@ -55,7 +55,5 @@
       y = (j - Yo) * dN + No;
       r = hypot(x, y);
-      t = DEG_RAD*atan2 (y, x);
-      while (t < 360.0) {t += 360.0;}
-      while (t > 360.0) {t -= 360.0;}
+      t = ohana_normalize_angle(DEG_RAD*atan2 (y, x));
       X = (t - Lo) / dL + xo;
       Y = (r - Do) / dD + yo;
Index: trunk/Ohana/src/opihi/cmd.astro/rotcurve.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.astro/rotcurve.c	(revision 18718)
+++ trunk/Ohana/src/opihi/cmd.astro/rotcurve.c	(revision 19823)
@@ -70,6 +70,6 @@
   gfits_scan (&out[0].header, "CRPIX2", "%lf", 1, &Yo);
 
-  while (L >= 360) {L -= 360.0;}
-  while (L < 0.0)  {L += 360.0;}
+  L = ohana_normalize_angle (L);
+
   X = (L - Lo) / dL + Xo;
   if ((X >= Nx) || (X < 0)) {
