IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4613


Ignore:
Timestamp:
Jul 26, 2005, 2:36:01 PM (21 years ago)
Author:
drobbin
Message:

Added psCube and psCube fxns to psCoord

Location:
trunk/psLib/src/astro
Files:
2 edited

Legend:

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

    r4581 r4613  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.80 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-07-20 01:21:13 $
     12*  @version $Revision: 1.81 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-07-27 00:36:01 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    212212    psMemSetDeallocator(s, (psFreeFunc) sphereFree);
    213213    return(s);
     214}
     215
     216static void cubeFree(psCube *c)
     217{
     218    // There are non dynamic allocated items
     219}
     220
     221psCube* psCubeAlloc(void)
     222{
     223    psCube *c = psAlloc(sizeof(psCube));
     224
     225    psMemSetDeallocator(c, (psFreeFunc) cubeFree);
     226    return(c);
    214227}
    215228
     
    12561269    return(NULL);
    12571270}
     1271
     1272psCube *psSphereToCube(const psSphere *sphere)
     1273{
     1274    if(sphere == NULL) {
     1275        //        psError();
     1276        return NULL;
     1277    }
     1278
     1279    psCube *cube = NULL;
     1280
     1281    cube = psCubeAlloc();
     1282    cube->x = cos(sphere->d) * cos(sphere->r);
     1283    cube->y = cos(sphere->d) * sin(sphere->r);
     1284    cube->z = sin(sphere->d);
     1285    cube->xErr = cos(sphere->dErr) * cos(sphere->rErr);
     1286    cube->yErr = cos(sphere->dErr) * sin(sphere->rErr);
     1287    cube->zErr = sin(sphere->dErr);
     1288
     1289    return(cube);
     1290}
     1291
     1292psSphere *psCubeToSphere(const psCube *cube)
     1293{
     1294    if(cube == NULL) {
     1295        //        psError();
     1296        return NULL;
     1297    }
     1298
     1299    psSphere *sphere = NULL;
     1300    sphere = psSphereAlloc();
     1301    //    sphere->r = arctan(cube->x/cube->y);
     1302    //    sphere->d = arctan(sqrt(cube->x*cube->x + cube->y*cube->y)/cube->z);
     1303    //    sphere->rErr = arctan(cube->xErr/cube->yErr);
     1304    //    sphere->dErr = arctan(sqrt(cube->xErr*cube->xErr + cube->yErr*cube->yErr)/cube->zErr);
     1305    sphere->r = 1 / (atan(cube->x/cube->y));
     1306    sphere->d = 1 / (atan(sqrt(cube->x*cube->x + cube->y*cube->y)/cube->z));
     1307    sphere->rErr = 1 / (atan(cube->xErr/cube->yErr));
     1308    sphere->dErr = 1 / (atan(sqrt(cube->xErr*cube->xErr + cube->yErr*cube->yErr)/cube->zErr));
     1309
     1310    return(sphere);
     1311}
  • trunk/psLib/src/astro/psCoord.h

    r4581 r4613  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-07-20 01:21:13 $
     12*  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-07-27 00:36:01 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    3838typedef struct
    3939{
    40     double x;                   ///< x position
    41     double y;                   ///< y position
    42     double xErr;                ///< Error in x position
    43     double yErr;                ///< Error in y position
     40    double x;                          ///< x position
     41    double y;                          ///< y position
     42    double xErr;                       ///< Error in x position
     43    double yErr;                       ///< Error in y position
    4444}
    4545psPlane;
     
    5454typedef struct psSphere
    5555{
    56     double r;                   ///< RA
    57     double d;                   ///< Dec
    58     double rErr;                ///< Error in RA
    59     double dErr;                ///< Error in Dec
     56    double r;                          ///< RA
     57    double d;                          ///< Dec
     58    double rErr;                       ///< Error in RA
     59    double dErr;                       ///< Error in Dec
    6060}
    6161psSphere;
     62
     63/** 3-Dimensional Euclidean Coordinate System
     64 *
     65 *  Both detector and sky positions will be used extensively in the IPP. One
     66 *  coordinate system to be used is cubic coordinates for which additional
     67 *  care must often be taken in comparison to an angular coordinate system.
     68 *
     69 */
     70typedef struct
     71{
     72    double x;                          ///< cos (DEC) cos (RA)
     73    double y;                          ///< cos (DEC) sin (RA)
     74    double z;                          ///< sin (DEC)
     75    double xErr;                       ///< Error in x
     76    double yErr;                       ///< Error in y
     77    double zErr;                       ///< Error in z
     78}
     79psCube;
    6280
    6381/** 2D Polynomial Transform
     
    7189typedef struct
    7290{
    73     psPolynomial2D* x;         ///< 2D polynomial transform of X coordinates
    74     psPolynomial2D* y;         ///< 2D polynomial transform of Y coordinates
     91    psPolynomial2D* x;                 ///< 2D polynomial transform of X coordinates
     92    psPolynomial2D* y;                 ///< 2D polynomial transform of Y coordinates
    7593}
    7694psPlaneTransform;
     
    90108typedef struct
    91109{
    92     psPolynomial4D* x;         ///< 4D polynomial transform of X coordinates
    93     psPolynomial4D* y;         ///< 4D polynomial transform of Y coordinates
     110    psPolynomial4D* x;                 ///< 4D polynomial transform of X coordinates
     111    psPolynomial4D* y;                 ///< 4D polynomial transform of Y coordinates
    94112}
    95113psPlaneDistort;
     
    120138 */
    121139typedef enum {
    122     PS_PROJ_TAN,                ///< Tangent projection
    123     PS_PROJ_SIN,                ///< Sine projection
    124     PS_PROJ_AIT,                ///< Aitoff projection
    125     PS_PROJ_PAR,                ///< Par projection
     140    PS_PROJ_TAN,                       ///< Tangent projection
     141    PS_PROJ_SIN,                       ///< Sine projection
     142    PS_PROJ_AIT,                       ///< Aitoff projection
     143    PS_PROJ_PAR,                       ///< Par projection
    126144    //    PS_PROJ_GLS,                ///< GLS projection
    127145    //    PS_PROJ_CAR,                ///< CAR projection
    128146    //    PS_PROJ_MER,                ///< MER projection
    129     PS_PROJ_NTYPE               ///< Number of types; must be last.
     147    PS_PROJ_NTYPE                      ///< Number of types; must be last.
    130148} psProjectionType;
    131149
     
    137155typedef struct
    138156{
    139     double R;                   ///< Coordinates of projection center
    140     double D;                   ///< Coordinates of projection center
    141     double Xs;                  ///< plate-scale in X direction
    142     double Ys;                  ///< plate-scale in Y direction
    143     psProjectionType type;      ///< Projection type
     157    double R;                          ///< Coordinates of projection center
     158    double D;                          ///< Coordinates of projection center
     159    double Xs;                         ///< plate-scale in X direction
     160    double Ys;                         ///< plate-scale in Y direction
     161    psProjectionType type;             ///< Projection type
    144162}
    145163psProjection;
     
    151169 */
    152170typedef enum {
    153     PS_SPHERICAL,               ///< offset corresponds to an angular offset
    154     PS_LINEAR                   ///< offset corresponds to a linear offset
     171    PS_SPHERICAL,                      ///< offset corresponds to an angular offset
     172    PS_LINEAR                          ///< offset corresponds to a linear offset
    155173} psSphereOffsetMode;
    156174
     
    161179 */
    162180typedef enum {
    163     PS_ARCSEC,                  ///< Arcseconds
    164     PS_ARCMIN,                  ///< Arcminutes
    165     PS_DEGREE,                  ///< Degrees
    166     PS_RADIAN                   ///< Radians
     181    PS_ARCSEC,                         ///< Arcseconds
     182    PS_ARCMIN,                         ///< Arcminutes
     183    PS_DEGREE,                         ///< Degrees
     184    PS_RADIAN                          ///< Radians
    167185} psSphereOffsetUnit;
    168186
     
    181199psSphere* psSphereAlloc(void);
    182200
     201/** Allocates a psCube
     202 *
     203 *  @return psCube*       resulting cube structure.
     204 */
     205psCube* psCubeAlloc(void);
    183206
    184207/** Allocates a psPlaneTransform transform.
     
    233256
    234257psSphereTransform* psSphereTransformAlloc(
    235     double alphaP,                      ///< north pole latitude
    236     double deltaP,                      ///< north pole longitude?
    237     double phiP                         ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares).
     258    double alphaP,                     ///< north pole latitude
     259    double deltaP,                     ///< north pole longitude?
     260    double phiP                        ///< defines the longitude in the input system of the equatorial intersection between the two systems (e.g, the first point of Ares).
    238261);
    239262
     
    254277 */
    255278psSphereTransform* psSphereTransformICRSToEcliptic(
    256     psTime *time                        ///< the time for which the resulting transform will be valid
     279    psTime *time                       ///< the time for which the resulting transform will be valid
    257280);
    258281
     
    263286 */
    264287psSphereTransform* psSphereTransformEclipticToICRS(
    265     psTime *time                        ///< the time for which the resulting transform will be valid
     288    psTime *time                       ///< the time for which the resulting transform will be valid
    266289);
    267290
     
    283306 */
    284307psProjection* psProjectionAlloc(
    285     double R,                   ///< Right-ascension of projection center.
    286     double D,                   ///< Declination of projection center.
    287     double Xs,                  ///< Scale in x-dimension
    288     double Ys,                  ///< Scale in y-dimension
     308    double R,                          ///< Right-ascension of projection center.
     309    double D,                          ///< Declination of projection center.
     310    double Xs,                         ///< Scale in x-dimension
     311    double Ys,                         ///< Scale in y-dimension
    289312    psProjectionType type
    290313);
     
    361384*/
    362385psPlaneTransform *p_psPlaneTransformLinearInvert(
    363     psPlaneTransform *transform        ///<    transform to invert
     386    psPlaneTransform *transform        ///< transform to invert
    364387);
    365388
     
    371394*/
    372395psS32 p_psIsProjectionLinear(
    373     psPlaneTransform *transform        ///<     transform to test for linearity
     396    psPlaneTransform *transform        ///< transform to test for linearity
    374397);
    375398
     
    436459 */
    437460bool psPlaneTransformFit(
    438     psPlaneTransform *trans,
    439     const psArray *source,
    440     const psArray *dest,
    441     int nRejIter,
    442     float sigmaClip
     461    psPlaneTransform *trans,           ///< desired order, polynomial type, & polynomial mask terms
     462    const psArray *source,             ///< coordinates matching those in dest
     463    const psArray *dest,               ///< coordinates matching those in source
     464    int nRejIter,                      ///< number of rejection iterations to be performed
     465    float sigmaClip                    ///< coordinates above this number of standard deviations will be rejected
    443466);
    444467//XXX: need to add doxygen comments on the parameters above. -rdd
    445468
     469/** Converts from a 3-dimensional coordinate system to an angular coordinate system.
     470 *
     471 *  @return psSphere*       The former psCube in terms of a psSphere.
     472 */
     473psSphere *psCubeToSphere(
     474    const psCube *cube                 ///< psCube to convert
     475);
     476
     477/** Converts from an angular coordinate system to a 3-dimensional coordinate system.
     478 *
     479 *  @return psCube*         The former psSphere in terms of a psCube.
     480 */
     481psCube *psSphereToCube(
     482    const psSphere *sphere             ///< psSphere to convert
     483);
     484
     485
    446486/// @}
    447487
Note: See TracChangeset for help on using the changeset viewer.