IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 2, 2008, 8:08:31 AM (18 years ago)
Author:
eugene
Message:

replace poor code with ohana_normalize_angle

Location:
trunk/Ohana/src/opihi
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.astro/cplot.c

    r14066 r19823  
    4141  Npts = 0;
    4242  for (i = 0; i < Xvec.Nelements; i++, r++, d++) {
     43      *r = ohana_normalize_angle (*r);
    4344    while (*r < Rmin) *r += 360.0;
    4445    while (*r > Rmax) *r -= 360.0;
  • trunk/Ohana/src/opihi/cmd.astro/czplot.c

    r13479 r19823  
    4949  for (i = 0; i < Zvec.Nelements; i++, in++, out++, r++, d++, x++, y++) {
    5050    *out = MIN (1.0, MAX (0.01, (*in - min) / range));
    51     while (*r < Rmin) *r += 360.0;
    52     while (*r > Rmax) *r -= 360.0;
     51    *r = ohana_normalize_angle (*r);
    5352    fRD_to_XY (x, y, *r, *d, &graphmode.coords);
    5453  }
  • trunk/Ohana/src/opihi/cmd.astro/drizzle.c

    r8427 r19823  
    221221  *phi   = DEG_RAD*atan2(y,x) + rot_phi;
    222222 
    223   while (*phi <   0.0) *phi += 360.0;
    224   while (*phi > 360.0) *phi -= 360.0;
     223  *phi = ohana_normalize_angle(*phi);
    225224  return (TRUE);
    226225}
  • trunk/Ohana/src/opihi/cmd.astro/getvel.c

    r7917 r19823  
    4343  dV *= 0.001;
    4444
    45   while (L >= 360) {L -= 360.0;}
    46   while (L < 0.0)  {L += 360.0;}
     45  L = ohana_normalize_angle (L);
    4746  gprint (GP_ERR, "L: %f\n", L);
    4847
  • trunk/Ohana/src/opihi/cmd.astro/polar.c

    r7917 r19823  
    5555      y = (j - Yo) * dN + No;
    5656      r = hypot(x, y);
    57       t = DEG_RAD*atan2 (y, x);
    58       while (t < 360.0) {t += 360.0;}
    59       while (t > 360.0) {t -= 360.0;}
     57      t = ohana_normalize_angle(DEG_RAD*atan2 (y, x));
    6058      X = (t - Lo) / dL + xo;
    6159      Y = (r - Do) / dD + yo;
  • trunk/Ohana/src/opihi/cmd.astro/rotcurve.c

    r7917 r19823  
    7070  gfits_scan (&out[0].header, "CRPIX2", "%lf", 1, &Yo);
    7171
    72   while (L >= 360) {L -= 360.0;}
    73   while (L < 0.0)  {L += 360.0;}
     72  L = ohana_normalize_angle (L);
     73
    7474  X = (L - Lo) / dL + Xo;
    7575  if ((X >= Nx) || (X < 0)) {
  • trunk/Ohana/src/opihi/dimm/telescope.c

    r7917 r19823  
    6363    }
    6464
    65     ra  = atof (argv[2]);
     65    ra  = ohana_normalize_angle(atof (argv[2]));
    6666    dec = atof (argv[3]);
    67     while (ra  < 360.0) ra += 360.0;   
    68     while (ra  > 360.0) ra -= 360.0;   
    6967
    7068    status = gotoRD (ra, dec);
  • trunk/Ohana/src/opihi/dvo/ImageOps.c

    r18375 r19823  
    6565        if ((j == 0) && (r < Rmin)) flipped = TRUE;
    6666        if ((j == 0) && (r > Rmax)) flipped = TRUE;
     67        r = ohana_normalize_angle (r);
    6768        while (flipped && (r < Rmid)) r+= 360.0;
    6869        while (flipped && (r > Rmid)) r-= 360.0;
  • trunk/Ohana/src/opihi/dvo/aregion.c

    r7917 r19823  
    99  int i, NBigDec, NLINES, done;
    1010 
    11   while (ra < 0) { ra += 360.0; }
    12   while (ra >= 360.0) { ra -= 360.0; }
     11  ra = ohana_normalize_angle (ra);
    1312
    1413  if (dec >= 86.25) {
  • trunk/Ohana/src/opihi/dvo/catalog.c

    r13479 r19823  
    344344        if (LimExclude && (Zvec.elements[N] > 0.99)) continue;
    345345        if (Zvec.elements[N] < 0.011) continue;
     346        catalog.average[i].R = ohana_normalize_angle (catalog.average[i].R);
    346347        while (catalog.average[i].R < Rmin) catalog.average[i].R += 360.0;
    347348        while (catalog.average[i].R > Rmax) catalog.average[i].R -= 360.0;
     
    359360        if (Zvec.elements[N] == 0.01)
    360361          continue;
     362        catalog.average[i].R = ohana_normalize_angle (catalog.average[i].R);
    361363        while (catalog.average[i].R < Rmin) catalog.average[i].R += 360.0;
    362364        while (catalog.average[i].R > Rmax) catalog.average[i].R -= 360.0;
     
    374376        if (Zvec.elements[N] == 0.01)
    375377          continue;
     378        catalog.average[i].R = ohana_normalize_angle (catalog.average[i].R);
    376379        while (catalog.average[i].R < Rmin) catalog.average[i].R += 360.0;
    377380        while (catalog.average[i].R > Rmax) catalog.average[i].R -= 360.0;
  • trunk/Ohana/src/opihi/dvo/find_regions.c

    r7917 r19823  
    2727  nregion = 0;
    2828
    29   while (Ra < 0) Ra += 360.0;
    30   while (Ra >= 360) Ra -= 360.0;
     29  Ra = ohana_normalize_angle (Ra);
    3130
    3231  minDec = Dec - radius;
  • trunk/Ohana/src/opihi/dvo/gstar.c

    r19534 r19823  
    7575  Radius = atof (argv[3]);
    7676
    77   while (Ra < 0.0) Ra += 360.0;
    78   while (Ra > 360.0) Ra -= 360.0;
     77  Ra = ohana_normalize_angle (Ra);
    7978 
    8079  /* load sky from correct table */
  • trunk/Ohana/src/opihi/dvo/images.c

    r15999 r19823  
    179179      status = XY_to_RD (&r[j], &d[j], x[j], y[j], &image[i].coords);
    180180      if (!status) break;
     181      r[j] = ohana_normalize_angle (r[j]);
    181182      while (r[j] < Rmin) { r[j] += 360.0; }
    182183      while (r[j] > Rmax) { r[j] -= 360.0; }
     
    216217          status = XY_to_RD (&r[j], &d[j], x[jp], y[jp], &image[i].coords);
    217218          if (!status) continue;
     219          r[j] = ohana_normalize_angle (r[j]);
    218220          while (r[j] < Rmin) { r[j] += 360.0; }
    219221          while (r[j] > Rmax) { r[j] -= 360.0; }
  • trunk/Ohana/src/opihi/dvo/imbox.c

    r19130 r19823  
    7070    for (j = 0; j < 4; j++) {
    7171      XY_to_RD (&r, &d, x[j], y[j], &coords);
     72      r = ohana_normalize_angle (r);
    7273      while ((j == 0) && (r < Rmin)) { flipped = TRUE; r += 360.0; }
    7374      while ((j == 0) && (r > Rmax)) { flipped = TRUE; r -= 360.0; }
  • trunk/Ohana/src/opihi/dvo/imdense.c

    r13479 r19823  
    4242    if (!FindMosaicForImage (image, Nimage, i)) continue;
    4343    XY_to_RD (&r, &d, x, y, &image[i].coords);
     44    r = ohana_normalize_angle (r);
    4445    while (r < Rmin) r += 360.0;
    4546    while (r > Rmax) r -= 360.0;
  • trunk/Ohana/src/opihi/dvo/paverage.c

    r13479 r19823  
    117117    for (i = 0; i < catalog.Naverage; i++) {
    118118      if (IDclip && (average[i].code != IDchoice)) continue;
     119      average[i].R = ohana_normalize_angle (average[i].R);
    119120      while (average[i].R < Rmin) average[i].R += 360.0;
    120121      while (average[i].R > Rmax) average[i].R -= 360.0;
  • trunk/Ohana/src/opihi/dvo/pmeasure.c

    r16856 r19823  
    187187    for (i = 0; i < catalog.Naverage; i++) {
    188188      if (IDclip && (catalog.average[i].code != IDchoice)) continue;
     189      catalog.average[i].R = ohana_normalize_angle (catalog.average[i].R);
    189190      while (catalog.average[i].R < Rmin) catalog.average[i].R += 360.0;
    190191      while (catalog.average[i].R > Rmax) catalog.average[i].R -= 360.0;
  • trunk/Ohana/src/opihi/dvo/procks.c

    r13479 r19823  
    103103    if (SpeedClip && ((rocks[i].Y[0] < S0) || (rocks[i].Y[0] > S1))) continue;
    104104    for (j = 0; j < 3; j++) {
     105      rocks[i].ra[j]= ohana_normalize_angle (rocks[i].ra[j]);   
    105106      while (rocks[i].ra[j] < Rmin) rocks[i].ra[j] += 360.0;
    106107      while (rocks[i].ra[j] > Rmax) rocks[i].ra[j] -= 360.0;
     
    129130      if (rocks[i].t[j] > t1) { N1 = j; t1 = rocks[i].t[j]; }
    130131    }
     132    rocks[i].ra[N0]= ohana_normalize_angle (rocks[i].ra[N0]);   
     133    rocks[i].ra[N1]= ohana_normalize_angle (rocks[i].ra[N1]);   
    131134    while (rocks[i].ra[N0] < Rmin) rocks[i].ra[N0] += 360.0;
    132135    while (rocks[i].ra[N0] > Rmax) rocks[i].ra[N0] -= 360.0;
  • trunk/Ohana/src/opihi/dvo/skycat.c

    r13479 r19823  
    110110int RD_to_XYpic (double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside) {
    111111
    112   while (r < Rmin) { r += 360.0; }
    113   while (r > Rmax) { r -= 360.0; }
     112  r = ohana_normalize_angle (r);
    114113
    115114  if (*leftside == -1) {
  • trunk/Ohana/src/opihi/dvo/skycoverage.c

    r14590 r19823  
    128128      for (Xi = x[0] + 0.5*dPix; Xi < x[1]; Xi += dPix) {
    129129        XY_to_RD (&r, &d, Xi, Yi, &image[i].coords);
    130         while (r <   0.0) { r += 360.0; }
    131         while (r > 360.0) { r -= 360.0; }
     130        r = ohana_normalize_angle (r);
    132131        status = RD_to_XY (&Xs, &Ys, r, d, &coords);
    133132        if (status) {
  • trunk/Ohana/src/opihi/dvo/subpix.c

    r16810 r19823  
    2727  }
    2828  if (!ohana_str_to_radec (&Ra, &Dec, argv[1], argv[2])) return (FALSE);
    29   if (Ra < 0) Ra += 360.0;
    30   if (Ra > 360.0) Ra -= 360.0;
     29  Ra = ohana_normalize_angle (Ra);
     30
    3131  Radius = atof (argv[3]);
    3232
Note: See TracChangeset for help on using the changeset viewer.