# Conversion from Equatorial Coordinate to Horizon Coordinates

I'm developing my own Planetarium software using C++ following the book Practical Astronomy with your Calculator or Spreadsheet 4th Edition.

I don't know if I my formulas are correct or not, but when I check my results (Azimuth and Altitude) with Stellarium, they are different.

I have also checked my values with this page, but they are different. By the way, the azimuth and altitude given in that page are also different from the values given in Stellarium.

Do you know where can I find the formulas to covert celestial coordinate to horizontal coordinates?

• Several immediate thoughts (eg, are you using radians when computing trigonometric functions), but the most obvious question: can we see your source code? – barrycarter Jan 4 '16 at 16:11
• Yes, I'm using radians. And no, you can't see my source code. There are a lot of classes. – VansFannel Jan 5 '16 at 7:07
• Did you verified your results other sources, and also cross-checked the same for stellarium? Maybe your reference frame is different. – Astroynamicist Jan 5 '16 at 14:37
• How about just the part of your source code that does the calculation? Trying to debug a "black box" is fairly difficult. – barrycarter Jan 5 '16 at 15:17

$$\tan A = {\sin h \over \cos h \sin\phi_o - \tan\delta \cos\phi_o}$$ $$\begin{cases} \cos a \sin A = \cos\delta \sin h \\ \cos a \cos A = \cos\delta \cos h \sin\phi_o - \sin\delta \cos\phi_o \end{cases}$$ $$\sin a = \sin\phi_o \sin\delta + \cos\phi_o \cos\delta \cos h$$
Where $A$ is azimuth, $a$ altitude, $\alpha$ right ascension, $\delta$ declination, $h$ hour angle and $\phi_0$ the observer's latitude.