IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30515


Ignore:
Timestamp:
Feb 8, 2011, 8:43:38 AM (15 years ago)
Author:
eugene
Message:

create ohana_normalize_angle_to_midpoint

Location:
branches/eam_branches/ipp-20101205/Ohana/src/libohana
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/Ohana/src/libohana/include/ohana.h

    r30480 r30515  
    283283int     ohana_str_to_radec     PROTO((double *ra, double *dec, char *str1, char *str2));
    284284double  ohana_normalize_angle  PROTO((double angle));
     285double  ohana_normalize_angle_to_midpoint  PROTO((double angle, double Rmid));
    285286
    286287int     hstgsc_hms_to_deg      PROTO((double *h0, double *h1, double *d0, double *d1, char *string));
  • branches/eam_branches/ipp-20101205/Ohana/src/libohana/src/time.c

    r30480 r30515  
    469469}
    470470
     471double ohana_normalize_angle_to_midpoint (double angle, double Rmid) {
     472
     473    double result;
     474
     475    // take an input angle and force the domain to be 0.0 - 360.0
     476    // there are a few ways to do this: 
     477
     478    // option 1: This is a potentially very slow method, also subject to round off errors
     479# if (0)
     480    while (angle > 360.0) angle -= 360.0;
     481    while (angle <   0.0) angle += 360.0;
     482# endif
     483   
     484    // option 2: take sin & cos, apply atan2 (y, x)
     485# if (1)   
     486    double x, y;
     487
     488    x = cos(angle*RAD_DEG);
     489    y = sin(angle*RAD_DEG);
     490
     491    result = DEG_RAD*atan2 (y, x);
     492    if (result < Rmid - 180.0) result += 360.0;
     493    if (result > Rmid + 180.0) result -= 360.0;
     494# endif
     495
     496# if (0)
     497    // option 3:
     498    int nCircle = angle / 360.0;
     499    result -= 360.0*nCircle;
     500    if (result < 0.0) result += 360.0;
     501# endif
     502
     503    return (result);
     504}
     505
    471506short ToShortPixels (float pixels) {
    472507
Note: See TracChangeset for help on using the changeset viewer.