mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-03-27 19:03:39 -04:00
See this discussion: https://github.com/cosinekitty/astronomy/issues/150 For the case of calculating a map, where each pixel on the map represents a different location on the Earth, it is more efficient to factor out expensive calculation of sidereal times, assuming the entire map represents some phenomenon at a single moment in time. For example, to determine whether the Moon is visible at different places on the Earth, the following functions can be calculated across thousands of different (lat, lon) geographic coordinates around the world: ObserverVector Rotation_EQD_HOR Before iterating over the map pixels, a program can call GeoMoon, then convert EQJ coordinates to EQD. Then by passing the same time value in a loop to ObserverVector and Rotation_EQD_HOR, the program can calculate a vector from the observer to the Moon in EQD coordinates, then convert EQD to HOR. The z-coordinate of the horizontal coordinates determines whether the Moon is above or below the observer's horizon at that point on the Earth. This calculation pattern performed redundant sidereal time calculations for each pixel on the map. I changed the code for all 4 languages to cache sidereal time so that it only needs to be calculated once. In the C version of Astronomy Engine, this resulted in a speedup factor of about 2.3 in the above use case. (See the function MapPerformanceTest in generate/ctest.c.)
349 KiB
349 KiB