I've written some code to calculate the range, azimuth and elevation between two points.
Sandcastle is here: https://goo.gl/WhCP5B
The values are printed to the console.
All the calculations work very accurately. I.e. when they are used to calculate the orientation of a cylinder, the start and end of the cylinder fall exactly on the source and target.
You'll notice though that toElevationRadiansNumerical() is not very elegant. It tries different elevation angles until it finds one that produces the expected target.
Is there a better (more concise) way to calculate the elevation angle yet still produce good results?