3
$\begingroup$

I'm trying to make a simple app for my own use to be able to check which of my favorit restaurants have outdoor seating sun and for how long etc.

Given the data in the title (sunrise, noon, sunset, longitude and latitude) I can draw a path where the sun should be at any given time, but I want to display the hight as well.

I live in sweden where the sun changes "hight angle" (sorry I don't know the exact term for it) which make the angle relevant when deciding on seatings amongst high buildings. My end goal is to be able to use google maps 3D data to actually cast shadows on the map in a realistic way!

I have no Idea if I'm in the right place but I figure I'll give it a shot :)

$\endgroup$

1 Answer 1

3
$\begingroup$

To the precision that you need, you can calculate the azimuth A and altitude h of the Sun from the following equations: $$ \tan(A) = \frac{\sin(H)}{\cos(H)\sin(\phi)-\tan(\delta)\cos(\phi)}\\ \sin(h)=\sin(\phi)\sin(\delta)+\cos(\phi)\cos(\delta)\cos(H) $$ where

  • A is the azimuth measured from due south (positive towards the west)
  • H is the hour angle which is the number of degrees before (negative angle) or after (positive) solar noon. Calculate this as 15*1.00274*(time of day - time of noon).
  • $\phi$ is the latitude (positive for northern hemisphere)
  • $\delta$ is the declination of the Sun. This can be calculated from the second equation by assuming the altitude of the Sun h=0 when it is rising or setting, and H=15*1.00274*time from sunrise to solar noon. The assumption here is that the time from solar noon to sunset is the same.
  • h is the altitude of the Sun above the horizon.

All of the above quantities are in degrees. You may need to convert those to radians to perform the trigonometry calculations.

For a more accurate calculation, you would calculate the position of the Sun (its right ascension $\alpha$ and declination $\delta$) and Greenwich Mean Sidereal Time (GMST) based on the date and time throughout the day. Then using the latitude and longitude, you would calculate H, A, and h for various times of the day.

$\endgroup$
4
  • $\begingroup$ Those formulas make more sense if $H$ is the solar hour angle. $\endgroup$
    – Mike G
    May 22, 2018 at 3:29
  • $\begingroup$ You're right! I put the description in the wrong location. Hopefully it makes more sense now. Thanks Mike G. $\endgroup$
    – JohnHoltz
    May 22, 2018 at 15:09
  • $\begingroup$ That's better. The 1.00274 sidereal factor doesn't apply to the Sun though. $\endgroup$
    – Mike G
    May 22, 2018 at 15:33
  • $\begingroup$ I agree that since the motion of the Sun (increasing in right ascension approximately 1 degree per day) is ignored in my approach, the factor of 1.00274 is entirely unnecessary. (Also, atmospheric refraction that causes sunrise to be earlier than "theoretical" and the Sun's diameter affects my calculation of the Sun's declination.) If this discussion were about a non-moving object on an airless planet, the factor of 1.00274 would be needed to convert delta clock time in hours to an angle (also in measured in hours, of right ascension), and then the factor of 15 converts that angle to degrees. $\endgroup$
    – JohnHoltz
    May 23, 2018 at 3:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .