I tried posting this on math stack exchange to no avail so I thought maybe it's more relevant here :

I know a similar question has been posted here before but no links to any mathematical derivations given on the following post. I was not able to access the citations on the wiki page either.

How do I calculate the sun's azimuth based on zenith, hour angle, declination, and latitude?

I was recently trying to derive the position of the Sun in the sky given the latitude, time of year and time of day.

I used the following definitions:

$\phi :$ I used this to denote the angle of latitude, as per convention

$t:$ I used this to denote the angle of the year completed since Summer solstice

$\theta:$ I used this to denote the angle of the day completed since solar noon

$\Omega:$ I used this to denote the solar zenith angle.

$\Gamma:$ I used this to denote the azimuth of the Sun clockwise from due North

$k:$ I used this to denote the angle of 66.56 degrees between the Earth's axis and plane of revolution

$\lambda:$ I used this to denote the angle between the Earth's axis and the vector in the direction of the sun, this is complementary to the more commonly used declination angle $\delta$

My goal was to get a function $f(\phi, t, k,\theta)=\Omega,\Gamma$

I was able (with some help) to derive the following formulae:

$\cos(\lambda)= \cos(t)*\cos(k)$


However, I was not able to then derive the formula given on the following Wikipedia page for $\Gamma=f(\theta,\lambda,\Omega)$ which I have transcribed into my variables below:



I think in order to derive this I need to convert to a local co-ordinate system with due North along the y-axis, due East along the x-axis and zenith along the z-axis.

Can someone help me to proceed?

  • $\begingroup$ It's not entirely clear what your question is, but it sounds like you want a derivation of the equation, not just the equation itself? If so, it's roughly a series of rotations. E.g. a rotation about the x axis based on the observer's latitude, another about the y axis for longitude. Another about the y axis for the Earth Rotation Angle, and lastly a rotation about the y axis for the obliquity of the ecliptic. The process is detailed in "Computational Spherical Astronomy" by Laurence Taff. $\endgroup$ Aug 1, 2022 at 2:31

3 Answers 3


First we set up our global coordinate system as following:

Origin: center of Earth. $\vec z$: earth's axis (North Pole is the positive direction), $\vec x$ and $\vec y$ represent the equatorial plane with $\vec x$ points towards the location of noon.

The unit vector of sun is $\vec S = (\sin \lambda,0, \cos \lambda)$. The unit vector of local zenith is $\vec Z = (\cos\phi \cos \theta,\cos\phi \sin\theta ,\sin \phi)$. The unit vector of local East is $\vec E = (-\sin \theta, \cos\theta, 0)$.

To calculate the Azimuth angle, we need first to project $\vec S$ onto the local East-North plane: $\vec P = \vec S-\cos \Omega \ \vec Z =(\sin\lambda - \cos\Omega \cos\phi \cos \theta,- \cos\Omega\cos\phi \sin\theta, \cos \lambda - \cos \Omega \sin \phi)$.

Then calculate the dot product of the projection and the unit vector of local East, $\vec P \cdot \vec E = (\sin \lambda - \cos\Omega \cos\phi \cos \theta)(-\sin \theta)+(- \cos\Omega\cos\phi \sin\theta\cos\theta) = -\sin\theta\sin\lambda$.

Finally, $\cos\left< \vec P,\vec E\right> = (\vec P \cdot \vec E)/|\vec P| = -\sin\theta\sin\lambda / \sin \Omega$.

  • $\begingroup$ Thanks! I actually spent some time re-creating the proof and this is how I ended up doing it. $\endgroup$
    – aman
    Aug 12, 2022 at 15:18

Have a look at https://www.pveducation.org, specifically section 2.4 on Terrestrial Solar Radiation. It describes the equations required and has some online calculators and interactive plots.

If you wish to calculate in your own code, I'd recommend the pysolar Python package: https://pysolar.readthedocs.io/en/latest/. It has methods for taking the latitude, longitude and time of day to calculate the Sun's azimuth and altitude.

  • $\begingroup$ Thanks, but I was looking for a nice derivation, I already have the intuition for the problem. I made an excel spreadsheet and was able to use dot products to solve the problem of finding the azimuth but couldn't really cleanly derive the formula in a mathematically elegant way. $\endgroup$
    – aman
    Mar 14, 2021 at 10:01

What I think you're trying to do is workable, but approximate. You first find the Sun's geographical position (GP), the point on the Earth where the Sun is in zenith at the time of the observation. You start by finding the Sun's GP latitude (its declination). It's approximately 23 degrees times the sine of ((days since the vernal equinox)times 360/365). Then you find its longitude as the ((hours since local apparent noon)times(15 degrees) + observer's west longitude). You will have three points, vertices of a spherical triangle: observer's location, Sun's GP, and the north pole. The angle at the pole is the difference between the longitudes of the Sun's GP and the observer. The sides between the pole and the other two points are 90 degrees minus their latitudes. All that's needed to solve a spherical triangle is the arc length of two sides and their included angle. Using the law of cosines for spherical triangles, find the arc distance between the observer and the Sun's GP. The altitude of the sun will be 90 degrees minus that number. Find the angle at the observer using the law of sines for spherical triangles. That will be the Sun's azimuth.

  • $\begingroup$ Just to be clear, by North Pole you mean the actual North Pole of Earth correct? $\endgroup$
    – aman
    Mar 13, 2021 at 15:07
  • $\begingroup$ Yes. The south pole would work as well. $\endgroup$
    – stretch
    Mar 13, 2021 at 17:41
  • $\begingroup$ Unfotunately, I don't really have an understanding of spherical geometry, I was able to solve it using vectors though. $\endgroup$
    – aman
    Mar 14, 2021 at 9:59
  • 1
    $\begingroup$ There's not much to understand about spherical trigonometry. There are only two equations for most problems. There are online calculators that will immediately return the third side and the other two angles if given two sides and their included angle. The only tricky part is that answers come from inverse trigonometric functions no matter how you do the calculation, and give you one of two possible answers. You need to calculate the other answer and decide which is correct. Your expressions for azimuth and zenith angle also have that problem, you probably know. $\endgroup$
    – stretch
    Mar 14, 2021 at 12:30
  • $\begingroup$ Although Wikipedia is generally not a good place to learn new mathematics, en.wikipedia.org/wiki/Spherical_trigonometry isn't too bad, if you're already comfortable with plane trig and vectors. $\endgroup$
    – PM 2Ring
    Mar 15, 2021 at 8:59

You must log in to answer this question.

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