Wouldn't it be easier to use the image as a texture on a sphere or hemisphere in blender or some other 3d app and just take a render of it?

I know it's not what you want, as you seem to be streets ahead of me on the maths, but perhaps the obvious solution was overlooked...