KeithRB:
I don't think it can optimise away function calls
I'm pretty sure that modern compilers are capable of optimising away function calls which are known not to have any side effects - I've been told so by somebody I trusted, anyway. (I'm less sure that they can be counted on to work out for themselves which functions have side effects, so that optimisation might only apply to 'well known' library functions, but it certainly does apply for some functions.)
Azimuth/elevation is going to give you a direction over a spherical or hemispherical range.
X/Y is a location in a plane. Not the same thing.
Which sort of plane do you think you are mapping your hemisphere onto ?