Trying to calculate hours of daylight per day at given date and latitude

Garm

New member
Joined
Dec 30, 2016
Messages
2
Hi, I'm no mathematician, so I'm not even too sure this is the proper section, but in case, please, move the thread wherever it should be.

I'm trying to write a macro to calculate the hours, or better, minutes of daylight per day at any given date of the year, at any given latitude. The user selects month (between 1 and 12), day (between 1 and 31), and latitude (between 1 and 90), and the macro should output the total minutes of daylight for those values.

I don't want it to be the most accurate daylight-calculator ever, it's for a game, and I'm alright with writing it within loose conventional values.
1) I'm not taking into account leap years, nor DST, nor wariations due to longitude or other factors.
2) I've set equinoxes and solstices at fixed dates: Spring eq = 3/21; Summer sol = 6/21; Autumn eq = 9/22; Winter sol = 12/20.
3) I've gathered approximative data about daylight times at equinoxes and solstices at latitude 0 (equator), 30, 60, and 90 (either pole, I don't differentiate between north and south, assuming it's exactly the same for both), which are the four groups of four variables being set you can see here (date = minutes of daylight in that day):

Latitude 0°
Spring Equinox = 726
Summer Solstice = 727
Autumn Equinox = 726
Winter Solstice = 727

Latitude 30°
Spring Equinox = 726
Summer Solstice = 845
Autumn Equinox = 727
Winter Solstice = 652

Latitude 60°
Spring Equinox = 730
Summer Solstice = 1132
Autumn Equinox = 732
Winter Solstice = 612

Latitude 90°
Spring Equinox = 742
Summer Solstice = 1304
Autumn Equinox = 738
Winter Solstice = 225

So, now I have the fixed intervals of time and latitude, knowing that at the designated points, minutes of daylight have to be equal to those values.
How can I calculate the number of minutes of daylight at any given date and latitude that is not one of the fixed values?

As I said, I don't want it to be the most accurate daylight calculator ever, I just want to understand how to calculate the proper variation of minutes within given date/latitude intervals (for example, Spring Eq and Summer Sol in a latitude between 30 and 60).

I tried to imagine a sort of 3D projection with four parallel planes, each of which is a cartesian plane. One for latitude 0, one for 30, one for 60 and one for 90. Each graph has the number of days of the years along the X axis, and the minutes of light along the Y. So, for each graph, every equinox or solstice is a fixed point, but I have no idea how to find the value of minutes between them AND between different latitudes.
 
Top