SolarCalculator
SolarCalculator copied to clipboard
Add hourAngle function and wrapper function w/ equatorial coordinates
For telescopes and other things that rely on equatorial mounts, it is necessary to calculate hour angle in addition to declination. I added one new function and two wrapper functions that calculate equatorial coordinates and hour angle (one w/ unix time one with time a variables, like the existing equatorial coordinates function).
Hi, sorry for the delay. I will respond in a few days.
Since the hour angle (HA) can be determined from the Greenwich sidereal time (GMST), observer's longitude, and target's right ascension (RA), I suggest simply adding the two last lines to your code:
JulianDay jd(utc);
double ra, dec, r;
calcEquatorialCoordinates(jd, ra, dec, r);
double gmst = calcGrMeanSiderealTime(jd);
double sun_ha = gmst + obs_lon - ra;
The reason is: I'm already not a fan of the wrapper function scheme I am using. Although it reduces the final program size (in bytes), it is redundant. I'm hesitant to add any more before figuring out a better way.
I agree that in improved version of this library, HA/Dec coordinates should be available as an alternative to RA/Dec.
Thank you for your response. It may also be useful in some situations to have the coordinates in vector form as well (specifically useful for mirrors/heliostats), but of course it's not that hard to just add this in my code.
I do agree that using the wrapper functions causes some redundant calcs, but I'm not really an experienced enough programmer to come up with any ideas for an alternative.
Feel free to close pull request.