	implicit real*8 (a-h,o-z)
	ximm=150.
	etamm=0.
	call antiflatten(ximm,etamm,ximc,yimc)
	write(6,12) ximm,etamm,ximc,yimc
12	format('FINAL',4f10.3)
	stop
	end
	subroutine antiflatten(xout,yout,xin,yin)
	implicit real*8 (a-h,o-z)
	xin=xout
	yin=yout
C Start with the assumption that the output is similar to the input
12	call flatten(xin,yin,xtest,ytest)
	inum=inum+1
	difx=xtest-xout
	dify=ytest-yout
	write(8,13) inum,difx,dify
13	format('antiflatten:',i5,2f10.3)
	if ((abs(difx).lt.0.0001).and.(abs(dify).lt.0.0001)) return
C Take half the difference
	xin=xin-difx/2.
	yin=yin-dify/2.
	go to 12
	end
C flatten routine:
	subroutine flatten(x,y,xp,yp)
	implicit real*8 (a-h,o-z)
	r=5675.2
C = 223.4 inches radius of curvature
c r is radius of curve (mm) of Lockheed camera plate adapted for WIYN  
	zed=sqrt(x**2+y**2)
	theta=zed/r
	h=r*sin(theta)
	xp=0.
	yp=0.
	if (zed.gt.0.) then
	factor=h/zed
	write(6,*) factor
	xp=x*factor
	yp=y*factor
	end if
	return
	end
