cosinekitty / astronomy

Astronomy Engine: multi-language calculation of Sun, Moon, and planet positions. Predicts lunar phases, eclipses, transits, oppositions, conjunctions, equinoxes, solstices, rise/set times, and other events. Provides vector and angular coordinate transforms among equatorial, ecliptic, horizontal, and galactic orientations.
MIT License
496 stars 64 forks source link

Generic correction of light travel time #217

Closed cosinekitty closed 2 years ago

cosinekitty commented 2 years ago

Currently the GeoVector functions correct for light travel time, but other functions like HelioVector do not. The idea is that a caller of GeoVector wants to know where a planet appears to be, not where it actually is at a given moment. A caller of HelioVector is more likely interested in the instantaneous positions of planets.

It would be better if there were a generic mechanism for correcting light travel time. The new feature would require passing in a callback function that maps a time to a distance in AU. It would iterate until the distance matches the amount of time in the past the light must have left to reach the observer. The light travel corrector would support an observer anywhere in the solar system, not just on the Earth.

For more efficiency, perhaps the callback could return a state vector rather than a distance, and the same state vector could be returned to the travel time corrector's caller. In practice, that caller usually wants the position/state vector at the backdated time, and it is wasteful to have to calculate it again.

To keep the existing behavior of GeoVector, the callback should also have a context parameter, allowing enabling/disabling aberration correction. (Simply use an interface instead of a callback+context in languages that support interfaces.)