# include "astro.h"
# define FIND_SHIFT(A,B) \
  find_shift (stars1, stars2, N1, N2, (A), (B), &N, &S, &dX, &dY); \
  if (S < s) { \
      s = S; \
    *Rx =  (A); \
    *Ry =  (B); \
    *dx = dX; \
    *dy = dY; \
      n = N; \
  }

void delta (stars1, stars2, N1, N2, dx, dy, Rx, Ry)
Stars stars1[], stars2[];
int N1, N2; 
double *dx, *dy, *Rx, *Ry; 
{
  
  int N, n;
  double dX, dY, RX, RY, s, S;

  n = 0;
  s = 10000;
  RX = *Rx;
  RY = *Ry;

  if (!FLIP || (FLIP == 1)) {
/*    FIND_SHIFT( 0.9*RX,  0.9*RY);  */
    FIND_SHIFT( 1.0*RX,  1.0*RY);
/*    FIND_SHIFT( 1.1*RX,  1.1*RY);  */
  }

  if (!FLIP || (FLIP == 2)) {
/*    FIND_SHIFT(-0.9*RX,  0.9*RY);  */
    FIND_SHIFT(-1.0*RX,  1.0*RY);
/*    FIND_SHIFT(-1.1*RX,  1.1*RY);  */
  }

  if (!FLIP || (FLIP == 3)) {
/*    FIND_SHIFT(-0.9*RX, -0.9*RY);  */
    FIND_SHIFT(-1.0*RX, -1.0*RY);
/*    FIND_SHIFT(-1.1*RX, -1.1*RY);  */
  }

  if (!FLIP || (FLIP == 4)) {
/*    FIND_SHIFT( 0.9*RX, -0.9*RY);  */
    FIND_SHIFT( 1.0*RX, -1.0*RY);
/*    FIND_SHIFT( 1.1*RX, -1.1*RY);  */
  }

  fprintf (stderr, "USING: %f %f %f %f\n", *dx, *dy, *Rx, *Ry);

}
