IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 27, 2006, 3:31:44 PM (20 years ago)
Author:
drobbin
Message:

Implemented psPixelsTransform.

File:
1 edited

Legend:

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

    r6204 r6230  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.101 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-01-26 21:10:22 $
     12*  @version $Revision: 1.102 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-01-28 01:31:44 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    206206
    207207// XXX: Verify the order/nterms poly changes
    208 psPlaneTransform* psPlaneTransformAlloc(int order1, int order2)
     208psPlaneTransform* psPlaneTransformAlloc(int order1,
     209                                        int order2)
    209210{
    210211    PS_ASSERT_INT_NONNEGATIVE(order1, NULL);
     
    240241}
    241242
    242 psPlane* psPlaneTransformApply(
    243     psPlane* out,
    244     const psPlaneTransform* transform,
    245     const psPlane* coords)
     243psPlane* psPlaneTransformApply(psPlane* out,
     244                               const psPlaneTransform* transform,
     245                               const psPlane* coords)
    246246{
    247247    PS_ASSERT_PTR_NON_NULL(transform, NULL);
     
    267267
    268268// XXX: Verify the order/nterms poly changes
    269 psPlaneDistort* psPlaneDistortAlloc(int order1, int order2, int order3, int order4)
     269psPlaneDistort* psPlaneDistortAlloc(int order1,
     270                                    int order2,
     271                                    int order3,
     272                                    int order4)
    270273{
    271274    PS_ASSERT_INT_NONNEGATIVE(order1, NULL);
     
    347350}
    348351
    349 psProjection* psProjectionAlloc(
    350     double R,
    351     double D,
    352     double Xs,
    353     double Ys,
    354     psProjectionType type)
     352psProjection* psProjectionAlloc(double R,
     353                                double D,
     354                                double Xs,
     355                                double Ys,
     356                                psProjectionType type)
    355357{
    356358    psProjection *p = psAlloc(sizeof(psProjection));
     
    372374
    373375
    374 psPlane* p_psProject(
    375     psPlane *outPlane,
    376     const psSphere* coord,
    377     const psProjection* projection)
     376psPlane* p_psProject(psPlane *outPlane,
     377                     const psSphere* coord,
     378                     const psProjection* projection)
    378379{
    379380    PS_ASSERT_PTR_NON_NULL(coord, NULL);
     
    457458}
    458459
    459 psSphere* p_psDeproject(
    460     psSphere *outSphere,
    461     const psPlane* coord,
    462     const psProjection* projection)
     460psSphere* p_psDeproject(psSphere *outSphere,
     461                        const psPlane* coord,
     462                        const psProjection* projection)
    463463{
    464464    PS_ASSERT_PTR_NON_NULL(coord, NULL);
     
    604604routine far too many times.
    605605 *****************************************************************************/
    606 psPlaneTransform *psPlaneTransformCombine(
    607     psPlaneTransform *out,
    608     const psPlaneTransform *trans1,
    609     const psPlaneTransform *trans2,
    610     psRegion region,
    611     int nSamples)
     606psPlaneTransform *psPlaneTransformCombine(psPlaneTransform *out,
     607        const psPlaneTransform *trans1,
     608        const psPlaneTransform *trans2,
     609        psRegion region,
     610        int nSamples)
    612611{
    613612    psTrace(__func__, 3, "---- %s() begin ----\n", __func__);
     
    10161015}
    10171016
    1018 psPlane *psPlaneTransformDeriv(
    1019     psPlane *out,
    1020     const psPlaneTransform *transformation,
    1021     const psPlane *coord
    1022 )
     1017psPlane *psPlaneTransformDeriv(psPlane *out,
     1018                               const psPlaneTransform *transformation,
     1019                               const psPlane *coord)
    10231020{
    10241021    PS_ASSERT_PTR_NON_NULL(transformation, NULL);
     
    10801077    }
    10811078    return(out);
     1079}
     1080
     1081psPixels *psPixelsTransform(psPixels *out,
     1082                            const psPixels *input,
     1083                            const psPlaneTransform *inToOut)
     1084{
     1085    PS_ASSERT_PTR_NON_NULL(input, NULL);
     1086    PS_ASSERT_PTR_NON_NULL(inToOut, NULL);
     1087    PS_ASSERT_PTR_NON_NULL(inToOut->x, NULL);
     1088    PS_ASSERT_PTR_NON_NULL(inToOut->y, NULL);
     1089    if (out == NULL) {
     1090        //XXX: Should the length (nalloc) be 1 and append be used everytime a pixel is added?
     1091        //        out = psPixelsAlloc(input->nalloc);
     1092        out = psPixelsAlloc(1);
     1093    }
     1094    psPlane *coord = psPlaneAlloc();
     1095    psPlane *deriv = psPlaneAlloc();
     1096    psPlane *fxnVal = psPlaneAlloc();
     1097
     1098    int i = 0;
     1099    //    int m = 0;
     1100    //    while (input->data.x[i] != 0.0 && input->data.y[i] != 0.0) {
     1101    for ( i = 0; i < input->n; i++) {
     1102        coord->x = input->data[i].x;
     1103        coord->y = input->data[i].y;
     1104        deriv = psPlaneTransformDeriv(deriv, inToOut, coord);
     1105        fxnVal = psPlaneTransformApply(fxnVal, inToOut, coord);
     1106        if (fabs(fxnVal->x - coord->x) < fabs(deriv->x) &&
     1107                fabs(fxnVal->y - coord->y) < fabs(deriv->y)) {
     1108            int x = (int)(round(fabs(deriv->x)));
     1109            int y = (int)(round(fabs(deriv->y)));
     1110            for (int j = -x; j <= x; j++) {
     1111                for (int k = -y; k <= y; k++) {
     1112                    //                    out->data[m].x = fxnVal->x + x;
     1113                    //                    out->data[m].y = fxnVal->y + y;
     1114                    //                    m++;
     1115                    out = p_psPixelsAppend(out, 1, (float)(fxnVal->x+j),
     1116                                           (float)(fxnVal->y+k) );
     1117                }
     1118            }
     1119        }
     1120    }
     1121
     1122    psFree(coord);
     1123    psFree(deriv);
     1124    psFree(fxnVal);
     1125    return out;
    10821126}
    10831127
Note: See TracChangeset for help on using the changeset viewer.