IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19838


Ignore:
Timestamp:
Oct 2, 2008, 10:45:24 AM (18 years ago)
Author:
eugene
Message:

fix flips and ellipse

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa2/src/bDrawOverlay.c

    r16255 r19838  
    77
    88  int i;
    9   int dX, dY, dx, dy;
    10   int X, Y, Xmin, Ymin, Xmax, Ymax, Xrange, Yrange;
    11   double expand, X0, Y0;
     9  int dx, dy;
     10  int Xmin, Ymin, Xmax, Ymax, Xrange, Yrange;
     11  double expand, X, Y, dX, dY, pX, pY;
    1212  bDrawColor color;
    1313 
     
    1818  expand = 1.0;
    1919  if (image[0].picture.expand > 0) {
    20     expand = 1 / (1.0*image[0].picture.expand);
     20    expand = image[0].picture.expand;
    2121  }
    2222  if (image[0].picture.expand < 0) {
    23     expand = fabs((double)image[0].picture.expand);
     23    expand = 1.0 / fabs((double)image[0].picture.expand);
    2424  }
    25 
    26   Image_to_Screen (&X0, &Y0, 0.0, 0.0, &image[0].picture);
    27   X0 -= image[0].picture.x;
    28   Y0 -= image[0].picture.y;
    2925
    3026  Xmin = 0;
     
    3531  Yrange = image[0].picture.dy;
    3632
     33  if (N == INFRONT) {
     34    fprintf (stderr, "INFRONT deprecated\n");
     35    return;
     36  }
     37
    3738  for (i = 0; i < image[0].overlay[N].Nobjects; i++) {
    38     if (N == INFRONT) {
    39       X  = image[0].overlay[N].objects[i].x * Xrange;
    40       Y  = image[0].overlay[N].objects[i].y * Yrange;
    41       dX = image[0].overlay[N].objects[i].dx * Xrange;
    42       dY = image[0].overlay[N].objects[i].dy * Yrange;
    43     } else {
    44       X  = image[0].overlay[N].objects[i].x/expand + X0;
    45       Y =  image[0].overlay[N].objects[i].y/expand + Y0;
    46       dX = image[0].overlay[N].objects[i].dx/expand;
    47       dY = image[0].overlay[N].objects[i].dy/expand;
    48     }
    49     if ((X + dX < Xmin) || (X - dX > Xmax) ||
    50         (Y + dY < Ymin) || (Y - dY > Ymax)) {
    51       continue;
    52     }
     39    Image_to_Picture (&X, &Y, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].picture);
     40    dX = image[0].overlay[N].objects[i].dx * expand;
     41    dY = image[0].overlay[N].objects[i].dy * expand;
     42    if (image[0].picture.flipx) dX *= -1;
     43    if (image[0].picture.flipy) dY *= -1;
     44
     45    if (X + dX < Xmin) continue;
     46    if (X - dX > Xmax) continue;
     47    if (Y + dY < Ymin) continue;
     48    if (Y - dY > Ymax);
     49
     50    pX = (image[0].picture.flipx) ? -1.0 : +1.0;
     51    pY = (image[0].picture.flipy) ? -1.0 : +1.0;
    5352
    5453    /* for a LINE, (x, y) is the start, (dx, dy) is the distance to end
     
    7574          bDrawArc (X, Y, dx, dy, 0, 360);
    7675        } else {
    77           // very stupid rotate ellipse drawing:
    78           double x, y, t;
     76          // moderately-stupid rotated ellipse drawing:
     77          // ANGLE is distance ccw from the x-axis to the major axis
     78          double x0, y0, x1, y1, t;
    7979          double angle = image[0].overlay[N].objects[i].angle * RAD_DEG;
    8080          double cs = cos(angle);
    8181          double sn = sin(angle);
     82          x0 = X + pX*dx*cs;
     83          y0 = Y - pY*dx*sn;
    8284          // XXX dt should be based on the size of the ellipse...
    83           for (t = 0; t < 2*M_PI; t+=0.05) {
    84             x = X + dx*cos(t)*cs + dy*sin(t)*sn;
    85             y = Y - dx*cos(t)*sn + dy*sin(t)*cs;
    86             bDrawPoint (x, y);
     85          // 0.10 -> 60 segments on the ellipse
     86          # define DT 0.1
     87          for (t = DT; t < 2*M_PI + DT; t+=DT) {
     88            x1 = X + pX*dx*cos(t)*cs + pX*dy*sin(t)*sn;
     89            y1 = Y - pY*dx*cos(t)*sn + pY*dy*sin(t)*cs;
     90            bDrawLine (x0, y0, x1, y1);
     91            x0 = x1;
     92            y0 = y1;
    8793          }
    8894        }
Note: See TracChangeset for help on using the changeset viewer.