On windows 7, look at the file
c:\windows\winsxs...\weather.js
There is a function computeSunRiseSunSet(Latitude, Longitude, TimeZone, Year, Month, Day).
They don't cite the source of the algorithm.
One line of code is
var C2=RD*(Math.atan(Math.tan(L0+C)) - Math.atan(.9175*Math.tan(L0+C))-C);
Why is there Math.atan( Math.tan( L0+C )) ?
Is it the same as ( L0+C ) or there are corner cases ?
atan(tan(x)) is a periodic "sawtooth" function:
for -pi/2 < x < pi/2, atan(tan(x)) = x
for pi/2 < x < 3pi/2, atan(tan(x)) = x - pi
for 3pi/2 < x < 5pi/2, atan(tan(x)) = x - 2pi
...
You can plot it and see other details about it on Wolfram Alpha.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With