Given a position on earth (latitude/longitude, and maybe also height relative to sea-level) and a time, what's the algorithm to find how many degrees the Sun is from the horizon?
And the same for the opposite, given a location and date, how do you calculate the time when the Sun will be such-and-such degrees from the horizon (such as to calculate astronomical dusk and dawn)?
Best Answer
There are a number of steps involved, each of which are straightforward individually, but when combined make the process a bit tedious to do by hand. The following steps are only a conceptual outline, and ignore a number of important considerations, including but not limited to the ellipticity of the Earth's orbit. The outline of the algorithm is:
For a treatment sufficient for actual calculation, you can start with Practical Astronomy with your Calculator or Spreadsheet by Duffett-Smith & Zwart. For higher precision, you can go to Astronomical Algorithms by Meeus.