I'm trying to improve a site that shows the region of the Earth currently under daylight, and I need a formula that, given the current time, tells where (latitude/longitude) the sun and moon are overhead, accurate to 1 mile. Can anyone come up with one?
Ideally I'm hoping to get something JavaScript can calculate at a "reasonable speed" without recursion, loops, or extra libraries.
I've tried several things (eg, Fourier series on the Sun/Moon's RA/DEC), but nothing seems quite accurate enough.
Note: I realize my calculations for sun/moon rise/set ignore refraction and lunar parallax: for now, I'm focusing on finding the overhead positions. I realize I can pull data from a non-JavaScript CGI program (and have tried that), but it seems like a lot of unnecessary network access.