Index: nmake.opt =================================================================== --- nmake.opt (revision 2130) +++ nmake.opt (working copy) @@ -22,9 +22,9 @@ # Uncomment the first for an optimized build, or the second for debug. !IFNDEF OPTFLAGS !IFNDEF DEBUG -OPTFLAGS= /nologo /Ox /Op /MD +OPTFLAGS= /nologo /Ox /Op /MD /TC !ELSE -OPTFLAGS= /nologo /Zi /MD /Fdproj.pdb +OPTFLAGS= /nologo /Zi /MD /TC /Fdproj.pdb !ENDIF !ENDIF Index: src/PJ_healpix.c =================================================================== --- src/PJ_healpix.c (revision 2130) +++ src/PJ_healpix.c (working copy) @@ -56,8 +56,8 @@ /** Used for calculating if a point is within the HEALPix projection for sphere. **/ # define EPS 1e-12 typedef struct { - int cn; // the number 0 -> 4 indicating the position of the polar cap. - double x,y; // the coordinates of the pole points (point of most extreme latitude on the polar caps). + int cn; /* the number 0 -> 4 indicating the position of the polar cap. */ + double x,y; /* the coordinates of the pole points (point of most extreme latitude on the polar caps). */ enum Region { north, south, equatorial } region; } CapMap; typedef struct { @@ -146,21 +146,21 @@ * @param testy the y-coordinate of the test point. * @return 1 if on or within the bounds of the polygon, and 0 otherwise. **/ -int pnpoly(int nvert, double vert[][nvert], double testx, double testy){ - +int pnpoly(int nvert, double vert[][2], double testx, double testy){ + int i,j,c = 0; int counter = 0; double xinters; Point p1,p2; - // check for boundrary cases + /* check for boundrary cases */ for(i = 0; i < nvert; i++){ if(testx == vert[i][0] && testy == vert[i][1]){ return 1; } } - // initialize p1 + /* initialize p1 */ p1.x = vert[0][0]; p1.y = vert[0][1]; @@ -200,7 +200,7 @@ **/ int in_image(double x, double y, int proj, int npole, int spole){ if(proj == 0){ - double healpixVertsJit[][18] = { + double healpixVertsJit[18][2] = { {-1.0*PI-EPS ,PI/4.0}, {-3.0*PI/4.0 ,PI/2.0+EPS}, {-1.0*PI/2.0 ,PI/4.0+EPS}, @@ -219,10 +219,10 @@ {-1.0*PI/2.0 ,-1.0*PI/4.0-EPS}, {-3.0*PI/4.0 ,-1.0*PI/2.0-EPS}, {-1.0*PI-EPS ,-1.0*PI/4.0}}; - return pnpoly(18,healpixVertsJit,x,y); + return pnpoly(18,healpixVertsJit,x,y); }else{ - // Used for calculating if a point is within the rHEALPix projection for sphere. - double rhealpixVertsJit[][12] = { + /* Used for calculating if a point is within the rHEALPix projection for sphere. */ + double rhealpixVertsJit[12][2] = { {-1.0*PI-EPS ,PI/4.0+EPS}, {-1.0*PI + npole*PI/2.0-EPS ,PI/4.0+EPS}, {-1.0*PI + npole*PI/2.0-EPS ,3*PI/4.0+EPS}, @@ -257,7 +257,7 @@ double qp = 1.0 - (1.0-pow(e,2.0)) / (2.0*e)*log((1.0 - e) / (1.0 + e)); double ratio = q/qp; - // Rounding errors + /* Rounding errors */ if( fabsl(ratio) > 1){ ratio = sign(ratio); } @@ -276,7 +276,7 @@ double phi = standardize_lat(lp.phi); double phi0 = aasin(P->ctx, 2.0/3.0); XY xy; - // equatorial region + /* equatorial region */ if( fabsl(phi) <= phi0) { xy.x = lam; xy.y = 3.0*PI/8.0*sin(phi); @@ -305,11 +305,11 @@ double xc; double tau; LP lp; - // Scale down to radius 1 sphere + /* Scale down to radius 1 sphere */ x = scale_number(xy.x,P->a,1); y = scale_number(xy.y,P->a,1); y0 = PI/4.0; - // Equatorial region. + /* Equatorial region. */ if(fabsl(y) <= y0){ lp.lam = x; lp.phi = asin(8.0*y/(3.0*PI)); @@ -399,7 +399,7 @@ capmap.cn = 0; return capmap; } - // polar region + /* polar region */ if(x < -1*R*PI/2.0){ capmap.cn = 0; capmap.x = (-1*R*3.0*PI/4.0); @@ -436,9 +436,10 @@ capmap.cn = 0; return capmap; } - // Polar Region, find # of HEALPix polar cap number that - // x,y moves to when rHEALPix polar square is disassembled. - eps = R*1e-15; // Kludge. Fuzz to avoid some rounding errors. + /* Polar Region, find # of HEALPix polar cap number that + * x,y moves to when rHEALPix polar square is disassembled. + */ + eps = R*1e-15; /* Kludge. Fuzz to avoid some rounding errors. */ if(capmap.region == north){ if(y >= -1*x - R*PI/4.0 - eps && y < x + R*5.0*PI/4.0 - eps){ capmap.cn = 1; @@ -496,7 +497,7 @@ v[0] = x; v[1] = y; if(inverse == 0){ - // compute forward function by rotating, translating, and shifting xy. + /* compute forward function by rotating, translating, and shifting xy. */ int pole = 0; double (*tmpRot)[2]; double c[2] = {capmap.x,capmap.y}; @@ -514,7 +515,7 @@ tmpVect[0] = R*pole*PI/2.0; tmpVect[1] = 0; - // translate, rotate, then shift + /* translate, rotate, then shift */ vector_sub(v,c,v_min_c); dot_product(tmpRot,v_min_c,ret_dot); vector_add(a,tmpVect,ret_add); @@ -523,16 +524,17 @@ xy.y = vector[1]; return xy; }else{ - // compute inverse function. - // get the current position of rHEALPix polar squares + /* compute inverse function. + * get the current position of rHEALPix polar squares + */ int pole = floor( (capmap.x + R*3.0*PI/4.0) / (R*PI/2.0)); double tmpVect[2] = {R*pole*PI/2.0,0}; double coord[2] = {x,y}; double (*tmpRot)[2]; int cn; - // translate polar square to position 0 + /* translate polar square to position 0 */ vector_sub(coord,tmpVect,v); - // disassemble + /* disassemble */ if(capmap.region == north){ cn = capmap.cn + RFACTOR; a[0] = R*-3*PI/4.0; @@ -544,7 +546,7 @@ } tmpVect[0] = R*capmap.cn*PI/2.0; tmpVect[1] = 0; - // Math: Rotate Matrix * v-a + a + R*CN*{PI/2,0} + /* Math: Rotate Matrix * v-a + a + R*CN*{PI/2,0} */ vector_sub(v,a,v_min_c); dot_product(rot[cn],v_min_c,ret_dot); vector_add(ret_dot,a,ret_add); @@ -555,7 +557,7 @@ } } FORWARD(e_healpix_forward); /* ellipsoidal */ - //int r1[][2] = R1; + /*int r1[][2] = R1;*/ double bet = auth_lat(lp.phi, P->e, 0); lp.phi = bet; P->a = P->ra; @@ -564,14 +566,18 @@ FORWARD(s_healpix_forward); /* spheroid */ return healpix_sphere(lp, P); } + INVERSE(e_healpix_inverse); /* ellipsoidal */ + double bet; - P->a = P->ra; - // Scale down to radius 1 sphere before checking x,y + /* Scale down to radius 1 sphere before checking x,y */ double x = scale_number(xy.x,P->a,1); double y = scale_number(xy.y,P->a,1); - // check if the point is in the image + + P->a = P->ra; + + /* check if the point is in the image */ if(in_image(x,y,0,0,0) == 0){ lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; @@ -588,10 +594,10 @@ INVERSE(s_healpix_inverse); /* spheroid */ double x = xy.x; double y = xy.y; - // Scale down to radius 1 sphere before checking x,y + /* Scale down to radius 1 sphere before checking x,y */ x = scale_number(x,P->a,1); y = scale_number(y,P->a,1); - // check if the point is in the image + /* check if the point is in the image */ if(in_image(x,y,0,0,0) == 0){ lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; @@ -607,14 +613,14 @@ return combine_caps(xy.x, xy.y, P->a, P->npole, P->spole, 0); } FORWARD(s_rhealpix_forward); /* spheroid */ - // Compute forward function. + /* Compute forward function. */ xy = healpix_sphere(lp,P); return combine_caps(xy.x, xy.y, P->a, P->npole, P->spole, 0); } INVERSE(e_rhealpix_inverse); /* ellipsoidal */ double x = scale_number(xy.x,P->a,1); double y = scale_number(xy.y,P->a,1); - // check for out of bounds coordinates + /* check for out of bounds coordinates */ if(in_image(x,y,1,P->npole,P->spole) == 0){ lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; @@ -630,7 +636,7 @@ INVERSE(s_rhealpix_inverse); /* spheroid */ double x = scale_number(xy.x,P->a,1); double y = scale_number(xy.y,P->a,1); - // check for out of bounds coordinates + /* check for out of bounds coordinates */ if(in_image(x,y,1,P->npole,P->spole) == 0){ lp.lam = HUGE_VAL; lp.phi = HUGE_VAL; @@ -656,7 +662,7 @@ P->npole = pj_param(P->ctx, P->params,"inpole").i; P->spole = pj_param(P->ctx,P->params,"ispole").i; - // check for valid npole and spole inputs + /* check for valid npole and spole inputs */ if(P->npole < 0 || P->npole > 3){ E_ERROR(-47); }