## Altitude and Azimuth Calculation

### Introduction

Given the coordinates of an object, our location on the earths surface,
and the local sidereal time, it is possible to calculate the altitude
and azimuth of the object.
Those who study the following equations will observe that the site longitude
does not appear in the calculations. It would have been used in the calculation
of the local sidereal time, and is no longer needed once that has been done.

It will also be noticed that the RA of the object is used only in the calculation
of the hour angle (HA) and that once the HA is known, neither RA nor LST are needed.

The following equations are written in a C (or Fortran) style pseudocode.

ha = lst - ra
sinh = sin(lat) * sin(dec) + cos(lat) * cos(dec) * cos(ha)
sinz = -cos(dec)*sin(ha)
cosz = ( sin(dec) - sin(lat)*sinh ) / cos(lat)
sin(alt) = sinh
tan(az) = cosz / sinz

Notice that division by zero would occur for a site at the pole with a latitude of 90 degrees.

An "altaz" (altazimuth) telescope would also need the parallactic angle of an object to
control an image derotator, and this may be calculated as follows:

sinb = -sin(az) * cos(lat) / cos(dec)
cosb = -cos(ha) * cos(az) - sin(ha) * sin(az) * sin(lat)
tan(pa) = cosb / sinb

Notice again that division by zero would occur for an object with a declination of 90 degrees
(at the celestial pole).

Notice that inverse trigonometric functions will need to be used to calculate alt, az, and pa.
Typically the "atan2" function with two arguments is used to calculate the inverse tangent, as
it gives the angle over the appropriate full range of 0-360 degrees, perhaps constrained to the
range -180 to 180.

### The Astronomical Triangle

The above equations are derived using spherical trigonometry.
The triangle in question is known as the "astronomical triangle" and is
the triangle with vertices being the object of interest (O) , the zenith (Z), and the north celestial pole (P).
The three sides of this triangle are:

- The side "o" joining Z to P has length 90 - latitude
- The side "p" joining O to Z has length 90 - altitude ("zenith distance")
- The side "z" joining O to P has length 90 - declination

The angles at the vertices of this triangle are:
- The angle at P is "h" - the hour angle
- The angle at Z is 180-A, where A is the azimuth
- The angle at O is "pa" - the parallactic angle

Have any comments? Questions?
Drop me a line!

Tom's home page / tom@mmto.org