IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

Added psCube and psCube fxns to psCoord

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.