Uh, uh..
this is not so easy as I thought it would be.
The basic theory is here:
http://en.wikipedia.org/wiki/Spherical_trigonometry
here :
http://www.hps.cam.ac.uk/starry/sphertrig.html
and here:
http://mathworld.wolfram.com/SphericalTrigonometry.html
One of the issues is lens and FOV distortion, result of projection from celestial sphere to flat surface of the sensor.
If we assume ideal lens (pinhole), then the problem can be solved easier.
However, I need some more time to think about it, unfortunately I forgot a lot of this stuff since I used it last time

....
I will be back with this.. no way I will give up now . especially because I am interested in this kind of work.