IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2077


Ignore:
Timestamp:
Oct 13, 2004, 9:40:42 AM (22 years ago)
Author:
gusciora
Message:

Modified the Set/Get offset functions.

Location:
trunk/psLib/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psCoord.c

    r2058 r2077  
    1010*  @author George Gusciora, MHPCC
    1111*
    12 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-10-12 20:53:02 $
     12*  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-10-13 19:40:42 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6161XXX: Verify this arc tan function.
    6262XXX: macro
     63XXX: I don't think this arg() is correct.
    6364 *****************************************************************************/
    6465
     
    6667              float y)
    6768{
    68     if (x > 0) {
    69         return (atan(y / x));
    70     } else if ((x == 0) && (y == 0)) {
    71         return (0.5 * M_PI);
    72     } else if ((x == 0) && (y == 0)) {
    73         return (-0.5 * M_PI);
    74     } else if ((x == 0) && (y == 0)) {
    75         return (M_PI + atan(y / x));
    76     } else if ((x == 0) && (y == 0)) {
    77         return (-M_PI + atan(y / x));
    78     }
    79 
    80     psAbort(__func__, "Unacceptable range for (p_psArg(%f, %f).\n", x, y);
     69    if (y!= 0.0) {
     70        return(atan(y/x));
     71    } else {
     72        return(0.5 * M_PI);
     73    }
    8174    return (0.0);
     75    /*
     76        if (x > 0) {
     77            return (atan(y / x));
     78        } else if ((x == 0) && (y == 0)) {
     79            return (0.5 * M_PI);
     80        } else if ((x == 0) && (y == 0)) {
     81            return (-0.5 * M_PI);
     82        } else if ((x == 0) && (y == 0)) {
     83            return (M_PI + atan(y / x));
     84        } else if ((x == 0) && (y == 0)) {
     85            return (-M_PI + atan(y / x));
     86        }
     87        psAbort(__func__, "Unacceptable range for (p_psArg(%f, %f).\n", x, y);
     88    */
    8289}
    8390
     
    9299        out = (psPlane* ) psAlloc(sizeof(psPlane));
    93100    }
    94     out->x = transform->x->coeff[0][0] +
    95              (transform->x->coeff[1][0] * coords->x) +
    96              (transform->x->coeff[0][1] * coords->y);
    97 
    98     out->y = transform->y->coeff[0][0] +
    99              (transform->y->coeff[1][0] * coords->x) +
    100              (transform->y->coeff[0][1] * coords->y);
    101 
     101    out->x = psDPolynomial2DEval(coords->x, coords->y, transform->x);
     102    out->y = psDPolynomial2DEval(coords->x, coords->y, transform->y);
    102103    return (out);
    103104}
     
    116117        out = (psPlane* ) psAlloc(sizeof(psPlane));
    117118    }
    118 
    119     out->x = transform->x->coeff[0][0][0][0] +
    120              (transform->x->coeff[1][0][0][0] * coords->x) +
    121              (transform->x->coeff[0][1][0][0] * coords->y) +
    122              (transform->x->coeff[0][0][1][0] * color) +
    123              (transform->x->coeff[0][0][0][1] * magnitude);
    124 
    125     out->y = transform->y->coeff[0][0][0][0] +
    126              (transform->y->coeff[1][0][0][0] * coords->x) +
    127              (transform->y->coeff[0][1][0][0] * coords->y) +
    128              (transform->y->coeff[0][0][1][0] * color) +
    129              (transform->y->coeff[0][0][0][1] * magnitude);
    130 
     119    out->x = psDPolynomial4DEval(coords->x, coords->y, color, magnitude, transform->x);
     120    out->y = psDPolynomial4DEval(coords->x, coords->y, color, magnitude, transform->y);
    131121    return (out);
    132122}
     
    196186    double xo = 0.0;
    197187
     188    psFree(tmTime);
    198189    return (psSphereTransformAlloc(phi, Xo, xo));
    199190}
     
    208199    double xo = 0.0;
    209200
     201    psFree(tmTime);
    210202    return (psSphereTransformAlloc(phi, Xo, xo));
    211203}
     
    251243
    252244    } else if (projection->type == PS_PROJ_AIT) {
    253         alpha = 1.0 / ((180.0 / M_PI) * sqrt(1.0 + (cos(coord->r) * cos(0.5 * coord->d) * 0.5)));
     245        alpha = 1.0 / ((180.0 / M_PI) * sqrt(1.0 + (cos(coord->r) *
     246                                             cos(0.5 * coord->d) * 0.5)));
    254247
    255248        tmp->x = 2.0 * alpha * cos(coord->r) * sin(0.5 * coord->d);
     
    325318 
    326319XXX: Do I need to somehow scale this projection?
     320 
     321XXX: Does PS_LINEAR mode make sense?  The result must be returned in psSphere
     322     regardless of the mode.
     323 
     324XXX: How to compound errors?
    327325 *****************************************************************************/
    328326psSphere* psSphereGetOffset(const psSphere* restrict position1,
     
    351349        return (tmp);
    352350    } else if (mode == PS_SPHERICAL) {
    353         tmpR = position2->r - position1->r;
    354         tmpD = position2->d - position1->d;
     351        tmp = (psSphere* ) psAlloc(sizeof(psSphere));
     352        tmp->r = position2->r - position1->r;
     353        tmp->d = position2->d - position1->d;
     354
     355        // XXX: Wrap these to an acceptable range.  This assumes that all
     356        // angles are in radians.
     357        tmp->r = fmod(tmp->r, 2*M_PI);
     358        tmp->d = fmod(tmp->d, 2*M_PI);
     359        tmp->rErr = 0.0;
     360        tmp->dErr = 0.0;
    355361
    356362        if (unit == PS_ARCSEC) {
    357             tmpR = (tmpR * 180.0 * 60.0 * 60.0) / M_PI;
    358             tmpD = (tmpR * 180.0 * 60.0 * 60.0) / M_PI;
     363            tmp->r = (tmp->r * 180.0 * 60.0 * 60.0) / M_PI;
     364            tmp->d = (tmp->d * 180.0 * 60.0 * 60.0) / M_PI;
    359365        } else if (unit == PS_ARCMIN) {
    360             tmpR = (tmpR * 180.0 * 60.0) / M_PI;
    361             tmpD = (tmpR * 180.0 * 60.0) / M_PI;
     366            tmp->r = (tmp->r * 180.0 * 60.0) / M_PI;
     367            tmp->d = (tmp->d * 180.0 * 60.0) / M_PI;
    362368        } else if (unit == PS_DEGREE) {
    363             tmpR = (tmpR * 180.0) / M_PI;
    364             tmpD = (tmpR * 180.0) / M_PI;
     369            tmp->r = (tmp->r * 180.0) / M_PI;
     370            tmp->d = (tmp->d * 180.0) / M_PI;
    365371        } else if (unit == PS_RADIAN) {}
    366372        else {
     
    368374        }
    369375
    370         tmp = (psSphere* ) psAlloc(sizeof(psSphere));
    371         // XXX: Wrap these to an acceptable range.  Is this correct?
    372         tmp->r = fmod(tmpR, 2*M_PI);
    373         tmp->d = fmod(tmpD, 2*M_PI);
    374         tmp->rErr = 0.0;
    375         tmp->dErr = 0.0;
    376 
    377376        return (tmp);
    378377    }
     
    388387 
    389388XXX: I copied the algorithm from the ADD exactly.
     389 
     390XXX: Should we compound errors?
    390391 *****************************************************************************/
    391392
     
    432433
    433434        tmp = (psSphere* ) psAlloc(sizeof(psSphere));
    434         // XXX: Is this an acceptable way to wrap the angular output?
    435435        tmp->r = position->r + tmpR;
    436436        tmp->r = fmod(tmp->r, 2.0*M_PI);
  • trunk/psLib/src/astronomy/psAstrometry.c

    r2067 r2077  
    88 *  @author George Gusciora, MHPCC
    99 *
    10  *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-10-13 00:10:50 $
     10 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-10-13 19:40:42 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    172172{
    173173    if (readout != NULL) {
     174        psFree(readout->image);
    174175        psFree(readout->mask);
    175176        psFree(readout->objects);
  • trunk/psLib/src/astronomy/psCoord.c

    r2058 r2077  
    1010*  @author George Gusciora, MHPCC
    1111*
    12 *  @version $Revision: 1.21 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2004-10-12 20:53:02 $
     12*  @version $Revision: 1.22 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2004-10-13 19:40:42 $
    1414*
    1515*  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    6161XXX: Verify this arc tan function.
    6262XXX: macro
     63XXX: I don't think this arg() is correct.
    6364 *****************************************************************************/
    6465
     
    6667              float y)
    6768{
    68     if (x > 0) {
    69         return (atan(y / x));
    70     } else if ((x == 0) && (y == 0)) {
    71         return (0.5 * M_PI);
    72     } else if ((x == 0) && (y == 0)) {
    73         return (-0.5 * M_PI);
    74     } else if ((x == 0) && (y == 0)) {
    75         return (M_PI + atan(y / x));
    76     } else if ((x == 0) && (y == 0)) {
    77         return (-M_PI + atan(y / x));
    78     }
    79 
    80     psAbort(__func__, "Unacceptable range for (p_psArg(%f, %f).\n", x, y);
     69    if (y!= 0.0) {
     70        return(atan(y/x));
     71    } else {
     72        return(0.5 * M_PI);
     73    }
    8174    return (0.0);
     75    /*
     76        if (x > 0) {
     77            return (atan(y / x));
     78        } else if ((x == 0) && (y == 0)) {
     79            return (0.5 * M_PI);
     80        } else if ((x == 0) && (y == 0)) {
     81            return (-0.5 * M_PI);
     82        } else if ((x == 0) && (y == 0)) {
     83            return (M_PI + atan(y / x));
     84        } else if ((x == 0) && (y == 0)) {
     85            return (-M_PI + atan(y / x));
     86        }
     87        psAbort(__func__, "Unacceptable range for (p_psArg(%f, %f).\n", x, y);
     88    */
    8289}
    8390
     
    9299        out = (psPlane* ) psAlloc(sizeof(psPlane));
    93100    }
    94     out->x = transform->x->coeff[0][0] +
    95              (transform->x->coeff[1][0] * coords->x) +
    96              (transform->x->coeff[0][1] * coords->y);
    97 
    98     out->y = transform->y->coeff[0][0] +
    99              (transform->y->coeff[1][0] * coords->x) +
    100              (transform->y->coeff[0][1] * coords->y);
    101 
     101    out->x = psDPolynomial2DEval(coords->x, coords->y, transform->x);
     102    out->y = psDPolynomial2DEval(coords->x, coords->y, transform->y);
    102103    return (out);
    103104}
     
    116117        out = (psPlane* ) psAlloc(sizeof(psPlane));
    117118    }
    118 
    119     out->x = transform->x->coeff[0][0][0][0] +
    120              (transform->x->coeff[1][0][0][0] * coords->x) +
    121              (transform->x->coeff[0][1][0][0] * coords->y) +
    122              (transform->x->coeff[0][0][1][0] * color) +
    123              (transform->x->coeff[0][0][0][1] * magnitude);
    124 
    125     out->y = transform->y->coeff[0][0][0][0] +
    126              (transform->y->coeff[1][0][0][0] * coords->x) +
    127              (transform->y->coeff[0][1][0][0] * coords->y) +
    128              (transform->y->coeff[0][0][1][0] * color) +
    129              (transform->y->coeff[0][0][0][1] * magnitude);
    130 
     119    out->x = psDPolynomial4DEval(coords->x, coords->y, color, magnitude, transform->x);
     120    out->y = psDPolynomial4DEval(coords->x, coords->y, color, magnitude, transform->y);
    131121    return (out);
    132122}
     
    196186    double xo = 0.0;
    197187
     188    psFree(tmTime);
    198189    return (psSphereTransformAlloc(phi, Xo, xo));
    199190}
     
    208199    double xo = 0.0;
    209200
     201    psFree(tmTime);
    210202    return (psSphereTransformAlloc(phi, Xo, xo));
    211203}
     
    251243
    252244    } else if (projection->type == PS_PROJ_AIT) {
    253         alpha = 1.0 / ((180.0 / M_PI) * sqrt(1.0 + (cos(coord->r) * cos(0.5 * coord->d) * 0.5)));
     245        alpha = 1.0 / ((180.0 / M_PI) * sqrt(1.0 + (cos(coord->r) *
     246                                             cos(0.5 * coord->d) * 0.5)));
    254247
    255248        tmp->x = 2.0 * alpha * cos(coord->r) * sin(0.5 * coord->d);
     
    325318 
    326319XXX: Do I need to somehow scale this projection?
     320 
     321XXX: Does PS_LINEAR mode make sense?  The result must be returned in psSphere
     322     regardless of the mode.
     323 
     324XXX: How to compound errors?
    327325 *****************************************************************************/
    328326psSphere* psSphereGetOffset(const psSphere* restrict position1,
     
    351349        return (tmp);
    352350    } else if (mode == PS_SPHERICAL) {
    353         tmpR = position2->r - position1->r;
    354         tmpD = position2->d - position1->d;
     351        tmp = (psSphere* ) psAlloc(sizeof(psSphere));
     352        tmp->r = position2->r - position1->r;
     353        tmp->d = position2->d - position1->d;
     354
     355        // XXX: Wrap these to an acceptable range.  This assumes that all
     356        // angles are in radians.
     357        tmp->r = fmod(tmp->r, 2*M_PI);
     358        tmp->d = fmod(tmp->d, 2*M_PI);
     359        tmp->rErr = 0.0;
     360        tmp->dErr = 0.0;
    355361
    356362        if (unit == PS_ARCSEC) {
    357             tmpR = (tmpR * 180.0 * 60.0 * 60.0) / M_PI;
    358             tmpD = (tmpR * 180.0 * 60.0 * 60.0) / M_PI;
     363            tmp->r = (tmp->r * 180.0 * 60.0 * 60.0) / M_PI;
     364            tmp->d = (tmp->d * 180.0 * 60.0 * 60.0) / M_PI;
    359365        } else if (unit == PS_ARCMIN) {
    360             tmpR = (tmpR * 180.0 * 60.0) / M_PI;
    361             tmpD = (tmpR * 180.0 * 60.0) / M_PI;
     366            tmp->r = (tmp->r * 180.0 * 60.0) / M_PI;
     367            tmp->d = (tmp->d * 180.0 * 60.0) / M_PI;
    362368        } else if (unit == PS_DEGREE) {
    363             tmpR = (tmpR * 180.0) / M_PI;
    364             tmpD = (tmpR * 180.0) / M_PI;
     369            tmp->r = (tmp->r * 180.0) / M_PI;
     370            tmp->d = (tmp->d * 180.0) / M_PI;
    365371        } else if (unit == PS_RADIAN) {}
    366372        else {
     
    368374        }
    369375
    370         tmp = (psSphere* ) psAlloc(sizeof(psSphere));
    371         // XXX: Wrap these to an acceptable range.  Is this correct?
    372         tmp->r = fmod(tmpR, 2*M_PI);
    373         tmp->d = fmod(tmpD, 2*M_PI);
    374         tmp->rErr = 0.0;
    375         tmp->dErr = 0.0;
    376 
    377376        return (tmp);
    378377    }
     
    388387 
    389388XXX: I copied the algorithm from the ADD exactly.
     389 
     390XXX: Should we compound errors?
    390391 *****************************************************************************/
    391392
     
    432433
    433434        tmp = (psSphere* ) psAlloc(sizeof(psSphere));
    434         // XXX: Is this an acceptable way to wrap the angular output?
    435435        tmp->r = position->r + tmpR;
    436436        tmp->r = fmod(tmp->r, 2.0*M_PI);
Note: See TracChangeset for help on using the changeset viewer.