# Who does these mesmerizing simulations of the phases of the Moon? And how?

It's lunar new year here and people will be lighting fire crackers and launching bottle rockets off and on until dawn, so I thought I would read up on it. EarthSky.org's Moon Phases update Your new moon is January 27 or 28 is really interesting, including some photos of actual new moons by Thierry Legault, the photographer who's taking those amazing photos of the ISS passing in front of the Sun, or the Moon.

But the next item down, Lengths of lunar months in 2017, is also really interesting both technically and visually, because it has this amazing GIF of the moon's changes in appearance over one orbit, shown below. This version is much better quality than the one from Wikipedia that I've used here and here. But I am not sure where it's from or how to read about it.

The information for the Wikipedia-sourced animation is difficult for me to understand already. The period is a "Draconic Month of nodes", but is that actually the same thing as the time between successive apogees? The issue here is how to generate a smooth, cyclic GIF, since an exact simulation would be jumpy - no two orbits are the same in the real world.

Also, how is the shading calculated, what kind of shader is used (diffuse reflectivity model) for the oblique sunlight incidence?

While an actual answer would be fantastic, a link to a source of the information would be helpful as well.

Source bitmap for projection from NRL's Clementine Spacecraft:

• USGS: Global simple cylindrical projection at 10 km/pixel.

Animation

• 50 frames were created, equally spaced in time.
• Period used: 27.21222 days (Draconic month of nodes)
• Animation began and ended at Apogee to minimize "jumping" when cycles back to the start.
• New moon given an unreal 1% intensity "Ambient light" to show motion in all phases.
• View assumed from the center of the earth. (Geometrically impossible, but best demonstration of monthly libration caused by moon's motion versus the shorter daily libration that would be included from the surface of the earth.)

Animation used in EarthSky.org:

EDIT: As pointed out here by the GIF's creator, the original image is actually in Wikipedia.

Animation from Wikipedia:

• Comments are not for extended discussion; this conversation has been moved to chat. – called2voyage Mar 8 '17 at 15:57

I made the images on wikipedia with my own software. The original on wikipedia is here: https://commons.wikimedia.org/wiki/File:Lunar_libration_with_phase_Oct_2007.gif

The main work needed is getting the proper position of the moon with its precessing elliptical orbit, while the orientation is based on a constant rotation rate. This book is an older one, but has sufficient terms to predict eclipses.

Book: "Astronomical Formulae for Calculators, 4th edition", Jean Meeus, 1988, published by "Willmann-Bell, Inc" Chapter 30 "Position of the Moon"

And yes, just standard diffuse lambert shading, brightness based on the cosine angle between a surface normal and the sun direction. Its actually not an accurate model for the moon which is much brighter near full moon. (And the dark side has a constant brightness, while the real moon darkside is lit most by earthshine in small phases, and even near new moono, its actually much much dimmer) https://en.wikipedia.org/wiki/Lambertian_reflectance

• Wow, thank you for taking the time to leave an answer! Did you need to do anything special to stitch the loop? Since the Earth-Moon system moves nearly 30 degrees around the Sun from one orbit to the next, there has to be some kind of orbital dove-tailing to avoid a visual glitch or jump. Did you have to do anything special here, or does the near-invisibility of the new moon effectively make the issue moot? – uhoh Mar 9 '17 at 2:18
• When you mention brighter near full moon, do you mean the Opposition surge effect or just the brightening due to simple $1/r^2$ that would happen near periapsis, which by coincidence happens near full moon in the particular time of year chosen for the animation? – uhoh Mar 9 '17 at 2:20

Creating animation like this is fairly simple using rendering tools such as POVray. All you need is a cylindrical projection map of the moon and appropriate data for the orbit of the moon. The orbital elements available on wikipedia are good enough for most uses.

For example here is some of my own work as a still image. Earth from the north pole with all of the known earthquakes mapped, size is intensity, and color is depth.

Source code available, though the explanation is nearly non-existent.

This is a reasonable good primer on animations and orbit with POVray. The method for putting an image onto a sphere is described here.

Finally, this site has a script to at least produce stills (animations just require the coding from the previously mentioned animations page)

#include "colors.inc"
#include "textures.inc"
#include "finish.inc"

//1 POV-Ray unit = 1000 km
//Earth is approx. 150 e6 km from Sun
//Moon is approx. 384 e3 km from Earth

camera {location <-2000,0,149.9E3>
look_at <100,0,150E3> angle 1}
light_source {<0,0,0> color rgb<1,1,0.9>}  //Sun

#declare Earth = sphere {  <0,0,0>, 6.38
pigment {image_map {gif "earthmap.gif" map_type 1}}
finish {ambient 0.01 diffuse 0.85 specular 0 roughness 0.01}  }

#declare Moon = sphere {  <0,0,0>, 1.74
pigment {image_map {gif   "moonmap2.gif" map_type 1}}
finish {ambient 0 diffuse 0.95 specular 0    roughness 0.5}  }

object {Earth translate <0,0,150E3>}
object {Moon translate    <384,0,150E3>}

• I have emailed Tomruen (the creator) to get more information – OrangePeel52 Mar 8 '17 at 15:55

The photos used are not views of the moon as seen from earth, but multiple orbital images that provide a direct overhead view of the entire moon.

Those images are applied as a bitmap texture to a very simple 3d model - a sphere. I'm not sure on the exact shader settings used, but those images look pretty close to the default appearance of a grey sphere.

Then all you need is a script that tells you where to put the moon, camera and light source for each frame as per the related question.

The smooth cycling comes from careful date selection. Both animations start and end at apogee so that the apparent size is consistent between the first and last frames, and the dates are chosen so that this coincides with a new moon. A dark frame hides any small differences that may exist, and the terminator is not visible, so it doesn't matter if the next orbit would be lit from a slightly different angle.

The draconic month (time between apogees) is two days shorter than the synodic month (time between new moons), but that shouldn't be enough to cause serious issues - it is the equivalent of three frames that can reasonably be dropped if they occur near new moon when the terminator is not visibly moving much.

• Oh! I didn't notice that @AndrewThompson has just put a bounty on this question. It's possible those requirements would be different than mine. You might add a link to this excellent answer which explains in more detail the source of the images used for this simulation. – uhoh Mar 8 '17 at 9:30
• I meant create a primitive in your 3d software of choice, add a light source, and it will probably come out something like that. You are overthinking the shading unless you plan to build your own renderer - simply adjust the diffusion settings until it resembles a real photo of the moon. As for those images specifically, the wikipedia one has a link to the guy who made it. The other one doesn't show a source, but appears to be the same thing rendered at higher resolution. – Quentin Clarkson Mar 8 '17 at 9:45
• OK well any rendering will use a mathematical model. Certainly if there is a diffusion setting then there is a mathematical model that uses that setting, and that model will indeed have a name. But for sure, one has the option to not know about it or even pretend it's not there if one chooses. I think the problem now is that you are posting an answer for the bounty-writer, not me, so I'll step out of that conversation now. – uhoh Mar 8 '17 at 9:56
• Probably Lambert shading, but that starts getting more into something more appropriate for blender.stackexchange.com – Quentin Clarkson Mar 8 '17 at 10:20