We now begin with a vital part of astronomical calculations – how to convert between different coordinate systems.

Each coordinate system has advantages and disadvantages for different areas of work, so each is used where applicable. The main coodinate systems in use in astronomy are the Equatorial, Horizontal, Ecliptic and Galactic coordinate systems.

The most important of these for astronomical work are Equatorial coordinates, so I tend to use this as a basis to convert all the other coordinates to and from each other. In this tutorial I will handle the conversion between equatorial and horizontal coodinates, and then cover the others in later tutorials, but first some definitions.

The equatorial coordinate system is the projection of the normal geographic coordinates on the earth. So, what this means, is that the lines of longitude and latitude on the earth are projected to an imaginary celestial sphere, with the celestial equator above the earth’s equator, and the celestial poles above the earth’s poles.

The sphere is split up into longitude and latitude, just like the Earth is. The longitude is known as the right ascension, and is measured in hours, with the zero point being the First Point of Aries, which is the point where the Sun is in at the Vernal Equinox (on March 21st). This value will change over time due to precession and nutation, but that is out of the scope of this tutorial.

The latitude is known as declination (denoted by δ), and is the distance in degrees that an object is away from the celestial equator, with the poles being 90 degrees, just like latitude on the earth’s surface.

Now, let us look at horizontal coordinates, also known as alt-azimuth coordinates. Here, the coodinates in the sky are demarcated by the height about the horizon (altitude) expressed in degrees, with 90 degrees being vertically upwards, and the azimuth, which is the direction to the object in relation to north, expressed in degrees in the range 0-360 degrees.

Before we can convert between the two coordinate systems, we need to find the hour angle from the right ascension. The right ascension is based on the star’s position in the celestial sphere, whereas the hour angle converts that value to a value based on the earth’s longitude and latitude.

This is done by calculating the Local Sidereal Time, using the Universal Time and longitude of the observer’s position, and then subtracting the right ascension from that to get the hour angle.

		public static double ConvRAToHA(double fRA, DateTime dUT, double fLong)
		{
			//Convert Right Ascension to Hour Angle at specified time and longitude
			double fLST;
			double fHA;

			fLST = UraniaTime.ConvTimeToDec(UraniaTime.CalcLSTFromUT(dUT, fLong));

			fHA = fLST - fRA;
			fHA = Trig.PutIn24Hour(fHA);

			return fHA;
		}

		public static double ConvHAToRA(double fHA, DateTime dUT, double fLong)
		{
			//Convert Hour Angle to Right Ascension at specified time and longitude
			double fLST;
			double fRA;
			
			fLST = UraniaTime.ConvTimeToDec(UraniaTime.CalcLSTFromUT(dUT, fLong));

			fRA = fLST - fHA;
			fRA = Trig.PutIn24Hour(fRA);

			return fRA;
		}

Converting between these requires some considerable trigonometry, but is not overly complicated. We need to pass the hour angle (as calculated using the previous function), declination and latitude to find the horizontal coordinates.

Finding the equatorial coordinates from the horizontal coordinates is merely the inverse of the previous steps. Once we have the declination and hour angle, we can convert the hour angle to the right ascension as detailed in the previous section.

		public static void ConvEquToHor(double fLatitude, double fHA, double fDecl, ref double fAlt, ref double fAzim)
		{
			double fSinAlt;
			double fCosAzim;

			fHA = Trig.DegToRad(fHA * 15);
			fDecl = Trig.DegToRad(fDecl);
			fLatitude = Trig.DegToRad(fLatitude);
			fSinAlt = (Math.Sin(fDecl) * Math.Sin(fLatitude)) + (Math.Cos(fDecl) * Math.Cos(fLatitude) * Math.Cos(fHA));
			fAlt = Math.Asin(fSinAlt);
			fCosAzim = ((Math.Sin(fDecl) - (Math.Sin(fLatitude) * Math.Sin(fAlt))) / (Math.Cos(fLatitude) * Math.Cos(fAlt)));
			fAzim = Trig.RadToDeg(Math.Acos(fCosAzim));
			if (Math.Sin(fHA) > 0)
			{
				fAzim = 360 - fAzim;
			}
			fAlt = Trig.RadToDeg(fAlt);
		}

		public static void ConvHorToEqu(double fLatitude, double fAlt, double fAzim, ref double fHA, ref double fDecl)
		{
			double fSinDecl;
			double fCosH;

			fAlt = Trig.DegToRad(fAlt);
			fAzim = Trig.DegToRad(fAzim);
			fLatitude = Trig.DegToRad(fLatitude);
			fSinDecl = (Math.Sin(fAlt) * Math.Sin(fLatitude)) + (Math.Cos(fAlt) * Math.Cos(fLatitude) * Math.Cos(fAzim));
			fDecl = Math.Asin(fSinDecl);
			fCosH = ((Math.Sin(fAlt) - (Math.Sin(fLatitude) * Math.Sin(fDecl))) / (Math.Cos(fLatitude) * Math.Cos(fDecl)));
			fHA = Trig.RadToDeg(Math.Acos(fCosH));
			if (Math.Sin(fAzim) > 0)
			{
				fHA = 360 - fHA;
			}
			
			fDecl = Trig.RadToDeg(fDecl);
			fHA = fHA / 15.0;
		}

Share