<p>First we set up our global coordinate system as following:</p>
<p>Origin: center of Earth. <span class="math-container">$\vec z$</span>: earth's axis (North Pole is the positive direction), <span class="math-container">$\vec x$</span> and <span class="math-container">$\vec y$</span> represent the
equatorial plane with <span class="math-container">$\vec x$</span> points towards the location of noon.</p>
<p>The unit vector of sun is <span class="math-container">$\vec S = (\sin \lambda,0, \cos \lambda)$</span>. The unit vector of local zenith is <span class="math-container">$\vec Z = (\cos\phi \cos \theta,\cos\phi \sin\theta ,\sin \phi)$</span>. The unit vector of local East is <span class="math-container">$\vec E = (-\sin \theta, \cos\theta, 0)$</span>.</p>
<p>To calculate the Azimuth angle, we need first to project <span class="math-container">$\vec S$</span> onto the local East-North plane: <span class="math-container">$\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)$</span>.</p>
<p>Then calculate the dot product of the projection and the unit vector of local East, <span class="math-container">$\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$</span>.</p>
<p>Finally, <span class="math-container">$\cos\left&lt; \vec P,\vec E\right&gt; = (\vec P \cdot \vec E)/|\vec P| = -\sin\theta\sin\lambda / \sin \Omega$</span>.</p>

CC BY-SA 4.0
2022-08-12T15:18:37.020Z
Thanks! I actually spent some time re-creating the proof and this is how I ended up doing it.
aman
CC BY-SA 4.0
2022-08-01T01:34:39.903Z
2022-08-01T02:08:59.270Z
2022-08-01T02:08:59.270Z
Salmonella mayonnaise
<p>Have a look at <a href="https://www.pveducation.org" rel="nofollow noreferrer">https://www.pveducation.org</a>, specifically section 2.4 on Terrestrial Solar Radiation. It describes the equations required and has some online calculators and interactive plots.</p>
<p>If you wish to calculate in your own code, I'd recommend the pysolar Python package: <a href="https://pysolar.readthedocs.io/en/latest/" rel="nofollow noreferrer">https://pysolar.readthedocs.io/en/latest/</a>.  It has methods for taking the latitude, longitude and time of day to calculate the Sun's azimuth and altitude.</p>

CC BY-SA 4.0
2021-03-14T10:01:49.067Z
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.
aman
CC BY-SA 4.0
2021-03-13T20:25:38.400Z
2021-03-13T20:25:38.400Z
Emanuel V
<p>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.</p>

