IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34515


Ignore:
Timestamp:
Oct 5, 2012, 1:03:36 PM (14 years ago)
Author:
eugene
Message:

fix posangle calculation (rationalize at boundary)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmSourceOutputs.c

    r34499 r34515  
    227227    *pltScale = 0.5*(pltScale_x + pltScale_y);
    228228
     229    float posAngle_x, posAngle_y;
    229230    float crossProduct = dTPx_dCHx * dTPy_dCHy - dTPx_dCHy * dTPy_dCHx;
    230231    if  (crossProduct > 0.) {
    231232      *pltScale *= -1.0;
    232     }
    233 
    234     float posAngle_x = atan2 (+dTPy_dCHx, +dTPx_dCHx);
    235     float posAngle_y = atan2 (-dTPx_dCHy, +dTPy_dCHy);
     233      posAngle_x = atan2 (dTPy_dCHx, dTPx_dCHx);
     234      posAngle_y = atan2 (dTPy_dCHy, dTPx_dCHy) - M_PI_2;
     235    } else {
     236      posAngle_x = atan2 (dTPy_dCHx, -dTPx_dCHx);
     237      posAngle_y = atan2 (dTPy_dCHy,  dTPx_dCHy) - M_PI_2;
     238    }
     239
     240    // with errors, these may end up on opposite sides of the M_PI boundary. 
     241    if (posAngle_x - posAngle_y > M_PI) {
     242      posAngle_y += 2.0 * M_PI;
     243    }
     244    if (posAngle_y - posAngle_x > M_PI) {
     245      posAngle_x += 2.0 * M_PI;
     246    }
    236247    *posAngle = 0.5*(posAngle_x + posAngle_y);
    237248
Note: See TracChangeset for help on using the changeset viewer.