Coding Eccentricities

Standing in the Shadow of the Moon

Solar eclipses offer the unique ability to stand in the shadow of a massive solar system body. When that moment of totality (or annularity) occurs you get the opportunity to witness the simultaneous sunsets and sunrises on another planetary body. The unique geometry of our Earth-Moon system allows us to view this rare spectacle as the perceived lunar size is nearly the exactly the same as of the Sun: There’s no other place in the solar system where this occurs.

Solar Eclipse Diagram

the orbit of the Moon is planar and the geometry of it’s shadow is conical, when cast on another rotating spherical body, the Earth, the lunar shadow is contorted into unique and odd shapes. During a solar eclipse, the shadow of the Moon is rarely circular, and is often an odd ellipsoid shape that races from 10,000 to 2000 mph across the surface of the Earth. NASA has provided excellent animations of the Moon’s traversal across the globe during eclipses. I find it interesting that such a perfectly round object moving in a nearly perfect plane can create such oddly fascinating tracks across our planet.

NASA’s online animated shadow: Can non-astronomer/non-professional developer recreate this?

During a total eclipse, especially from an elevated location, it is possible to witness the lunar shadow race toward you: I want to know it is coming!

I made it my endeavor to see if it was possible to recreate this NASA’s shadow images using the somewhat limited computing power of a mobile phone. I wanted something that was self-contained and worked in an environment without an online connection. Other websites and apps often use pre-computed points to display an eclipse circumstance map. My app differs from this approach as it only stores a small set of Besselian elements (28 floating point numbers per eclipse) that compute the entire eclipse map and animated shadow.

The Moon’s shadow near sunset from an annular solar eclipse in January 1992 as calculated by Eclipse Explorer.

While there were plenty of online resources to use Besselian elements to compute eclipse times and circumstances for a particular spot on Earth, I was at a loss to find resources to construct eclipse maps and shadow dynamics. Being neither an astronomer, mathematical expert, or even a full time software developer I gave it my best.

In the end, I used JavaScript’s somewhat new ability to spawn multiple parallelcomputations to scan and interpolate points that create the maps and animations you see in the Eclipse Explorer App. It’s not a perfect solution, and there are other and possibly better ways to make these computations, but it was a fantastic learning experience. I expanded my software development skills while digging around in trigonometric math that I haven’t dealt with in years (or ever).

Please keep all this in mind, I’m pushing the limits of what is possible with what was supposed to be a “scripting” programming language while also pushing the limits of what a small handheld computer can calculate: User results will vary and batteries will be drained: There’s no way around it, this is a lot of math all at once all in the palm of your hand.