IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 21, 2005, 5:33:37 PM (21 years ago)
Author:
eugene
Message:

reorg

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/psLibUtils.c

    r5562 r5565  
    171171    return(out);
    172172}
     173
     174// returns the rotation term, forcing positive parity
     175double psPlaneTransformGetRotation (psPlaneTransform *map) {
     176
     177    if (map->x->nX < 1) return 0;
     178    if (map->x->nY < 1) return 0;
     179
     180    if (map->y->nX < 1) return 0;
     181    if (map->y->nY < 1) return 0;
     182   
     183    double pc1_1 = map->x->coeff[1][0];
     184    double pc1_2 = map->x->coeff[0][1];
     185    double pc2_1 = map->y->coeff[1][0];
     186    double pc2_2 = map->y->coeff[0][1];
     187
     188    double px = SIGN (pc1_1);
     189    double py = SIGN (pc2_2);
     190
     191    // both x and y terms imply an angle. take the average
     192    double t1 = -atan2 (px*pc1_2, px*pc1_1);
     193    double t2 = +atan2 (py*pc2_1, py*pc2_2);
     194   
     195    // careful near -pi,+pi boundary...
     196    if (t1 - t2 > M_PI/2) t2 += 2*M_PI;
     197    if (t2 - t1 > M_PI/2) t1 += 2*M_PI;
     198
     199    double theta = 0.5*(t1 + t2);
     200    while (theta < M_PI) theta += 2*M_PI;
     201    while (theta > M_PI) theta -= 2*M_PI;
     202   
     203    return (theta);
     204}
Note: See TracChangeset for help on using the changeset viewer.