#include <stdlib.h>

#include "tree.h"
#include "readpts.h"
#include "rand01.h"
#include "f_est.h"
#include "test.h"

#define max(a,b) ((a>b)?a:b)

int main(int argc,
	 char *argv[]
	 )
{
  coord *points=NULL;
  coord *events=NULL;
  int n=0; /* Number of events read from file */
  int i;
  double a;
  double b;
  double r;
  long seed=1032621985;

  if(argc <= 1){
    fprintf(stderr,"There was no specified input!\n");
    return 1;
  }

  events=readpoints(argv[1],&a,&b,&n,points);
  if(events==NULL){
    fprintf(stderr,"Failed to read file %s",argv[1]);
    exit(1);
  }

  /* GENERATE n POINTS */
  points=(coord *)malloc(sizeof(coord)*n);
  if(events==NULL){
    fprintf(stderr,"Failed to allocate space for points");
    exit(1);
  }
  for(i=n; i>=0; --i){
    points[i].x=rand1(&seed);
    points[i].y=rand1(&seed);
  }

  for(r=0.001; r < max(a,b)/2; r+=0.001){
    printf("%g\n",f_tor(points,events,n,a,b,r));
  }
  return 0.0;
}
