Changeset 12753
- Timestamp:
- Apr 5, 2007, 1:36:09 PM (19 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 6 edited
-
addstar/src/ConfigInit_skycells.c (modified) (1 diff)
-
addstar/src/args_skycells.c (modified) (1 diff)
-
addstar/src/sky_tessalation.c (modified) (3 diffs)
-
addstar/src/skycells.c (modified) (2 diffs)
-
opihi/dvo/gimages.c (modified) (1 diff)
-
opihi/dvo/images.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/addstar/src/ConfigInit_skycells.c
r12749 r12753 1 # include " addstar.h"1 # include "skycells.h" 2 2 3 3 void GetConfig (char *config, char *field, char *format, int N, void *ptr); -
trunk/Ohana/src/addstar/src/args_skycells.c
r12749 r12753 1 # include " addstar.h"1 # include "skycells.h" 2 2 static void help (void); 3 3 -
trunk/Ohana/src/addstar/src/sky_tessalation.c
r12751 r12753 23 23 for (i = 0; i < Ntriangles; i++) { 24 24 sky_triangle_to_image (&image[i], &tri[i]); 25 sprintf (image[i].name, "test.%03d", i); 25 26 } 26 27 … … 35 36 double xv[3], yv[3]; // coordinates of the vertex in the reference projection 36 37 double xo, yo, xc, yc, angle, scale; 38 double Xmin, Xmax, Ymin, Ymax; 37 39 38 40 // calculate the triangle coordinates in r,d 39 41 sky_triangle_coords (triangle); 40 42 41 for (n = 0; n < 3; n++) { 42 // we will project to the triangle center position 43 refcoords[0].crval1 = triangle[0].r; 44 refcoords[0].crval2 = triangle[0].d; 45 46 // find the size, rotation, and parity of the image 47 // project the vertices and find the image parity 48 parity = 1; 49 for (i = 0; i < 3; i++) { 50 RD_to_XY (&xv[i], &yv[i], triangle[0].rv[i], triangle[0].dv[i], refcoords); 51 parity *= SIGN(yv[i]); 52 } 53 54 // choose the peak vertex 55 peak = -1; 56 for (i = 0; (peak == -1) && (i < 3); i++) { 57 if (parity == SIGN(yv[i])) { 58 peak = i; 59 } 60 } 61 assert (peak != -1); 62 63 // find the base and height 64 b1 = (peak + 1) % 3; 65 b2 = (peak + 2) % 3; 66 67 // xo, yo is the center of the baseline 68 xo = 0.5*(xv[b2] + xv[b1]); 69 yo = 0.5*(yv[b2] + yv[b1]); 70 71 if (n != 2) { 72 // xc, yc is the true image center 73 xc = 0.5*(xv[peak] + xo); 74 yc = 0.5*(yv[peak] + yo); 75 XY_to_RD (&triangle[0].r, &triangle[0].d, xc, yc, refcoords); 76 } 77 } 78 79 NX = hypot((xv[b2]-xv[b1]),(yv[b2]-yv[b1])); 80 NY = hypot((xv[peak]-xo),(yv[peak]-yo)); 81 angle = atan2(parity*xv[peak], parity*yv[peak]); // note that this is x/y not y/x (and in radians) 43 // we will project to the triangle center position 44 refcoords[0].crval1 = triangle[0].r; 45 refcoords[0].crval2 = triangle[0].d; 46 47 // project the vertices to this projection, find bounds 48 Xmin = Xmax = Ymin = Ymax = 0.0; // 0,0 is center of triangle 49 for (i = 0; i < 3; i++) { 50 RD_to_XY (&xv[i], &yv[i], triangle[0].rv[i], triangle[0].dv[i], refcoords); 51 Xmin = MIN (xv[i], Xmin); 52 Xmax = MAX (xv[i], Xmax); 53 Ymin = MIN (yv[i], Ymin); 54 Ymax = MAX (yv[i], Ymax); 55 } 56 57 // set NX, NY to the roughly full-width box (centered at 0,0) 58 NX = Xmax - Xmin; 59 NY = Ymax - Ymin; 82 60 83 61 memset (image, 0, sizeof(Image)); 84 62 image[0].coords = *refcoords; 85 image[0].coords.pc1_1 = +cos(angle); 86 image[0].coords.pc1_2 = +sin(angle); 87 image[0].coords.pc2_1 = -sin(angle); 88 image[0].coords.pc2_2 = +cos(angle); 89 90 if (parity == 1) { 91 strcpy (image[0].coords.ctype, "TRP--TAN"); 92 } else { 93 strcpy (image[0].coords.ctype, "TRM--TAN"); 94 } 95 sprintf (image[0].name, "test.%03d", i); 96 if ((NX > 60000) || (NY > 60000)) { 97 scale = NX / 60000.0; 98 scale = MAX(scale, NY / 60000.0); 63 image[0].coords.pc1_1 = image[0].coords.pc2_2 = 1.0; 64 image[0].coords.pc1_2 = image[0].coords.pc2_1 = 0.0; 65 66 // We cannot use the correction below if we want to set cdelt1,2 to our desired pixel scale 67 // use this test to raise an error (60000 x 60000 is a very large image...) 68 strcpy (image[0].coords.ctype, "TRI--TAN"); 69 scale = 0; 70 for (i = 0; i < 3; i++) { 71 scale = MAX (abs(xv[i]), scale); 72 scale = MAX (abs(yv[i]), scale); 73 } 74 if (scale > 32000) { 75 scale /= 30000.0; 99 76 NX /= scale; 100 77 NY /= scale; 101 78 image[0].coords.cdelt1 *= scale; 102 79 image[0].coords.cdelt2 *= scale; 80 for (i = 0; i < 3; i++) { 81 xv[i] /= scale; 82 yv[i] /= scale; 83 } 103 84 } 104 85 image[0].NX = NX; 105 86 image[0].NY = NY; 106 image[0].code = 1; 107 108 // fprintf (stderr, "%d %f %d %d %d %d %d\n", parity, angle*DEG_RAD, peak, b1, b2, NX, NY); 87 88 image[0].code = 1; // this needs to be set more sensibly 89 90 image[0].Mx = xv[0]; image[0].My = yv[0]; 91 image[0].Mxxx = xv[1]; image[0].Mxyy = yv[1]; 92 image[0].Mxxy = xv[2]; image[0].Myyy = yv[2]; 109 93 110 94 return (TRUE); … … 298 282 } 299 283 284 285 286 /*** this code was an attempt to fit the triangle boundaries into NX, NY ***/ 287 # if (0) 288 for (n = 0; n < 3; n++) { 289 // we will project to the triangle center position 290 refcoords[0].crval1 = triangle[0].r; 291 refcoords[0].crval2 = triangle[0].d; 292 293 // find the size, rotation, and parity of the image 294 // project the vertices and find the image parity 295 parity = 1; 296 for (i = 0; i < 3; i++) { 297 RD_to_XY (&xv[i], &yv[i], triangle[0].rv[i], triangle[0].dv[i], refcoords); 298 parity *= SIGN(yv[i]); 299 } 300 301 // choose the peak vertex 302 peak = -1; 303 for (i = 0; (peak == -1) && (i < 3); i++) { 304 if (parity == SIGN(yv[i])) { 305 peak = i; 306 } 307 } 308 assert (peak != -1); 309 310 // find the base and height 311 b1 = (peak + 1) % 3; 312 b2 = (peak + 2) % 3; 313 314 // xo, yo is the center of the baseline 315 xo = 0.5*(xv[b2] + xv[b1]); 316 yo = 0.5*(yv[b2] + yv[b1]); 317 318 if (n != 2) { 319 // xc, yc is the true image center 320 xc = 0.5*(xv[peak] + xo); 321 yc = 0.5*(yv[peak] + yo); 322 XY_to_RD (&triangle[0].r, &triangle[0].d, xc, yc, refcoords); 323 } 324 } 325 326 NX = hypot((xv[b2]-xv[b1]),(yv[b2]-yv[b1])); 327 NY = hypot((xv[peak]-xo),(yv[peak]-yo)); 328 angle = atan2(parity*xv[peak], parity*yv[peak]); // note that this is x/y not y/x (and in radians) 329 330 memset (image, 0, sizeof(Image)); 331 image[0].coords = *refcoords; 332 image[0].coords.pc1_1 = +cos(angle); 333 image[0].coords.pc1_2 = +sin(angle); 334 image[0].coords.pc2_1 = -sin(angle); 335 image[0].coords.pc2_2 = +cos(angle); 336 337 if (parity == 1) { 338 strcpy (image[0].coords.ctype, "TRP--TAN"); 339 } else { 340 strcpy (image[0].coords.ctype, "TRM--TAN"); 341 } 342 sprintf (image[0].name, "test.%03d", i); 343 if ((NX > 60000) || (NY > 60000)) { 344 scale = NX / 60000.0; 345 scale = MAX(scale, NY / 60000.0); 346 NX /= scale; 347 NY /= scale; 348 image[0].coords.cdelt1 *= scale; 349 image[0].coords.cdelt2 *= scale; 350 } 351 image[0].NX = NX; 352 image[0].NY = NY; 353 image[0].code = 1; 354 # endif -
trunk/Ohana/src/addstar/src/skycells.c
r12749 r12753 1 # include " addstar.h"1 # include "skycells.h" 2 2 3 3 int main (int argc, char **argv) { … … 29 29 if (db.dbstate == LCK_EMPTY) { 30 30 if (VERBOSE) fprintf (stderr, "can't find %s, creating a new one\n", ImageCat); 31 dvo_image_create (&db, ZeroPt);31 dvo_image_create (&db, 25.0); 32 32 } else { 33 if (!dvo_image_load (&db, VERBOSE, F ORCE_READ)) {33 if (!dvo_image_load (&db, VERBOSE, FALSE)) { 34 34 Shutdown ("can't read image catalog %s", db.filename); 35 35 } -
trunk/Ohana/src/opihi/dvo/gimages.c
r12750 r12753 80 80 int TriangleUp = wordhash ("TRP-"); 81 81 int TriangleDn = wordhash ("TRM-"); 82 int TrianglePts = wordhash ("TRI-"); 82 83 83 84 Nfound = 0; -
trunk/Ohana/src/opihi/dvo/images.c
r12750 r12753 114 114 int TriangleUp = wordhash ("TRP-"); 115 115 int TriangleDn = wordhash ("TRM-"); 116 int TrianglePts = wordhash ("TRI-"); 116 117 117 118 npts = NPTS = 200; … … 155 156 x[1] = +0.5*image[i].NX; y[1] = +0.5*image[i].NY; 156 157 x[2] = -0.5*image[i].NX; y[2] = +0.5*image[i].NY; 158 goto got_type; 159 } 160 // For 'TrianglePts' (TRI-), we are using the Mx,My, etc terms to save the coordinates 161 // this means triangular images cannot carry photometric zero-point variations 162 if (typehash == TrianglePts) { 163 Npts = 3; 164 x[0] = image[i].Mx; y[0] = image[i].My; 165 x[1] = image[i].Mxxx; y[1] = image[i].Mxyy; 166 x[2] = image[i].Mxxy; y[2] = image[i].Myyy; 157 167 goto got_type; 158 168 } … … 228 238 if (Npts == 0) continue; 229 239 230 // if any of the points is on the screen, plot the image231 240 status = FALSE; 232 241 for (j = 0; j < Npts; j++) { … … 239 248 Xvec.elements[N+2*Npts-1] = Xvec.elements[N]; 240 249 Yvec.elements[N+2*Npts-1] = Yvec.elements[N]; 250 if (!status) continue; 251 // if none of the points are on the visible side of the projection, do not plot the image 252 241 253 InPic = FALSE; 242 254 for (j = 0; j < 2*Npts; j+=2) { … … 247 259 InPic = TRUE; 248 260 } 249 if (!status && HIDDEN) status = TRUE;250 if ( InPic && status) {251 plist[n] = i; 252 n++;253 if (n > npts - 1) {254 npts += 200; 255 REALLOCATE (plist, int, npts);256 }257 N+=2*Npts;258 if (N + 16 >= NPTS) { /* need to leave room for 8 point image */259 NPTS += 400; 260 REALLOCATE (Xvec.elements, float, NPTS);261 REALLOCATE (Yvec.elements, float, NPTS);262 }261 // if (!status && HIDDEN) status = TRUE; 262 if (!InPic) continue; 263 264 plist[n] = i; 265 n++; 266 if (n > npts - 1) { 267 npts += 200; 268 REALLOCATE (plist, int, npts); 269 } 270 N+=2*Npts; 271 if (N + 16 >= NPTS) { /* need to leave room for 8 point image */ 272 NPTS += 400; 273 REALLOCATE (Xvec.elements, float, NPTS); 274 REALLOCATE (Yvec.elements, float, NPTS); 263 275 } 264 276 }
Note:
See TracChangeset
for help on using the changeset viewer.