CC BY-SA 4.0
2021-03-13T15:07:16.240Z
Just to be clear, by North Pole you mean the actual North Pole of Earth correct?
aman
CC BY-SA 4.0
2021-03-13T17:41:11.597Z
Yes. The south pole would work as well.
stretch
CC BY-SA 4.0
2021-03-14T09:59:38.183Z
Unfotunately, I don't really have an understanding of spherical geometry, I was able to solve it using vectors though.
aman
CC BY-SA 4.0
2021-03-14T12:30:44.537Z
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.
stretch
CC BY-SA 4.0
2021-03-15T08:59:22.957Z
Although Wikipedia is generally *not* a good place to learn new mathematics, https://en.wikipedia.org/wiki/Spherical_trigonometry isn't too bad, if you're already comfortable with plane trig and vectors.
PM 2Ring
CC BY-SA 4.0
2021-03-18T03:51:52.813Z
Yes, which of the two angles to select can be determined using intuition, like azimuth is more than 180 after noon. I'll also look into the Wikipedia page thanks
aman
CC BY-SA 4.0
2021-03-13T14:34:20.180Z
2021-03-14T12:08:43.343Z
2021-03-14T12:08:43.343Z
stretch
<p>I tried posting this on math stack exchange to no avail so I thought maybe it's more relevant here :</p>
<p>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.</p>
<p><a href="https://astronomy.stackexchange.com/questions/29782/how-do-i-calculate-the-suns-azimuth-based-on-zenith-hour-angle-declination-a">How do I calculate the sun&#39;s azimuth based on zenith, hour angle, declination, and latitude?</a></p>
<p>I was recently trying to derive the position of the Sun in the sky given the latitude, time of year and time of day.</p>
<p>I used the following definitions:</p>
<p><span class="math-container">$\phi :$</span> I used this to denote the angle of latitude, as per convention</p>
<p><span class="math-container">$t:$</span> I used this to denote the angle of the year completed since Summer solstice</p>
<p><span class="math-container">$\theta:$</span> I used this to denote the angle of the day completed since solar noon</p>
<p><span class="math-container">$\Omega:$</span> I used this to denote the solar zenith angle.</p>
<p><span class="math-container">$\Gamma:$</span> I used this to denote the azimuth of the Sun clockwise from due North</p>
<p><span class="math-container">$k:$</span> I used this to denote the angle of 66.56 degrees between the Earth's axis and plane of revolution</p>
<p><span class="math-container">$\lambda:$</span>  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 <span class="math-container">$\delta$</span></p>
<p>My goal was to get a function <span class="math-container">$f(\phi, t, k,\theta)=\Omega,\Gamma$</span></p>
<p>I was able (with some help) to derive the following formulae:</p>
<p><span class="math-container">$\cos(\lambda)= \cos(t)*\cos(k)$</span></p>
<p><span class="math-container">$\cos(\Omega)=\cos(\lambda)*\sin(\phi)+\cos(\phi)*\sin(\lambda)*\cos(\theta)$</span></p>
<p>However, I was not able to then derive the formula given on the following Wikipedia page for <span class="math-container">$\Gamma=f(\theta,\lambda,\Omega)$</span> which I have transcribed into my variables below:</p>
<p><a href="https://en.wikipedia.org/wiki/Solar_azimuth_angle" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Solar_azimuth_angle</a></p>
<p><span class="math-container">$\sin(\Gamma)=-\dfrac{(\sin(\theta)*\sin(\lambda))}{\sin(\Omega)}$</span></p>
<p>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.</p>
<p>Can someone help me to proceed?</p>

CC BY-SA 4.0
2022-08-01T02:31:47.733Z
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.
Greg Miller
<coordinate><declination><ecliptic><azimuth><horizon>
Solar Azimuth angle Derivation
aman
# Solar Azimuth angle Derivation

(Asked by: username_0 on 2021-03-13)

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?](https://astronomy.stackexchange.com/questions/29782/how-do-i-calculate-the-suns-azimuth-based-on-zenith-hour-angle-declination-a)

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)$

$\cos(\Omega)=\cos(\lambda)\*\sin(\phi)+\cos(\phi)\*\sin(\lambda)\*\cos(\theta)$

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:

<https://en.wikipedia.org/wiki/Solar_azimuth_angle>

$\sin(\Gamma)=-\dfrac{(\sin(\theta)\*\sin(\lambda))}{\sin(\Omega)}$

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?

**Tags:** coordinate, declination, ecliptic, azimuth, horizon

> **Comments:**
> **username_1**: 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.  

---

## 3 answers

### Answer by username_2 on 2022-08-01. Score: 1 | Accepted answer

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$.

> **Comments:**
> **username_0**: Thanks! I actually spent some time re-creating the proof and this is how I ended up doing it.  

---

### Answer by username_3 on 2021-03-13. Score: 1

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.

> **Comments:**
> **username_0**: 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.  

---

### Answer by username_4 on 2021-03-13. Score: 1

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.

> **Comments:**
> **username_0**: Just to be clear, by North Pole you mean the actual North Pole of Earth correct?  
> **username_4**: Yes. The south pole would work as well.  
> **username_0**: Unfotunately, I don't really have an understanding of spherical geometry, I was able to solve it using vectors though.  
> **username_4**: 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.  
> **username_5**: Although Wikipedia is generally *not* a good place to learn new mathematics, https://en.wikipedia.org/wiki/Spherical_trigonometry isn't too bad, if you're already comfortable with plane trig and vectors.  
> **username_0**: Yes, which of the two angles to select can be determined using intuition, like azimuth is more than 180 after noon. I'll also look into the Wikipedia page thanks  

---

