Written with the northern hemisphere in mind... swap relevant parts for the southern hemisphere
near the equator
, realise that the value can get above 90 degrees. (This will occur between the equinoxes
In this case, the actual height above the horizon will be 180 minus the calculated value, although the sun will now be in the north, not the south.
The equation can be extended to give the height of the sun above the horizon at any hour... (day
is measured from January 1st, and hour
c = 90 - latitude The celestial sphere
altitude = -c*cos(360*hour/24)+23.5*sin(360*(day-80)/365)
If the result is negative, then you will be in some stage of twilight
The equation assumes the following approximations:
I have to acknowledge PhasedWeasel's writeup without which I wouldn't have had the inspiration to take it further.