IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12753


Ignore:
Timestamp:
Apr 5, 2007, 1:36:09 PM (19 years ago)
Author:
eugene
Message:

use TRI images to represent skycell triangles

Location:
trunk/Ohana/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/ConfigInit_skycells.c

    r12749 r12753  
    1 # include "addstar.h"
     1# include "skycells.h"
    22
    33void 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"
    22static void help (void);
    33
  • trunk/Ohana/src/addstar/src/sky_tessalation.c

    r12751 r12753  
    2323  for (i = 0; i < Ntriangles; i++) {
    2424    sky_triangle_to_image (&image[i], &tri[i]);
     25    sprintf (image[i].name, "test.%03d", i);
    2526  } 
    2627
     
    3536  double xv[3], yv[3];        // coordinates of the vertex in the reference projection
    3637  double xo, yo, xc, yc, angle, scale;
     38  double Xmin, Xmax, Ymin, Ymax;
    3739
    3840  // calculate the triangle coordinates in r,d
    3941  sky_triangle_coords (triangle);
    4042
    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;
    8260
    8361  memset (image, 0, sizeof(Image));
    8462  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;
    9976    NX /= scale;
    10077    NY /= scale;
    10178    image[0].coords.cdelt1 *= scale;
    10279    image[0].coords.cdelt2 *= scale;
     80    for (i = 0; i < 3; i++) {
     81      xv[i] /= scale;
     82      yv[i] /= scale;
     83    }
    10384  }
    10485  image[0].NX = NX;
    10586  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];
    10993
    11094  return (TRUE);
     
    298282}
    299283
     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"
    22
    33int main (int argc, char **argv) {
     
    2929  if (db.dbstate == LCK_EMPTY) {
    3030    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);
    3232  } else {
    33     if (!dvo_image_load (&db, VERBOSE, FORCE_READ)) {
     33    if (!dvo_image_load (&db, VERBOSE, FALSE)) {
    3434      Shutdown ("can't read image catalog %s", db.filename);
    3535    }
  • trunk/Ohana/src/opihi/dvo/gimages.c

    r12750 r12753  
    8080  int TriangleUp   = wordhash ("TRP-");
    8181  int TriangleDn   = wordhash ("TRM-");
     82  int TrianglePts  = wordhash ("TRI-");
    8283
    8384  Nfound = 0;
  • trunk/Ohana/src/opihi/dvo/images.c

    r12750 r12753  
    114114  int TriangleUp   = wordhash ("TRP-");
    115115  int TriangleDn   = wordhash ("TRM-");
     116  int TrianglePts  = wordhash ("TRI-");
    116117
    117118  npts = NPTS = 200;
     
    155156      x[1] = +0.5*image[i].NX; y[1] = +0.5*image[i].NY;
    156157      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;
    157167      goto got_type;
    158168    }
     
    228238    if (Npts == 0) continue;
    229239
    230     // if any of the points is on the screen, plot the image
    231240    status = FALSE;
    232241    for (j = 0; j < Npts; j++) {
     
    239248    Xvec.elements[N+2*Npts-1] = Xvec.elements[N];
    240249    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
    241253    InPic = FALSE;
    242254    for (j = 0; j < 2*Npts; j+=2) {
     
    247259        InPic = TRUE;
    248260    }
    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);
    263275    }
    264276  }
Note: See TracChangeset for help on using the changeset viewer.