forrestguice / SuntimesWidget

Android app (and widget collection) that displays sunlight and moonlight times.
GNU General Public License v3.0
335 stars 61 forks source link

Eclipses times #237

Open FTno opened 6 years ago

FTno commented 6 years ago

The world map was a really nice new feature in the latest version, and if I may propose another new feature, I would like to see times for eclipses (both sun and moon) in the app.

forrestguice commented 6 years ago

That would be a really neat feature. I'll look into this.

xandro0777 commented 3 years ago

Doing this "right" is not trivial: for the Sun eclipses the calculation needs to be very exact and the calculation is valid only in one place - thus you could easily miss a sun eclipse 100 miles away.

What would be much easier is is to display the angular difference of sun&moon positions at every full and new moon - and alert the user if it is close enough to value where we could hope for an eclipse somewhere)

forrestguice commented 3 years ago

I've looked into this a few times. As noted its not trivial. It involves solving a couple hard problems. First, determining the date an eclipse will occur on, and second, determining the location and shape of the shadow it will cast.

\<hand waving>

I think its relatively easy to determine potential eclipse dates using simple brute force. As suggested, the app could compare the angular distance during each eclipse season and flag those days when an eclipse might occur somewhere.

Another approach is to simply look these dates up. Knowledge of the Saros cycle makes them easy to predict, and NASA conveniently publishes a complete list. Its a lot of data (too much), but the app could probably restrict itself to near-future/past. Or the app might try to derive these tables on its own, storing only minimal information about each cycle. This would be arguably way cooler (not to mention more challenging).

The second problem, determining the shape of the shadow, I think is a lot more difficult. It can be done by solving for a series of equations to determine the "Besselian elements" of the eclipse. Trying to understand how these equations work is a headache - not exactly my idea of fun. NASA also publishes these values. Knowing these, its then possible to draw the shadow using our chosen map projection.

\<\/hand waving>

Anyhow, I haven't given up on this feature, but nobody hold their breath..

xandro0777 commented 3 years ago

there are different possibilities to solve that have their merrits.