# include "astro.h"

void ranges (stars1, stars2, N1, N2, Xrange, Yrange, Xzero, Yzero, Rx, Ry)
Stars stars1[], stars2[];
int N1, N2;
double *Xrange, *Yrange, *Xzero, *Yzero;
double Rx, Ry;
{

  int i;
  double maxX1, minX1, maxY1, minY1;
  double maxX2, minX2, maxY2, minY2;

  maxX1 = minX1 = stars1[0].X;
  maxY1 = minY1 = stars1[0].Y;

  for (i = 0; i < N1; i++) {
    maxX1 = MAX (maxX1, stars1[i].X);    
    minX1 = MIN (minX1, stars1[i].X);    
    maxY1 = MAX (maxY1, stars1[i].Y);    
    minY1 = MIN (minY1, stars1[i].Y);    
  }

  maxX2 = minX2 = Rx*stars2[0].X;
  maxY2 = minY2 = Ry*stars2[0].Y;
  for (i = 0; i < N2; i++) {
    maxX2 = MAX (maxX2, (Rx*stars2[i].X));    
    minX2 = MIN (minX2, (Rx*stars2[i].X));    
    maxY2 = MAX (maxY2, (Ry*stars2[i].Y));    
    minY2 = MIN (minY2, (Ry*stars2[i].Y));    
  }

  *Xzero = minX1 - maxX2;
  *Yzero = minY1 - maxY2;
  *Xrange = ((maxX1 - minX2) - (minX1 - maxX2));
  *Yrange = ((maxY1 - minY2) - (minY1 - maxY2));

}
