Hi Erick,
Just had a look at the web site quoted and his formulae work quite well.
Before delving into the C code check the programmers maths. There is alot of unnecessary messing about.
In the article it is stated;
"note how we added 360 to LST to bring the number into the range
0 to 360 degrees"
What should be done is to invoke the modulus function (n Mod m ) ie.
lst = lst mod 360 ... this will resolve ambiguities - if needed.
In following : HA = LST - RA it is OK for lst to have a negative value
(-55.19 degrees) all this means that the angle is measured in a CW direction
This is not needed:
"If HA negative, then add 360 to bring in range 0 to 360"
An hour angle of approx. -55 - 250 = -305 degrees is the same as (90 - 35) or 55 degrees. the maths functions sin and cos should evaluate sin(-305) and cos(-305) correctly.
1. Possible problem as to why your code works sometimes may lie in the way sines and cosines are handled by the programmer.
2. Check the calculation of local sidereal time (lst) for various conditions.
|