Is there an algorithm for determining how much daylight there is?
Is there a function/algorithm that allows me to input the latitude and the approximate orbital position of the earth in so that I can determine how long the sun is up? IE during the winter开发者_开发技巧 it would show that the sun is only up a few hours in the far north hemisphere.
I did some basic Google search and didn't find much so I was thinking that I might have to do some trigonometry that would allow me to calculate how much the earth is inclined or not toward the sun then use that information along with the latitude to figure out how much sunshine a site would be getting.
Nice problem. Would this Sunset/Sunrise algorithm be helpful?
Source:
Almanac for Computers, 1990
published by Nautical Almanac Office
United States Naval Observatory
Washington, DC 20392
You can use the Sunrise/Sunset Algorithm to calculate the start/end of each day, and then just subtract to get the amount of daylight.
Also, NOAA hosts an improved sunrise/sunset calculator which includes an online tool as well as links to their JavaScript source code and other resources.
精彩评论