# Transformation of hour angle to azimuth

Converting Hour angle to Azimuth, is there a simple way to know which result is correct (as the formulas and the arccosine give various results shifted by 180° etc.), or does one just have to figure it out visually with a drawing?

$$sin(A) = - \frac{\sin(H) \cos(\delta)}{\cos(a)}$$

$$cos(A) = \frac{\sin(\delta) - \sin(\phi) \sin(a)}{ \cos(\phi) \cos(a) }$$

If there is a rule, please indicate if the Azimuth is counted from the southern or northern cardinal point.

Sketch of the equatorial and horizontal coordinate systems (I use the hour angle positive to the west and azimuth 0° at north, positive to east; I just like this illustration): You can use the signs of the $$sin A$$ and $$cos A$$ to determine the proper quadrant: The equations in the Explanatory Supplement to the Astronomical Almanac are slightly different than the ones above. These are recond with $$0^\circ$$ being North, and Western longitudes negative.

\begin{align*} \cos \mathit{a} \sin A_{z} &= -\cos \delta \sin \mathit{h} & (eq 1) \\ \cos \mathit{a} \cos A_{z} &= \sin \delta \cos \phi - \cos \delta \cos \mathit{h} \sin \phi & (eq 2) \\ \sin \mathit{a} &= \sin \delta \sin \phi + \cos \delta \cos \mathit{h} \cos \phi & (eq 3) \end{align*}

Where $$h$$ is the hour angle, $$\delta$$ is the declination, $$A_{z}$$ is azimuth, $$a$$ is altitude, $$\phi$$ is the lattitude. You will need to check the signs of $$\cos A_z$$ and $$\sin A_z$$ to determine the propper quadrant:

if $$\cos A_z$$ > 0 and $$\sin A_z$$ > 0: use either eq1 or eq2

if $$\cos A_z$$ > 0 and $$\sin A_z$$ < 0: use eq1

if $$\cos A_z$$ < 0 and $$\sin A_z$$ < 0: use $$A_z$$ = 360 - eq2

if $$\cos A_z$$ < 0 and $$\sin A_z$$ > 0: use eq2

Alternatively, I prefer to use the equations below, which allows the use of the atan2() function built in to most languages. These are based on those in Meeus, but I have modified them so that Az=$$0^\circ$$ is North, and Western longitudes are negative (same as above), agreeing with what is in common use today.

\begin{aligned} \tan A &= \dfrac{\sin H}{\cos H \sin \phi - \tan \delta \cos \phi} \\~\\ \sin a &= \sin \phi \sin \delta + \cos \phi \cos \delta \cos H \end{aligned}

The page Convert RA/Dec to Alt/Az has implementations of these, and two other alternate methods. As well as test data to verify accuracy.