      subroutine fixell(p,r,npts,a,rfit)
      real*8 r(*),p(*),rfit(*),a(*),esqr
c--centx=a1,centy=a2,position angle=a3,major axis=a4,minor axis=a5
      integer*4 nangles
      parameter (nangles=36)
      real*8 ex(nangles),ey(nangles)
      common /edata/ex,ey
      do i=1,npts
       dx=ex(i)-a(1)
       dy=ey(i)-a(2)
       r(i)=sqrt(dx**2+dy**2)
       p(i)=atan2(dy,dx)-a(3)
       esqr=1.D0-a(5)*a(5)/(a(4)*a(4))
       rfit(i)=sqrt(a(5)*a(5)/(1.D0-esqr*cos(p(i))*cos(p(i))))
      enddo
      return
      end
